public Matrix() { this.matrixStack = new Stack<>(); Matrix4d matrix = new Matrix4d(); matrix.setIdentity(); this.matrixStack.push(matrix); }
/** * Return all symmetry axes of of the structure: the set of axes that * describe all parts of the structure. This combines the elementary * axes to generate all possible axes. The axes are returned in the repeat * degrees. * @return axes all symmetry axes of the structure. */ public List<Axis> getSymmetryAxes(){ List<Axis> symmAxes = new ArrayList<>(); Matrix4d prior = new Matrix4d(); prior.setIdentity(); getSymmetryAxes(symmAxes,prior,0,0); return symmAxes; } /**
public void translate(double x, double y, double z) { Matrix4d matrix = this.matrixStack.peek(); Matrix4d translation = new Matrix4d(); translation.setIdentity(); translation.setTranslation(new Vector3d(x, y, z)); matrix.mul(translation); }
public void rotate(double angle, double x, double y, double z) { Matrix4d matrix = this.matrixStack.peek(); Matrix4d rotation = new Matrix4d(); rotation.setIdentity(); rotation.setRotation(new AxisAngle4d(x, y, z, angle * (Math.PI / 180))); matrix.mul(rotation); }
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); }
private Matrix4d reorientHelix(int index) { Matrix4d matrix = new Matrix4d(); matrix.setIdentity(); matrix.setRotation(new AxisAngle4d(1,0,0,Math.PI/2*(index+1))); matrix.mul(transformationMatrix); return matrix; }
@Override public String getOrientation(int index) { StringBuilder s = new StringBuilder(); s.append(setCentroid()); // calculate orientation Matrix4d matrix = new Matrix4d(); matrix.setIdentity(); matrix.setRotation(new AxisAngle4d(1,0,0,Math.PI/2*(index+1))); Quat4d r = new Quat4d(); r.set(new AxisAngle4d(1,0,0,index*Math.PI/2)); Quat4d q = new Quat4d(); q.set(helixAxisAligner.getRotationMatrix()); r.mul(q); // set orientation s.append("moveto 4 quaternion{"); s.append(jMolFloat(r.x)); s.append(","); s.append(jMolFloat(r.y)); s.append(","); s.append(jMolFloat(r.z)); s.append(","); s.append(jMolFloat(r.w)); s.append("}"); s.append(";"); return s.toString(); }
private void addEOperation() { List<Integer> permutation = Arrays.asList(new Integer[]{0,1}); Matrix4d transformation = new Matrix4d(); transformation.setIdentity(); combineWithTranslation(transformation); AxisAngle4d axisAngle = new AxisAngle4d(); QuatSymmetryScores scores = new QuatSymmetryScores(); int fold = 1; // ?? Rotation rotation = createSymmetryOperation(permutation, transformation, axisAngle, fold, scores); rotations.addRotation(rotation); }
/** * Return the transformation that needs to be applied to a * repeat in order to superimpose onto repeat 0. * * @param repeat the repeat index * @return transformation matrix for the repeat */ public Matrix4d getRepeatTransform(int repeat){ Matrix4d transform = new Matrix4d(); transform.setIdentity(); int[] counts = getAxisCounts(repeat); for(int t = counts.length-1; t>=0; t--) { if( counts[t] == 0 ) continue; Matrix4d axis = new Matrix4d(axes.get(t).getOperator()); for(int i=0;i<counts[t];i++) { transform.mul(axis); } } return transform; }
public void setC1(int n) { Rotation r = new Rotation(); List<Integer> permutation = new ArrayList<Integer>(n); for (int i = 0; i < n; i++) { permutation.add(i); } r.setPermutation(permutation); Matrix4d m = new Matrix4d(); m.setIdentity(); r.setTransformation(m); r.setAxisAngle(new AxisAngle4d()); r.setFold(1); r.setScores(new QuatSymmetryScores()); rotations.add(r); pointGroup = "C1"; }
identity.setIdentity();
/** * 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); }
@Override public ResultSample doInverse3Test(final int count, final int maxCount, final long timeOutMS) { final Matrix4d mat = vecMatrixRandom(); final Matrix3d m1 = new Matrix3d( // mat.getElement(0, 0), mat.getElement(0, 1), mat.getElement(0, 2), // mat.getElement(1, 0), mat.getElement(1, 1), mat.getElement(1, 2), // mat.getElement(2, 0), mat.getElement(2, 1), mat.getElement(2, 2)); mat.setIdentity(); final long start = System.currentTimeMillis(); int loopCount = 0; while (System.currentTimeMillis() - start < timeOutMS && loopCount != maxCount) { ++loopCount; for (int i = 0; i < count; ++i) { m1.invert(); } } mat.set(m1); return populateResult(System.currentTimeMillis() - start, loopCount, toArray(mat)); }
transform.setIdentity();
mat.setIdentity(); Matrix4d transform = new Matrix4d(); transform.setIdentity(); transform.setTranslation(new Vector3d(cube.getPosition())); mat.mul(transform);
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);
private void calcTransformationBySymmetryAxes() { Vector3d[] axisVectors = new Vector3d[2]; axisVectors[0] = new Vector3d(principalRotationVector); axisVectors[1] = new Vector3d(referenceVector); // y,z axis centered at the centroid of the subunits Vector3d[] referenceVectors = new Vector3d[2]; referenceVectors[0] = new Vector3d(Z_AXIS); referenceVectors[1] = new Vector3d(Y_AXIS); transformationMatrix = alignAxes(axisVectors, referenceVectors); // combine with translation Matrix4d combined = new Matrix4d(); combined.setIdentity(); Vector3d trans = new Vector3d(subunits.getCentroid()); trans.negate(); combined.setTranslation(trans); transformationMatrix.mul(combined); // for cyclic geometry, set a canonical view for the Z direction if (rotationGroup.getPointGroup().startsWith("C")) { calcZDirection(); } }
private void calcTransformationByInertiaAxes() { Vector3d[] axisVectors = new Vector3d[2]; axisVectors[0] = new Vector3d(principalAxesOfInertia[0]); axisVectors[1] = new Vector3d(principalAxesOfInertia[1]); Vector3d[] referenceVectors = new Vector3d[2]; referenceVectors[0] = new Vector3d(Y_AXIS); referenceVectors[1] = new Vector3d(X_AXIS); // align inertia axes with y-x plane transformationMatrix = alignAxes(axisVectors, referenceVectors); // combine with translation Matrix4d translation = new Matrix4d(); translation.setIdentity(); Vector3d trans = new Vector3d(subunits.getCentroid()); trans.negate(); translation.setTranslation(trans); transformationMatrix.mul(translation); }
private void calcTransformationBySymmetryAxes() { Vector3d[] axisVectors = new Vector3d[2]; axisVectors[0] = new Vector3d(principalRotationVector); axisVectors[1] = new Vector3d(referenceVector); // y,z axis centered at the centroid of the subunits Vector3d[] referenceVectors = new Vector3d[2]; referenceVectors[0] = new Vector3d(Z_AXIS); referenceVectors[1] = new Vector3d(Y_AXIS); transformationMatrix = alignAxes(axisVectors, referenceVectors); // combine with translation Matrix4d combined = new Matrix4d(); combined.setIdentity(); Vector3d trans = new Vector3d(subunits.getCentroid()); trans.negate(); combined.setTranslation(trans); transformationMatrix.mul(combined); // for helical geometry, set a canonical view for the Z direction calcZDirection(); }
trans.setIdentity(); trans.setTranslation(new Vector3d(ytrans)); rotTrans.mul(rotTrans, trans); transInverse.setIdentity(); transInverse.setTranslation(new Vector3d(xtrans)); rotTrans.mul(transInverse, rotTrans);