/** * Adds transforms t1 and t2 and places the result into this transform. * @param t1 the transform to be added * @param t2 the transform to be added */ public final void add(Transform3D t1, Transform3D t2) { for (int i=0 ; i<16 ; i++) { mat[i] = t1.mat[i] + t2.mat[i]; } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Subtracts transform t1 from this transform and places the result * into this: this = this - t1. * @param t1 the transform to be subtracted from this transform */ public final void sub(Transform3D t1) { for (int i=0 ; i<16 ; i++) { mat[i] -= t1.mat[i]; } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Adds this transform to transform t1 and places the result into * this: this = this + t1. * @param t1 the transform to be added to this transform */ public final void add(Transform3D t1) { for (int i=0 ; i<16 ; i++) { mat[i] += t1.mat[i]; } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Subtracts transform t2 from transform t1 and places the result into * this: this = t1 - t2. * @param t1 the left transform * @param t2 the right transform */ public final void sub(Transform3D t1, Transform3D t2) { for (int i=0 ; i<16 ; i++) { mat[i] = t1.mat[i] - t2.mat[i]; } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Scales this transform by a Uniform scale matrix with scale factor * s and then adds transform t1 (this = S*this + t1). * @param s the scale factor * @param t1 the transform to be added */ public final void scaleAdd(double s, Transform3D t1) { for (int i=0 ; i<16 ; i++) { mat[i] = s*mat[i] + t1.mat[i]; } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Multiplies each element of transform t1 by a scalar and places * the result into this. Transform t1 is not modified. * @param scalar the scalar multiplier * @param t1 the original transform */ public final void mul(double scalar, Transform3D t1) { for (int i=0 ; i<16 ; i++) { mat[i] = t1.mat[i] * scalar; } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Replaces the upper 3x3 matrix values of this transform with the * values in the matrix m1. * @param m1 the matrix that will be the new upper 3x3 */ public final void setRotationScale(Matrix3f m1) { mat[0] = m1.m00; mat[1] = m1.m01; mat[2] = m1.m02; mat[4] = m1.m10; mat[5] = m1.m11; mat[6] = m1.m12; mat[8] = m1.m20; mat[9] = m1.m21; mat[10] = m1.m22; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Replaces the upper 3x3 matrix values of this transform with the * values in the matrix m1. * @param m1 the matrix that will be the new upper 3x3 */ public final void setRotationScale(Matrix3d m1) { mat[0] = m1.m00; mat[1] = m1.m01; mat[2] = m1.m02; mat[4] = m1.m10; mat[5] = m1.m11; mat[6] = m1.m12; mat[8] = m1.m20; mat[9] = m1.m21; mat[10] = m1.m22; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Scales transform t1 by a Uniform scale matrix with scale * factor s and then adds transform t2 (this = S*t1 + t2). * @param s the scale factor * @param t1 the transform to be scaled * @param t2 the transform to be added */ public final void scaleAdd(double s, Transform3D t1, Transform3D t2) { for (int i=0 ; i<16 ; i++) { mat[i] = s*t1.mat[i] + t2.mat[i]; } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Sets a flag that enables or disables automatic SVD * normalization. If this flag is enabled, an automatic SVD * normalization of the rotational components (upper 3x3) of this * matrix is done after every subsequent matrix operation that * modifies this matrix. This is functionally equivalent to * calling normalize() after every subsequent call, but may be * less computationally expensive. * The default value for this parameter is false. * @param autoNormalize the boolean state of auto normalization */ public final void setAutoNormalize(boolean autoNormalize) { this.autoNormalize = autoNormalize; if (autoNormalize) { normalize(); } }
/** * Sets the matrix values of this transform to the matrix values in the * double precision array parameter. The matrix type is classified * internally by the Transform3D class. * @param matrix the double precision array of length 16 in row major format */ public final void set(double[] matrix) { mat[0] = matrix[0]; mat[1] = matrix[1]; mat[2] = matrix[2]; mat[3] = matrix[3]; mat[4] = matrix[4]; mat[5] = matrix[5]; mat[6] = matrix[6]; mat[7] = matrix[7]; mat[8] = matrix[8]; mat[9] = matrix[9]; mat[10] = matrix[10]; mat[11] = matrix[11]; mat[12] = matrix[12]; mat[13] = matrix[13]; mat[14] = matrix[14]; mat[15] = matrix[15]; dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Sets the matrix values of this transform to the matrix values in the * single precision Matrix4f argument. The transform type is classified * internally by the Transform3D class. * @param m1 the single precision 4x4 matrix */ public final void set(Matrix4f m1) { mat[0] = m1.m00; mat[1] = m1.m01; mat[2] = m1.m02; mat[3] = m1.m03; mat[4] = m1.m10; mat[5] = m1.m11; mat[6] = m1.m12; mat[7] = m1.m13; mat[8] = m1.m20; mat[9] = m1.m21; mat[10] = m1.m22; mat[11] = m1.m23; mat[12] = m1.m30; mat[13] = m1.m31; mat[14] = m1.m32; mat[15] = m1.m33; dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Sets the matrix values of this transform to the matrix values in the * single precision array parameter. The matrix type is classified * internally by the Transform3D class. * @param matrix the single precision array of length 16 in row major format */ public final void set(float[] matrix) { mat[0] = matrix[0]; mat[1] = matrix[1]; mat[2] = matrix[2]; mat[3] = matrix[3]; mat[4] = matrix[4]; mat[5] = matrix[5]; mat[6] = matrix[6]; mat[7] = matrix[7]; mat[8] = matrix[8]; mat[9] = matrix[9]; mat[10] = matrix[10]; mat[11] = matrix[11]; mat[12] = matrix[12]; mat[13] = matrix[13]; mat[14] = matrix[14]; mat[15] = matrix[15]; dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Sets the matrix values of this transform to the matrix values in the * double precision Matrix4d argument. The transform type is classified * internally by the Transform3D class. * @param m1 the double precision 4x4 matrix */ public final void set(Matrix4d m1) { mat[0] = m1.m00; mat[1] = m1.m01; mat[2] = m1.m02; mat[3] = m1.m03; mat[4] = m1.m10; mat[5] = m1.m11; mat[6] = m1.m12; mat[7] = m1.m13; mat[8] = m1.m20; mat[9] = m1.m21; mat[10] = m1.m22; mat[11] = m1.m23; mat[12] = m1.m30; mat[13] = m1.m31; mat[14] = m1.m32; mat[15] = m1.m33; dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Transposes this matrix in place. */ public final void transpose() { double temp; temp = mat[4]; mat[4] = mat[1]; mat[1] = temp; temp = mat[8]; mat[8] = mat[2]; mat[2] = temp; temp = mat[12]; mat[12] = mat[3]; mat[3] = temp; temp = mat[9]; mat[9] = mat[6]; mat[6] = temp; temp = mat[13]; mat[13] = mat[7]; mat[7] = temp; temp = mat[14]; mat[14] = mat[11]; mat[11] = temp; dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
/** * Normalizes the rotational components (upper 3x3) of transform t1 * using a Singular Value Decomposition (SVD), and places the result * into this transform. * This operation ensures that the column vectors of this matrix * are orthogonal to each other. The primary use of this method * is to correct for floating point errors that accumulate over * time when concatenating a large number of rotation matrices. * Note that the scale of the matrix is not altered by this method. * * @param t1 the source transform, which is not modified */ public final void normalize(Transform3D t1){ set(t1); normalize(); }
/** * Sets the rotational component (upper 3x3) of this transform to the * matrix values in the single precision Matrix3f argument; the other * elements of this transform are unchanged; any pre-existing scale * will be preserved; the argument matrix m1 will be checked for proper * normalization when this transform is internally classified. * @param m1 the single precision 3x3 matrix */ public final void setRotation(Matrix3f m1) { if ((dirtyBits & SCALE_BIT)!= 0) { computeScales(false); } mat[0] = m1.m00*scales[0]; mat[1] = m1.m01*scales[1]; mat[2] = m1.m02*scales[2]; mat[4] = m1.m10*scales[0]; mat[5] = m1.m11*scales[1]; mat[6] = m1.m12*scales[2]; mat[8] = m1.m20*scales[0]; mat[9] = m1.m21*scales[1]; mat[10]= m1.m22*scales[2]; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }
@Override protected void endAction(Sensor s) { super.endAction(s) ; viewPlatformToVworld.normalize() ; targetTG.setTransform(viewPlatformToVworld) ; if (rotationCoords == HEAD) { view.setUserHeadToVworldEnable(false) ; } }
@Override protected void endAction(Sensor s) { super.endAction(s) ; viewPlatformToVworld.normalize() ; targetTG.setTransform(viewPlatformToVworld) ; if (rotationCoords == HEAD) { view.setUserHeadToVworldEnable(false) ; } if (s != null && readAction6D == ECHO) { eventAgent.addSensorReadListener(s, echoReadListener6D) ; } }
/** * Sets the matrix values of this transform to the matrix values in the * upper 4x4 corner of the GMatrix parameter. If the parameter matrix is * smaller than 4x4, the remaining elements in the transform matrix are * assigned to zero. The transform matrix type is classified * internally by the Transform3D class. * @param matrix the general matrix from which the Transform3D matrix is derived */ public final void set(GMatrix matrix) { int i,j, k; int numRows = matrix.getNumRow(); int numCol = matrix.getNumCol(); for(i=0 ; i<4 ; i++) { k = i*4; for(j=0 ; j<4 ; j++) { if(i>=numRows || j>=numCol) mat[k+j] = 0.0; else mat[k+j] = matrix.getElement(i,j); } } dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } }