本文整理汇总了Java中javax.vecmath.Matrix4d.setTranslation方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4d.setTranslation方法的具体用法?Java Matrix4d.setTranslation怎么用?Java Matrix4d.setTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Matrix4d
的用法示例。
在下文中一共展示了Matrix4d.setTranslation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: combineTransformation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
static Matrix4d combineTransformation(Matrix4d matrix, Vector3d translation, Vector3d rotation) {
Matrix4d gM = new Matrix4d(matrix);
Matrix4d m = new Matrix4d();
m.setIdentity();
m.setTranslation(translation);
gM.mul(m);
m.setIdentity();
m.rotZ(rotation.z);
gM.mul(m);
m.setIdentity();
m.rotY(rotation.y);
gM.mul(m);
m.setIdentity();
m.rotX(rotation.x);
gM.mul(m);
return gM;
}
示例2: getMatrixFromAlgebraic
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public static Matrix4d getMatrixFromAlgebraic(String transfAlgebraic) {
String[] parts = transfAlgebraic.toUpperCase().split(",");
double[] xCoef = convertAlgebraicStrToCoefficients(parts[0].trim());
double[] yCoef = convertAlgebraicStrToCoefficients(parts[1].trim());
double[] zCoef = convertAlgebraicStrToCoefficients(parts[2].trim());
Matrix4d mat = new Matrix4d();
mat.setIdentity();
mat.setRotation(new Matrix3d(xCoef[0],xCoef[1],xCoef[2],yCoef[0],yCoef[1],yCoef[2],zCoef[0],zCoef[1],zCoef[2]));
mat.setTranslation(new Vector3d(xCoef[3],yCoef[3],zCoef[3]));
return mat;
//return new Matrix4d(xCoef[0],xCoef[1],xCoef[2],xCoef[3],
// yCoef[0],yCoef[1],yCoef[2],yCoef[3],
// zCoef[0],zCoef[1],zCoef[2],zCoef[3],
// 0,0,0,1);
}
示例3: translate
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void translate(double x, double y, double z) {
Matrix4d mat = this.matrixStack.peek();
Matrix4d translation = this.getMatrix();
translation.setIdentity();
Vector3d vector = this.getVector(x, y, z);
translation.setTranslation(vector);
this.freeVector(vector);
mat.mul(translation);
this.freeMatrix(translation);
}
示例4: calcTransformation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Superposition coords2 onto coords1 -- in other words, coords2 is rotated,
* coords1 is held fixed
*/
private void calcTransformation() {
// transformation.set(rotmat,new Vector3d(0,0,0), 1);
transformation.set(rotmat);
// long t2 = System.nanoTime();
// System.out.println("create transformation: " + (t2-t1));
// System.out.println("m3d -> m4d");
// System.out.println(transformation);
// combine with x -> origin translation
Matrix4d trans = new Matrix4d();
trans.setIdentity();
trans.setTranslation(new Vector3d(xtrans));
transformation.mul(transformation, trans);
// System.out.println("setting xtrans");
// System.out.println(transformation);
// combine with origin -> y translation
ytrans.negate();
Matrix4d transInverse = new Matrix4d();
transInverse.setIdentity();
transInverse.setTranslation(new Vector3d(ytrans));
transformation.mul(transInverse, transformation);
// System.out.println("setting ytrans");
// System.out.println(transformation);
}
示例5: getParentTransformation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private float[][] getParentTransformation(List<QubbleCuboid> parentCuboids)
{
Matrix4d matrix = new Matrix4d();
matrix.setIdentity();
Matrix4d transform = new Matrix4d();
for (QubbleCuboid cuboid : parentCuboids)
{
transform.setIdentity();
transform.setTranslation(new Vector3d(cuboid.getPositionX(), cuboid.getPositionY(), cuboid.getPositionZ()));
matrix.mul(transform);
transform.rotZ(cuboid.getRotationZ() / 180 * Math.PI);
matrix.mul(transform);
transform.rotY(cuboid.getRotationY() / 180 * Math.PI);
matrix.mul(transform);
transform.rotX(cuboid.getRotationX() / 180 * Math.PI);
matrix.mul(transform);
}
double sinRotationAngleY, cosRotationAngleY, sinRotationAngleX, cosRotationAngleX, sinRotationAngleZ, cosRotationAngleZ;
sinRotationAngleY = -matrix.m20;
cosRotationAngleY = Math.sqrt(1 - sinRotationAngleY * sinRotationAngleY);
if (Math.abs(cosRotationAngleY) > 0.0001)
{
sinRotationAngleX = matrix.m21 / cosRotationAngleY;
cosRotationAngleX = matrix.m22 / cosRotationAngleY;
sinRotationAngleZ = matrix.m10 / cosRotationAngleY;
cosRotationAngleZ = matrix.m00 / cosRotationAngleY;
}
else
{
sinRotationAngleX = -matrix.m12;
cosRotationAngleX = matrix.m11;
sinRotationAngleZ = 0;
cosRotationAngleZ = 1;
}
float rotationAngleX = (float) (this.epsilon((float) Math.atan2(sinRotationAngleX, cosRotationAngleX)) / Math.PI * 180);
float rotationAngleY = (float) (this.epsilon((float) Math.atan2(sinRotationAngleY, cosRotationAngleY)) / Math.PI * 180);
float rotationAngleZ = (float) (this.epsilon((float) Math.atan2(sinRotationAngleZ, cosRotationAngleZ)) / Math.PI * 180);
return new float[][] { { this.epsilon((float) matrix.m03), this.epsilon((float) matrix.m13), this.epsilon((float) matrix.m23) }, { rotationAngleX, rotationAngleY, rotationAngleZ } };
}
示例6: 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" );
}
示例7: setUp
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Generate two clouds of random points of different sizes to test
* correctness and performance of superposition algorithms.
*
* @throws StructureException
*/
@Before
public void setUp() throws StructureException {
cloud1 = new ArrayList<Point3d[]>(5);
cloud2 = new ArrayList<Point3d[]>(5);
Random rnd = new Random(0);
transform = new Matrix4d();
transform.set(rotAxis);
transform.setTranslation(translation);
List<Integer> sizes = Arrays.asList(5, 50, 500, 5000, 50000, 500000);
for (Integer size : sizes) {
Point3d[] c1 = new Point3d[size];
Point3d[] c2 = new Point3d[size];
for (int p = 0; p < size; p++) {
Point3d a = new Point3d(rnd.nextInt(100), rnd.nextInt(50),
rnd.nextInt(150));
c1[p] = a;
// Add some noise
Point3d b = new Point3d(a.x + rnd.nextDouble(), a.y
+ rnd.nextDouble(), a.z + rnd.nextDouble());
c2[p] = b;
}
CalcPoint.center(c1);
CalcPoint.center(c2);
CalcPoint.transform(transform, c1);
cloud1.add(c1);
cloud2.add(c2);
Point3d centroid1 = CalcPoint. centroid(c1);
Point3d centroid2 = CalcPoint. centroid(c2);
LOGGER.debug("Centroid c1 (size %d): (%.2f, %.2f, %.2f)\n", size, centroid1.x, centroid1.y, centroid1.z);
LOGGER.debug("Centroid c2 (size %d): (%.2f, %.2f, %.2f)\n", size, centroid2.x, centroid2.y, centroid2.z);
}
}
示例8: testSymmetryQCP
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Test case proposed by Peter Rose from his observations about quaternary
* symmetry artifacts with the QCP algorithm.
*/
@Test
public void testSymmetryQCP() {
// Generate an array of points with symmetry
Point3d[] set1 = new Point3d[16];
set1[0] = new Point3d(14.065934, 47.068832, -32.895836);
set1[1] = new Point3d(-14.065934, -47.068832, -32.895836);
set1[2] = new Point3d(-47.068832, 14.065934, -32.895836);
set1[3] = new Point3d(47.068832, -14.065934, -32.895836);
set1[4] = new Point3d(-14.065934, 47.068832, 32.895836);
set1[5] = new Point3d(14.065934, -47.068832, 32.895836);
set1[6] = new Point3d(47.068832, 14.065934, 32.895836);
set1[7] = new Point3d(-47.068832, -14.065934, 32.895836);
set1[8] = new Point3d(43.813946, 22.748293, -32.14434);
set1[9] = new Point3d(-43.813946, -22.748293, -32.14434);
set1[10] = new Point3d(-22.748293, 43.813946, -32.14434);
set1[11] = new Point3d(22.748293, -43.813946, -32.14434);
set1[12] = new Point3d(-43.813946, 22.748293, 32.14434);
set1[13] = new Point3d(43.813946, -22.748293, 32.14434);
set1[14] = new Point3d(22.748293, 43.813946, 32.14434);
set1[15] = new Point3d(-22.748293, -43.813946, 32.14434);
Point3d[] set2 = CalcPoint.clonePoint3dArray(set1);
// Use a random transformation to set2
AxisAngle4d rotAxis = new AxisAngle4d(0.440, 0.302, 0.845, 1.570);
Vector3d translation = new Vector3d(0.345, 2.453, 5.324);
Matrix4d transform = new Matrix4d();
transform.set(rotAxis);
transform.setTranslation(translation);
CalcPoint.transform(transform, set2);
// Use Quaternion superposition to obtain the RMSD
SuperPosition algorithm = new SuperPositionQuat(false);
long quatStart = System.nanoTime();
double quatrmsd = algorithm.getRmsd(set1, set2);
long quatTime = (System.nanoTime() - quatStart) / 1000;
// Use QCP algorithm to get the RMSD
algorithm = new SuperPositionQCP(false);
long qcpStart = System.nanoTime();
double qcprmsd = algorithm.getRmsd(set1, set2);
long qcpTime = (System.nanoTime() - qcpStart) / 1000;
logger.info(String.format("RMSD Symmetry: Quat time: %d us"
+ ", QCP time: %d us", quatTime, qcpTime));
// Check that the returned RMSDs are equal
assertEquals(quatrmsd, qcprmsd, 0.001);
}
示例9: combineWithTranslation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Adds translational component to rotation matrix
* @param rotTrans
* @param rotation
* @return
*/
private void combineWithTranslation(Matrix4d rotation) {
rotation.setTranslation(centroid);
rotation.mul(rotation, centroidInverse);
}
示例10: combineWithTranslation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Adds translational component to rotation matrix
* @param rotation
* @return
*/
private void combineWithTranslation(Matrix4d rotation) {
rotation.setTranslation(centroid);
rotation.mul(rotation, centroidInverse);
}