⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transform3d.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
           mat[7] =  t1.mat[13];           mat[8] =  t1.mat[2];           mat[9] =  t1.mat[6];           mat[10] = t1.mat[10];           mat[11] = t1.mat[14];           mat[12] = t1.mat[3];           mat[13] = t1.mat[7];           mat[14] = t1.mat[11];           mat[15] = t1.mat[15];	   dirtyBits = ALL_DIRTY;	   if (autoNormalize) {	       normalize();	   }       } else {           this.transpose();       }    }   /**     * Sets the value of this transform to the matrix conversion of the     * single precision quaternion argument; the non-rotational     * components are set as if this were an identity matrix.     * @param q1  the quaternion to be converted     */    public final void set(Quat4f q1) {        mat[0] = (1.0f - 2.0f*q1.y*q1.y - 2.0f*q1.z*q1.z);        mat[4] = (2.0f*(q1.x*q1.y + q1.w*q1.z));        mat[8] = (2.0f*(q1.x*q1.z - q1.w*q1.y));        mat[1] = (2.0f*(q1.x*q1.y - q1.w*q1.z));        mat[5] = (1.0f - 2.0f*q1.x*q1.x - 2.0f*q1.z*q1.z);        mat[9] = (2.0f*(q1.y*q1.z + q1.w*q1.x));        mat[2] = (2.0f*(q1.x*q1.z + q1.w*q1.y));        mat[6] = (2.0f*(q1.y*q1.z - q1.w*q1.x));        mat[10] = (1.0f - 2.0f*q1.x*q1.x - 2.0f*q1.y*q1.y);        mat[3] =  0.0;        mat[7] =  0.0;        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(q1)) {            dirtyBits = ALL_DIRTY;            return;        }	dirtyBits = CLASSIFY_BIT | SCALE_BIT | ROTATION_BIT;	type = RIGID | CONGRUENT | AFFINE | ORTHO;    }   /**     * Sets the value of this transform to the matrix conversion of the     * double precision quaternion argument; the non-rotational     * components are set as if this were an identity matrix.     * @param q1  the quaternion to be converted     */    public final void set(Quat4d q1) {        mat[0] = (1.0 - 2.0*q1.y*q1.y - 2.0*q1.z*q1.z);        mat[4] = (2.0*(q1.x*q1.y + q1.w*q1.z));        mat[8] = (2.0*(q1.x*q1.z - q1.w*q1.y));        mat[1] = (2.0*(q1.x*q1.y - q1.w*q1.z));        mat[5] = (1.0 - 2.0*q1.x*q1.x - 2.0*q1.z*q1.z);        mat[9] = (2.0*(q1.y*q1.z + q1.w*q1.x));        mat[2] = (2.0*(q1.x*q1.z + q1.w*q1.y));        mat[6] = (2.0*(q1.y*q1.z - q1.w*q1.x));        mat[10] = (1.0 - 2.0*q1.x*q1.x - 2.0*q1.y*q1.y);        mat[3] =  0.0;        mat[7] =  0.0;        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(q1)) {            dirtyBits = ALL_DIRTY;            return;        }	dirtyBits = CLASSIFY_BIT | SCALE_BIT | ROTATION_BIT;	type = RIGID | CONGRUENT | AFFINE | ORTHO;    }   /**     * 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 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 double precision 3x3 matrix     */   public final void setRotation(Matrix3d 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) {	    // the matrix pass in may not normalize	    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();	}     }    /**     * Sets the rotational component (upper 3x3) of this transform to the     * matrix equivalent values of the quaternion argument; the other     * elements of this transform are unchanged; any pre-existing scale     * in the transform is preserved.     * @param q1    the quaternion that specifies the rotation    */    public final void setRotation(Quat4f q1) {	if ((dirtyBits & SCALE_BIT)!= 0) {	    computeScales(false);	}        mat[0] = (1.0 - 2.0*q1.y*q1.y - 2.0*q1.z*q1.z)*scales[0];        mat[4] = (2.0*(q1.x*q1.y + q1.w*q1.z))*scales[0];        mat[8] = (2.0*(q1.x*q1.z - q1.w*q1.y))*scales[0];        mat[1] = (2.0*(q1.x*q1.y - q1.w*q1.z))*scales[1];        mat[5] = (1.0 - 2.0*q1.x*q1.x - 2.0*q1.z*q1.z)*scales[1];        mat[9] = (2.0*(q1.y * q1.z + q1.w * q1.x))*scales[1];        mat[2] = (2.0*(q1.x*q1.z + q1.w*q1.y))*scales[2];        mat[6] = (2.0*(q1.y*q1.z - q1.w*q1.x))*scales[2];        mat[10] = (1.0 - 2.0*q1.x*q1.x - 2.0*q1.y*q1.y)*scales[2];        // Issue 253: set all dirty bits if input is infinity or NaN        if (isInfOrNaN(q1)) {            dirtyBits = ALL_DIRTY;            return;        }        dirtyBits |= CLASSIFY_BIT | ROTATION_BIT;	dirtyBits &= ~ORTHO_BIT;	type |= ORTHO;	type &= ~(ORTHOGONAL|IDENTITY|SCALE|TRANSLATION|SCALE|ZERO);      }    /**     * Sets the rotational component (upper 3x3) of this transform to the     * matrix equivalent values of the quaternion argument; the other     * elements of this transform are unchanged; any pre-existing scale     * in the transform is preserved.     * @param q1    the quaternion that specifies the rotation     */     public final void setRotation(Quat4d q1) {	 if ((dirtyBits & SCALE_BIT)!= 0) {	     computeScales(false);	 }	 mat[0] = (1.0 - 2.0*q1.y*q1.y - 2.0*q1.z*q1.z)*scales[0];	 mat[4] = (2.0*(q1.x*q1.y + q1.w*q1.z))*scales[0];	 mat[8] = (2.0*(q1.x*q1.z - q1.w*q1.y))*scales[0];	 mat[1] = (2.0*(q1.x*q1.y - q1.w*q1.z))*scales[1];	 mat[5] = (1.0 - 2.0*q1.x*q1.x - 2.0*q1.z*q1.z)*scales[1];	 mat[9] = (2.0*(q1.y * q1.z + q1.w * q1.x))*scales[1];	 mat[2] = (2.0*(q1.x*q1.z + q1.w*q1.y))*scales[2];	 mat[6] = (2.0*(q1.y*q1.z - q1.w*q1.x))*scales[2];	 mat[10] = (1.0 - 2.0*q1.x*q1.x - 2.0*q1.y*q1.y)*scales[2];         // Issue 253: set all dirty bits if input is infinity or NaN         if (isInfOrNaN(q1)) {             dirtyBits = ALL_DIRTY;             return;         }         dirtyBits |= CLASSIFY_BIT | ROTATION_BIT;         dirtyBits &= ~ORTHO_BIT;         type |= ORTHO;         type &= ~(ORTHOGONAL|IDENTITY|SCALE|TRANSLATION|SCALE|ZERO);      }    /**     * Sets the value of this transform to the matrix conversion     * of the single precision axis-angle argument; all of the matrix     * values are modified.     * @param a1 the axis-angle to be converted (x, y, z, angle)     */    public final void set(AxisAngle4f a1) {	double mag = Math.sqrt( a1.x*a1.x + a1.y*a1.y + a1.z*a1.z);	if (almostZero(mag)) {	    setIdentity();	} else {	    mag = 1.0/mag;	    double ax = a1.x*mag;	    double ay = a1.y*mag;	    double az = a1.z*mag;	    double sinTheta = Math.sin((double)a1.angle);	    double cosTheta = Math.cos((double)a1.angle);	    double t = 1.0 - cosTheta;	    double xz = ax * az;	    double xy = ax * ay;	    double yz = ay * az;	    mat[0] = t * ax * ax + cosTheta;	    mat[1] = t * xy - sinTheta * az;	    mat[2] = t * xz + sinTheta * ay;	    mat[3] = 0.0;	    mat[4] = t * xy + sinTheta * az;	    mat[5] = t * ay * ay + cosTheta;	    mat[6] = t * yz - sinTheta * ax;	    mat[7] = 0.0;	    mat[8] = t * xz - sinTheta * ay;	    mat[9] = t * yz + sinTheta * ax;	    mat[10] = t * az * az + cosTheta;	    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(a1)) {                dirtyBits = ALL_DIRTY;                return;            }            type = CONGRUENT | AFFINE | RIGID | ORTHO;	    dirtyBits = CLASSIFY_BIT | ROTATION_BIT | SCALE_BIT;	}    }    /**     * Sets the value of this transform to the matrix conversion     * of the double precision axis-angle argument; all of the matrix     * values are modified.     * @param a1 the axis-angle to be converted (x, y, z, angle)     */    public final void set(AxisAngle4d a1) {	double mag = Math.sqrt( a1.x*a1.x + a1.y*a1.y + a1.z*a1.z);	if (almostZero(mag)) {	    setIdentity();	} else {	    mag = 1.0/mag;	    double ax = a1.x*mag;	    double ay = a1.y*mag;	    double az = a1.z*mag;	    double sinTheta = Math.sin(a1.angle);	    double cosTheta = Math.cos(a1.angle);	    double t = 1.0 - cosTheta;	    double xz = ax * az;	    double xy = ax * ay;	    double yz = ay * az;	    mat[0] = t * ax * ax + cosTheta;	    mat[1] = t * xy - sinTheta * az;	    mat[2] = t * xz + sinTheta * ay;	    mat[3] = 0.0;	    mat[4] = t * xy + sinTheta * az;	    mat[5] = t * ay * ay + cosTheta;	    mat[6] = t * yz - sinTheta * ax;	    mat[7] = 0.0;	    mat[8] = t * xz - sinTheta * ay;	    mat[9] = t * yz + sinTheta * ax;	    mat[10] = t * az * az + cosTheta;	    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(a1)) {                dirtyBits = ALL_DIRTY;                return;            }	    type = CONGRUENT | AFFINE | RIGID | ORTHO;	    dirtyBits = CLASSIFY_BIT | ROTATION_BIT | SCALE_BIT;	}    }   /**     * Sets the rotational component (upper 3x3) of this transform to the     * matrix equivalent values of the axis-angle argument; the other     * elements of this transform are unchanged; any pre-existing scale     * in the transform is preserved.     * @param a1 the axis-angle to be converted (x, y, z, angle)     */    public final void setRotation(AxisAngle4d a1) {	if ((dirtyBits & SCALE_BIT)!= 0) {	    computeScales(false);	}	double mag = Math.sqrt( a1.x*a1.x + a1.y*a1.y + a1.z*a1.z);	if (almostZero(mag)) {	    mat[0] = scales[0];	    mat[1] = 0.0;	    mat[2] = 0.0;	    mat[4] = 0.0;	    mat[5] = scales[1];	    mat[6] = 0.0;	    mat[8] = 0.0;	    mat[9] = 0.0;	    mat[10] = scales[2];	} else {	    mag = 1.0/mag;	    double ax = a1.x*mag;	    double ay = a1.y*mag;	    double az = a1.z*mag;	    double sinTheta = Math.sin(a1.angle);	    double cosTheta = Math.cos(a1.angle);	    double t = 1.0 - cosTheta;	    double xz = ax * az;	    double xy = ax * ay;	    double yz = ay * az;	    mat[0] = (t * ax * ax + cosTheta)*scales[0];	    mat[1] = (t * xy - sinTheta * az)*scales[1];	    mat[2] = (t * xz + sinTheta * ay)*scales[2];	    mat[4] = (t * xy + sinTheta * az)*scales[0];	    mat[5] = (t * ay * ay + cosTheta)*scales[1];	    mat[6] = (t * yz - sinTheta * ax)*scales[2];	    mat[8] = (t * xz - sinTheta * ay)*scales[0];	    mat[9] = (t * yz + sinTheta * ax)*scales[1];	    mat[10] = (t * az * az + cosTheta)*scales[2];	}        // Issue 253: set all dirty bits if input is infinity or NaN        if (isInfOrNaN(a1)) {            dirtyBits = ALL_DIRTY;            return;        }	// Rigid remain rigid, congruent remain congruent after	// set rotation	dirtyBits |= CLASSIFY_BIT | ROTATION_BIT;	dirtyBits &= ~ORTHO_BIT;	type |= ORTHO;	type &= ~(ORTHOGONAL|IDENTITY|SCALE|TRANSLATION|SCALE|ZERO);    }   /**     * Sets the rotational component (upper 3x3) of this transform to the     * matrix equivalent values of the axis-angle argument; the other     * elements of this transform are unchanged; any pre-existing scale     * in the transform is preserved.     * @param a1 the axis-angle to be converted (x, y, z, angle)     */    public final void setRotation(AxisAngle4f a1)  {	if ((dirtyBits & SCALE_BIT)!= 0) {	    computeScales(false);	}	double mag = Math.sqrt( a1.x*a1.x + a1.y*a1.y + a1.z*a1.z);	if (almostZero(mag)) {	    mat[0] = scales[0];	    mat[1] = 0.0;	    mat[2] = 0.0;	    mat[4] = 0.0;	    mat[5] = scales[1];	    mat[6] = 0.0;	    mat[8] = 0.0;	    mat[9] = 0.0;	    mat[10] = scales[2];	} else {	    mag = 1.0/mag;	    double ax = a1.x*mag;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -