本文整理汇总了Java中javax.vecmath.Matrix4d.invert方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4d.invert方法的具体用法?Java Matrix4d.invert怎么用?Java Matrix4d.invert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Matrix4d
的用法示例。
在下文中一共展示了Matrix4d.invert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateViewersTransformation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private void updateViewersTransformation()
{
if ( mViewers .size() == 0 )
return;
Matrix4d trans = new Matrix4d();
model .getViewTransform( trans, 0d );
trans .invert();
for ( int i = 0; i < mViewers .size(); i++ )
mViewers .get( i ) .setViewTransformation( trans, Viewer .MONOCULAR );
model .getStereoViewTransform( trans, Viewer .LEFT_EYE );
trans .invert();
for ( int i = 0; i < mViewers .size(); i++ )
mViewers .get( i ) .setViewTransformation( trans, Viewer .LEFT_EYE );
model .getStereoViewTransform( trans, Viewer .RIGHT_EYE );
trans .invert();
for ( int i = 0; i < mViewers .size(); i++ )
mViewers .get( i ) .setViewTransformation( trans, Viewer .RIGHT_EYE );
}
示例2: invert
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Invert the transform, this object is inverted and returned.
*
* @return return this
*/
public CellTransform invert() {
// This invert for jme does not function when the scale != 1
// Matrix3f rot = new Matrix3f();
// rot.set(rotation);
// float temp;
// temp=rot.m01;
// rot.m01=rot.m10;
// rot.m10=temp;
// temp=rot.m02;
// rot.m02=rot.m20;
// rot.m20=temp;
// temp=rot.m21;
// rot.m21=rot.m12;
// rot.m12=temp;
// rot.multLocal(1/scale);
//
// rot.multLocal(translation);
//
// translation.multLocal(-1);
// scale = 1/scale;
//
// rotation.fromRotationMatrix(rot);
// Correctly compute the inversion, use Vecmath as the matrix invert
// in JME does not function when scale!=1
Quat4d q = new Quat4d(rotation.x, rotation.y, rotation.z, rotation.w);
Vector3d t = new Vector3d(translation.x, translation.y, translation.z);
Matrix4d m = new Matrix4d(q,t,scale);
m.invert();
m.get(q);
m.get(t);
scale = (float)m.getScale();
rotation.set((float)q.x, (float)q.y, (float)q.z, (float)q.w);
translation.set((float)t.x, (float)t.y, (float)t.z);
return this;
}
示例3: setViewTransformation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
@Override
public void setViewTransformation( Matrix4d trans, int eye )
{
if ( eye == Viewer .MONOCULAR ) {
Matrix3d justRotation3d = new Matrix3d();
trans .get( justRotation3d );
justRotation3d .invert(); // to match the invert() in the caller
Matrix4d finalTransform = new Matrix4d();
finalTransform .set( this .translation );
finalTransform .setRotation( justRotation3d );
finalTransform .invert(); // to match the invert() in the caller
this .delegate .setViewTransformation( finalTransform, Viewer .MONOCULAR );
}
}
示例4: getWorldRotation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void getWorldRotation( Quat4d q )
{
Vector3d axis = new Vector3d( q.x, q.y, q.z );
Matrix4d viewTrans = new Matrix4d();
model .getViewTransform( viewTrans, 0d );
viewTrans .invert();
// now map the axis back to world coordinates
viewTrans .transform( axis );
q.x = axis.x; q.y = axis.y; q.z = axis.z;
}
示例5: mapViewToWorld
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void mapViewToWorld( Vector3f vector )
{
Matrix4d viewTrans = new Matrix4d();
model .getViewTransform( viewTrans, 0d );
viewTrans .invert();
viewTrans .transform( vector );
}
示例6: mapViewToWorld
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void mapViewToWorld( Camera view, Vector3f vector )
{
Matrix4d viewTrans = new Matrix4d();
view .getViewTransform( viewTrans, 0d );
viewTrans .invert();
viewTrans .transform( vector );
}
示例7: analyze
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* This method is the main function call to extract all step parameters, pairing parameters, and sequence
* information from the Structure object provided to the constructor.
* @return This same object with the populated data, convenient for output
* (e.g. <i>log.info(new BasePairParameters(structure).analyze());</i>)
*/
public BasePairParameters analyze() {
if (structure == null) {
pairingParameters = null;
stepParameters = null;
return this;
}
List<Chain> nucleics = this.getNucleicChains(nonredundant);
List<Pair<Group>> pairs = this.findPairs(nucleics);
this.pairingParameters = new double[pairs.size()][6];
this.stepParameters = new double[pairs.size()][6];
Matrix4d lastStep;
Matrix4d currentStep = null;
for (int i = 0; i < pairs.size(); i++) {
lastStep = currentStep;
currentStep = this.basePairReferenceFrame(pairs.get(i));
referenceFrames.add((Matrix4d)currentStep.clone());
for (int j = 0; j < 6; j++) pairingParameters[i][j] = pairParameters[j];
if (i != 0) {
lastStep.invert();
lastStep.mul(currentStep);
double[] sparms = calculateTp(lastStep);
for (int j = 0; j < 6; j++) stepParameters[i][j] = sparms[j];
}
}
return this;
}
示例8: getSymmetryAxes
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Recursive helper
* @param symmAxes output list
* @param prior transformation aligning the first repeat of this axis with the first overall
* @param level current level
*/
private void getSymmetryAxes(List<Axis> symmAxes, Matrix4d prior, int level, int firstRepeat) {
if(level >= getNumLevels() ) {
return;
}
Axis elem = axes.get(level);
Matrix4d elemOp = elem.getOperator();
// Current axis:
// elementary maps B -> A
// prior maps I -> A and J -> B
// want J -> I = J -> B -> A <- I= inv(prior) * elementary * prior
Matrix4d currAxisOp = new Matrix4d(prior);
currAxisOp.invert();
currAxisOp.mul(elemOp);
currAxisOp.mul(prior);
Axis currAxis = new Axis(currAxisOp,elem.getOrder(),elem.getSymmType(),level,firstRepeat);
symmAxes.add(currAxis);
//Remember that all degrees are at least 2
getSymmetryAxes(symmAxes,prior,level+1,firstRepeat);
//New prior is elementary^d*prior
Matrix4d newPrior = new Matrix4d(elemOp);
newPrior.mul(prior);
int childSize = getNumRepeats(level+1);
getSymmetryAxes(symmAxes,newPrior,level+1,firstRepeat+childSize);
for(int d=2;d<elem.getOrder();d++) {
newPrior.mul(elemOp,newPrior);
getSymmetryAxes(symmAxes,newPrior,level+1,firstRepeat+childSize*d);
}
}
示例9: intersect
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
@Override
public final void intersect(final Ray ray, final IntersectResult result,
final double tMin, final double tMax) {
final Ray transformedRay = new Ray(ray);
if (transform != null) {
final Matrix4d mInv = transform.getMinv();
mInv.transform(transformedRay.eyePoint);
transformedRay.viewDirection = (Vector3d) ray.viewDirection.clone();
mInv.transform(transformedRay.viewDirection);
}
final IntersectResult subResult = new IntersectResult();
IntersectResult closestResult = null;
// Find closest intersection
for (final AbstractSurfaceXml surf : children) {
surf.intersect(transformedRay, subResult, tMin, tMax);
if (subResult.p != null
&& (result.p == null || subResult.tIn < result.tIn)) {
closestResult = subResult;
}
}
// Set result to closest intersection
if (closestResult != null) {
final IntersectResult transformedResult = new IntersectResult();
transformedResult.set(closestResult);
if (transform != null) {
final Matrix4d m = transform.getM();
m.transform(transformedResult.p);
final Matrix4d transposed = new Matrix4d();
transposed.transpose(m);
transposed.invert();
transposed.transform(transformedResult.n);
transformedResult.n.normalize();
}
result.set(transformedResult);
if (material != null) {
result.material = material;
}
}
}
示例10: postSet
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void postSet() {
final Matrix4d m = getM();
if (translation != null) {
final Matrix4d t = new Matrix4d();
t.set(translation);
m.mul(t);
}
if (rotation != null) {
final Matrix4d r = new Matrix4d();
r.rotX(Math.toRadians(rotation.x));
m.mul(r);
r.rotY(Math.toRadians(rotation.y));
m.mul(r);
r.rotZ(Math.toRadians(rotation.z));
m.mul(r);
}
if (scale != null) {
final Matrix4d s = new Matrix4d();
s.setIdentity();
s.setElement(0, 0, scale.x);
s.setElement(1, 1, scale.y);
s.setElement(2, 2, scale.z);
m.mul(s);
}
final Matrix4d minv = getMinv();
minv.invert(getM());
}
示例11: getInverseTransform
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Computes the inverse affine transform.
*/
public AffineTransform3D getInverseTransform() {
Matrix4d invertedMatrix = new Matrix4d(matrix);
invertedMatrix.invert();
return new AffineTransform3D(invertedMatrix);
}
示例12: doAlign
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private void doAlign() {
if (alignMarkers[0] == null || alignMarkers[1] == null || otherMarkers[0] == null || otherMarkers[1] == null) {
JOptionPane.showMessageDialog( null, "click meshes to create align markers" );
return;
}
Matrix4d toOrigin = buildFrame( alignMarkers );
toOrigin.invert();
Matrix4d o = buildFrame( otherMarkers );
toOrigin.mul( o, toOrigin );
toOrigin.m13 += vOffset;
Transform t = new Transform();
t.fromTransformMatrix( Jme3z.toJme ( toOrigin ) );
toAlign.moveTo( t );
// System.out.println ( "bounds "+ toAlign.gNode.getWorldBound() );
}
示例13: convertToMini
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public static void convertToMini( Iterable<File> bigObj, File outfile, Matrix4d transform ) {
outfile.mkdirs();
ObjDump src = new ObjDump( bigObj );//.iterator().next() );
src.centerVerts();
src.transform (transform);
long count = src.material2Face.entrySet().stream().mapToInt( x -> x.getValue().size() ).sum();
double[] bounds = src.orderVert.stream().collect( new InaxPoint3dCollector() );
long targetCount = 5000;
double volume = ( bounds[ 1 ] - bounds[ 0 ] ) * ( bounds[ 3 ] - bounds[ 2 ] ) * ( bounds[ 5 ] - bounds[ 4 ] );
double edgeLength = Math.pow( volume / ( count / targetCount ), 0.3333 );
int
xc = (int) Math.ceil( ( bounds[ 1 ] - bounds[ 0 ] ) / edgeLength ),
yc = (int) Math.ceil( ( bounds[ 3 ] - bounds[ 2 ] ) / edgeLength ),
zc = (int) Math.ceil( ( bounds[ 5 ] - bounds[ 4 ] ) / edgeLength );
Set<Face>[][][] faces = new Set[xc][yc][zc];
for ( Entry<Material, List<Face>> e : src.material2Face.entrySet() )
for ( Face f : e.getValue() ) {
Tuple3d vt = src.orderVert.get( f.vtIndexes.get( 0 ) );
int ix = (int) ( ( vt.x - bounds[ 0 ] ) / edgeLength );
int iy = (int) ( ( vt.y - bounds[ 2 ] ) / edgeLength );
int iz = (int) ( ( vt.z - bounds[ 4 ] ) / edgeLength );
if ( faces[ ix ][ iy ][ iz ] == null )
faces[ ix ][ iy ][ iz ] = new HashSet();
faces[ ix ][ iy ][ iz ].add( f );
}
int dir = 0;
MiniTransform mt = new MiniTransform();
for ( int x = 0; x < xc; x++ )
for ( int y = 0; y < yc; y++ )
for ( int z = 0; z < zc; z++ ) {
Set<Face> miniF = faces[ x ][ y ][ z ];
if ( miniF == null )
continue;
Matrix4d trans = new Matrix4d();
trans.setIdentity();
trans.setScale( edgeLength / 255 );
trans.setTranslation( new Vector3d(
x * edgeLength + bounds[0],
y * edgeLength + bounds[2],
z * edgeLength + bounds[4]
) );
Matrix4d pack = new Matrix4d( trans );
pack.invert();
ObjDump mini = new ObjDump();
miniF.stream().forEach( f -> mini.addFaceFrom( f, src ) );
mini.transform( pack );
mini.dump( new File( new File( outfile, "" + dir ), OBJ ) );
mt.index.put( dir, trans );
dir++;
}
try {
new XStream().toXML( mt, new FileWriter( new File( outfile, INDEX ) ) );
} catch ( IOException e1 ) {
e1.printStackTrace();
}
System.out.println( "wrote " + count + " faces to " + dir + " meshes" );
}
示例14: testOrientation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Test {@link UnitQuaternions#orientation(javax.vecmath.Point3d[])}.
* <p>
* Tests the identity orientation, orientation around one coordinate axis
* and orientation around a non-coordinate axis.
*
* @throws StructureException
* @throws IOException
*/
@Test
public void testOrientation() throws IOException, StructureException {
// Get points from a structure. It is difficult to generate points
// with no bias in their distribution (too uniform, ie).
Structure pdb = StructureIO.getStructure("4hhb.A");
Point3d[] cloud = Calc.atomsToPoints(StructureTools
.getRepresentativeAtomArray(pdb));
// Center the cloud at the origin
CalcPoint.center(cloud);
// Orient its principal axes to the coordinate axis
Quat4d orientation = UnitQuaternions.orientation(cloud);
Matrix4d transform = new Matrix4d();
transform.set(orientation);
transform.invert();
CalcPoint.transform(transform, cloud);
// The orientation found now should be 0 (it has been re-oriented)
orientation = UnitQuaternions.orientation(cloud);
AxisAngle4d axis = new AxisAngle4d();
axis.set(orientation);
// No significant rotation
assertEquals(orientation.x, 0.0, 0.01);
assertEquals(orientation.y, 0.0, 0.01);
assertEquals(orientation.z, 0.0, 0.01);
assertEquals(axis.angle, 0.0, 0.01);
// Now try to recover an orientation
Quat4d quat = new Quat4d(0.418, 0.606, 0.303, 0.606);
Matrix4d mat = new Matrix4d();
mat.set(quat);
CalcPoint.transform(mat, cloud);
orientation = UnitQuaternions.orientation(cloud);
// Test recovering the quaternion (q and -q same rotation)
assertEquals(Math.abs(orientation.x), quat.x, 0.01);
assertEquals(Math.abs(orientation.y), quat.y, 0.01);
assertEquals(Math.abs(orientation.z), quat.z, 0.01);
assertEquals(Math.abs(orientation.w), quat.w, 0.01);
}
示例15: getCameraToWorldTransform
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Give the matrix used to tranform a Camera Coordinate to a World
* Coordinate.
*
* @return The matrix for the transformation.
*/
public Matrix4d getCameraToWorldTransform() {
Matrix4d temp = (Matrix4d) matrix.clone();
temp.invert();
return temp;
}