public Matrix4d readMatrix4d( DataInput in ) throws IOException { double elements[] = new double[16]; for(int c=0; c<16; c++) elements[ c ] = in.readDouble(); return new Matrix4d(elements); }
/** * Sets the given matrix to contain the orientation for this keyframe */ void setRotationMatrix(Matrix4d mat) { debugOutputLn(TRACE, "setRotMat()"); debugOutputLn(VALUES, " p, h, b = " + pitch + ", " + heading + ", " + bank); Matrix4d pitchMat = new Matrix4d(); pitchMat.rotX(-pitch); Matrix4d bankMat = new Matrix4d(); bankMat.rotZ(bank); mat.rotY(-heading); mat.mul(pitchMat); mat.mul(bankMat); debugOutputLn(VALUES, "setRotMat(), mat = " + mat); }
/** * @deprecated Use epsilonEquals(Matrix4d,double) instead */ public boolean epsilonEquals(Matrix4d m1, float epsilon) { return epsilonEquals(m1, (double)epsilon); }
/** * Sets the given matrix to contain the position, orientation, and * scale values for the keyframe */ void setMatrix(Matrix4d mat) { setRotationMatrix(mat); mat.setTranslation(new Vector3d(x, y, z)); Matrix4d m = new Matrix4d(); m.setColumn(0, xScale, 0, 0, 0); // setScale not yet implemented m.setColumn(1, 0, yScale, 0, 0); m.setColumn(2, 0, 0, zScale, 0); m.setColumn(3, 0, 0, 0, 1); mat.mul(m); }
pitchMat.setIdentity(); pitchMat.rotX(-iPitch); bankMat.setIdentity(); bankMat.rotZ(iBank); tMat.setIdentity(); tMat.rotY(-iHeading); tMat.mul(pitchMat); tMat.mul(bankMat); sMat.set((double)iScale.x); tMat.mul(sMat);
/** * Processes the built-in command (Translate x y z). * * @param elements ArrayList containing Doubles wrapping x, y, and z * translation components at indices 1, 2, and 3 respectively * * @return matrix that translates by the given x, y, and z components */ private Matrix4d makeTranslate(ArrayList elements) { if (elements.size() != 4) { throw new IllegalArgumentException ("Incorrect number of arguments to Translate") ; } if (!(elements.get(1) instanceof Double) || !(elements.get(2) instanceof Double) || !(elements.get(3) instanceof Double)) { throw new IllegalArgumentException ("All arguments to Translate must be numbers") ; } Matrix4d m4d = new Matrix4d() ; m4d.set(new Vector3d(((Double)elements.get(1)).doubleValue(), ((Double)elements.get(2)).doubleValue(), ((Double)elements.get(3)).doubleValue())) ; return m4d ; }
Matrix4d mat = new Matrix4d(); mat.setIdentity();
Matrix4d mat = new Matrix4d(); mat.setIdentity(); debugOutputLn(VALUES, " Camera Matrix = \n" + mat); Transform3D t1 = new Transform3D(); Matrix4d m = new Matrix4d(); double scale = .1; m.setColumn(0, scale, 0, 0, 0); // setScale not yet implemented m.setColumn(1, 0, scale, 0, 0); m.setColumn(2, 0, 0, scale, 0); m.setColumn(3, 0, 0, 0, 1); Transform3D scaleTrans = new Transform3D(m); TransformGroup scaleGroup = new TransformGroup(scaleTrans);
/** * Sets the scale component of the current matrix by factoring * out the current scale (by doing an SVD) from the rotational * component and multiplying by the new scale. * @param scale the new scale amount */ public final void setScale(double scale) { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m00 = tmp_rot[0]*scale; m01 = tmp_rot[1]*scale; m02 = tmp_rot[2]*scale; m10 = tmp_rot[3]*scale; m11 = tmp_rot[4]*scale; m12 = tmp_rot[5]*scale; m20 = tmp_rot[6]*scale; m21 = tmp_rot[7]*scale; m22 = tmp_rot[8]*scale; }
tMat.set(tQuat);
int i; for (i = 0; i < frustumPoints.length; i++) { tMatrix.transform(frustumPoints[i]); double w_inv = 1.0 / frustumPoints[i].w; frustumPoints[i].x *= w_inv;
/** * Sets the value of this matrix to the matrix inverse * of the passed (user declared) matrix m1. * @param m1 the matrix to be inverted */ public final void invert(Matrix4d m1) { invertGeneral( m1); }
m1.get(m3d);
public void writeMatrix4d( DataOutput out, Matrix4d m ) throws IOException { for(int r=0; r<4; r++) for(int c=0; c<4; c++) out.writeDouble( m.getElement( r, c )); }
Matrix4d mat = new Matrix4d(); mat.setIdentity();
/** * Performs an SVD normalization of this matrix in order to acquire * the normalized rotational component; the values are placed into * the Matrix3d parameter. * @param m1 the matrix into which the rotational component is placed */ public final void get(Matrix3d m1) { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m1.m00 = tmp_rot[0]; m1.m01 = tmp_rot[1]; m1.m02 = tmp_rot[2]; m1.m10 = tmp_rot[3]; m1.m11 = tmp_rot[4]; m1.m12 = tmp_rot[5]; m1.m20 = tmp_rot[6]; m1.m21 = tmp_rot[7]; m1.m22 = tmp_rot[8]; }
tMat.set(iQuat);