📄 transform3d.java
字号:
mat[9] = (2.0f*(q1.y*q1.z + q1.w*q1.x))*s; mat[2] = (2.0f*(q1.x*q1.z + q1.w*q1.y))*s; mat[6] = (2.0f*(q1.y*q1.z - q1.w*q1.x))*s; mat[10] = (1.0f - 2.0f*q1.x*q1.x - 2.0f*q1.y*q1.y)*s; mat[3] = t1.x; mat[7] = t1.y; mat[11] = t1.z; mat[12] = 0.0; mat[13] = 0.0; mat[14] = 0.0; mat[15] = 1.0; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; } /** * Sets the value of this matrix from the rotation expressed * by the rotation matrix m1, the translation t1, and the scale s. * The scale is only applied to the * rotational component of the matrix (upper 3x3) and not to the * translational component of the matrix. * @param m1 the rotation matrix * @param t1 the translation * @param s the scale value */ public final void set(Matrix3f m1, Vector3f t1, float s) { mat[0]=m1.m00*s; mat[1]=m1.m01*s; mat[2]=m1.m02*s; mat[3]=t1.x; mat[4]=m1.m10*s; mat[5]=m1.m11*s; mat[6]=m1.m12*s; mat[7]=t1.y; mat[8]=m1.m20*s; mat[9]=m1.m21*s; mat[10]=m1.m22*s; mat[11]=t1.z; mat[12]=0.0; mat[13]=0.0; mat[14]=0.0; mat[15]=1.0; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { // input matrix may not normalize normalize(); } } /** * Sets the value of this matrix from the rotation expressed * by the rotation matrix m1, the translation t1, and the scale s. * The scale is only applied to the * rotational component of the matrix (upper 3x3) and not to the * translational component of the matrix. * @param m1 the rotation matrix * @param t1 the translation * @param s the scale value */ public final void set(Matrix3f m1, Vector3d t1, double s) { mat[0]=m1.m00*s; mat[1]=m1.m01*s; mat[2]=m1.m02*s; mat[3]=t1.x; mat[4]=m1.m10*s; mat[5]=m1.m11*s; mat[6]=m1.m12*s; mat[7]=t1.y; mat[8]=m1.m20*s; mat[9]=m1.m21*s; mat[10]=m1.m22*s; mat[11]=t1.z; mat[12]=0.0; mat[13]=0.0; mat[14]=0.0; mat[15]=1.0; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } } /** * Sets the value of this matrix from the rotation expressed * by the rotation matrix m1, the translation t1, and the scale s. * The scale is only applied to the * rotational component of the matrix (upper 3x3) and not to the * translational component of the matrix. * @param m1 the rotation matrix * @param t1 the translation * @param s the scale value */ public final void set(Matrix3d m1, Vector3d t1, double s) { mat[0]=m1.m00*s; mat[1]=m1.m01*s; mat[2]=m1.m02*s; mat[3]=t1.x; mat[4]=m1.m10*s; mat[5]=m1.m11*s; mat[6]=m1.m12*s; mat[7]=t1.y; mat[8]=m1.m20*s; mat[9]=m1.m21*s; mat[10]=m1.m22*s; mat[11]=t1.z; mat[12]=0.0; mat[13]=0.0; mat[14]=0.0; mat[15]=1.0; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } } /** * 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(); } } /** * Sets the matrix, type, and state of this transform to the matrix, * type, and state of transform t1. * @param t1 the transform to be copied */ public final void set(Transform3D t1){ mat[0] = t1.mat[0]; mat[1] = t1.mat[1]; mat[2] = t1.mat[2]; mat[3] = t1.mat[3]; mat[4] = t1.mat[4]; mat[5] = t1.mat[5]; mat[6] = t1.mat[6]; mat[7] = t1.mat[7]; mat[8] = t1.mat[8]; mat[9] = t1.mat[9]; mat[10] = t1.mat[10]; mat[11] = t1.mat[11]; mat[12] = t1.mat[12]; mat[13] = t1.mat[13]; mat[14] = t1.mat[14]; mat[15] = t1.mat[15]; type = t1.type; // don't copy rot[] and scales[] dirtyBits = t1.dirtyBits | ROTATION_BIT | SCALE_BIT; autoNormalize = t1.autoNormalize; } // This version gets a lock before doing the set. It is used internally synchronized void setWithLock(Transform3D t1) { this.set(t1); } // This version gets a lock before doing the get. It is used internally synchronized void getWithLock(Transform3D t1) { t1.set(this); } /** * 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 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(); } } /** * 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 rotational component (upper 3x3) of this transform to the * matrix values in the single precision Matrix3f argument; the other * elements of this transform are initialized as if this were an identity * matrix (i.e., affine matrix with no translational component). * @param m1 the single precision 3x3 matrix */ public final void set(Matrix3f m1) { mat[0] = m1.m00; mat[1] = m1.m01; mat[2] = m1.m02; mat[3] = 0.0; mat[4] = m1.m10; mat[5] = m1.m11; mat[6] = m1.m12; mat[7] = 0.0; mat[8] = m1.m20; mat[9] = m1.m21; mat[10] = m1.m22; mat[11] = 0.0; mat[12] = 0.0; mat[13] = 0.0; mat[14] = 0.0; mat[15] = 1.0; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } } /** * Sets the rotational component (upper 3x3) of this transform to the * matrix values in the double precision Matrix3d argument; the other * elements of this transform are initialized as if this were an identity * matrix (ie, affine matrix with no translational component). * @param m1 the double precision 3x3 matrix */ public final void set(Matrix3d m1) { mat[0] = m1.m00; mat[1] = m1.m01; mat[2] = m1.m02; mat[3] = 0.0; mat[4] = m1.m10; mat[5] = m1.m11; mat[6] = m1.m12; mat[7] = 0.0; mat[8] = m1.m20; mat[9] = m1.m21; mat[10] = m1.m22; mat[11] = 0.0; mat[12] = 0.0; mat[13] = 0.0; mat[14] = 0.0; mat[15] = 1.0; // Issue 253: set all dirty bits dirtyBits = ALL_DIRTY; if (autoNormalize) { normalize(); } } /** * Sets the rotational component (upper 3x3) of this transform to the * rotation matrix converted from the Euler angles provided; the other * non-rotational elements are set as if this were an identity matrix. * The euler parameter is a Vector3d consisting of three rotation angles * applied first about the X, then Y then Z axis. * These rotations are applied using a static frame of reference. In * other words, the orientation of the Y rotation axis is not affected * by the X rotation and the orientation of the Z rotation axis is not * affected by the X or Y rotation. * @param euler the Vector3d consisting of three rotation angles about X,Y,Z * */ public final void setEuler(Vector3d euler) { double sina, sinb, sinc; double cosa, cosb, cosc; sina = Math.sin(euler.x); sinb = Math.sin(euler.y); sinc = Math.sin(euler.z); cosa = Math.cos(euler.x); cosb = Math.cos(euler.y); cosc = Math.cos(euler.z); mat[0] = cosb * cosc; mat[1] = -(cosa * sinc) + (sina * sinb * cosc); mat[2] = (sina * sinc) + (cosa * sinb *cosc); mat[3] = 0.0; mat[4] = cosb * sinc; mat[5] = (cosa * cosc) + (sina * sinb * sinc); mat[6] = -(sina * cosc) + (cosa * sinb *sinc); mat[7] = 0.0; mat[8] = -sinb; mat[9] = sina * cosb; mat[10] = cosa * cosb; mat[11] = 0.0; mat[12] = 0.0; mat[13] = 0.0; mat[14] = 0.0; mat[15] = 1.0; // Issue 253: set all dirty bits if input is infinity or NaN if (isInfOrNaN(euler)) { dirtyBits = ALL_DIRTY; return; } type = AFFINE | CONGRUENT | RIGID | ORTHO; dirtyBits = CLASSIFY_BIT | SCALE_BIT | ROTATION_BIT; } /** * Places the values of this transform into the double precision ar
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -