/** * 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; }
/** * 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]; }
/** * Performs an SVD normalization of this matrix in order to acquire * the normalized rotational component; the values are placed into * the Matrix3f parameter. * @param m1 the matrix into which the rotational component is placed */ public final void get(Matrix3f m1) { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m1.m00 = (float)tmp_rot[0]; m1.m01 = (float)tmp_rot[1]; m1.m02 = (float)tmp_rot[2]; m1.m10 = (float)tmp_rot[3]; m1.m11 = (float)tmp_rot[4]; m1.m12 = (float)tmp_rot[5]; m1.m20 = (float)tmp_rot[6]; m1.m21 = (float)tmp_rot[7]; m1.m22 = (float)tmp_rot[8]; }
/** * Sets the rotational component (upper 3x3) of this matrix to the * matrix equivalent values of the quaternion argument; the other * elements of this matrix are unchanged; a singular value * decomposition is performed on this object's upper 3x3 matrix to * factor out the scale, then this object's upper 3x3 matrix components * are replaced by the matrix equivalent of the quaternion, * and then the scale is reapplied to the rotational components. * @param q1 the quaternion that specifies the rotation */ public final void setRotation(Quat4f q1){ double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m00 = (1.0 - 2.0f*q1.y*q1.y - 2.0f*q1.z*q1.z)*tmp_scale[0]; m10 = (2.0*(q1.x*q1.y + q1.w*q1.z))*tmp_scale[0]; m20 = (2.0*(q1.x*q1.z - q1.w*q1.y))*tmp_scale[0]; m01 = (2.0*(q1.x*q1.y - q1.w*q1.z))*tmp_scale[1]; m11 = (1.0 - 2.0f*q1.x*q1.x - 2.0f*q1.z*q1.z)*tmp_scale[1]; m21 = (2.0*(q1.y*q1.z + q1.w*q1.x))*tmp_scale[1]; m02 = (2.0*(q1.x*q1.z + q1.w*q1.y))*tmp_scale[2]; m12 = (2.0*(q1.y*q1.z - q1.w*q1.x))*tmp_scale[2]; m22 = (1.0 - 2.0f*q1.x*q1.x - 2.0f*q1.y*q1.y)*tmp_scale[2]; }
/** * Sets the rotational component (upper 3x3) of this matrix to the * matrix values in the double precision Matrix3d argument; the other * elements of this matrix are unchanged; a singular value * decomposition is performed on this object's upper 3x3 matrix to * factor out the scale, then this object's upper 3x3 matrix components * are replaced by the passed rotation components, * and then the scale is reapplied to the rotational components. * @param m1 double precision 3x3 matrix */ public final void setRotation( Matrix3d m1){ double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m00 = m1.m00*tmp_scale[0]; m01 = m1.m01*tmp_scale[1]; m02 = m1.m02*tmp_scale[2]; m10 = m1.m10*tmp_scale[0]; m11 = m1.m11*tmp_scale[1]; m12 = m1.m12*tmp_scale[2]; m20 = m1.m20*tmp_scale[0]; m21 = m1.m21*tmp_scale[1]; m22 = m1.m22*tmp_scale[2]; }
/** * Sets the rotational component (upper 3x3) of this matrix to the * matrix equivalent values of the quaternion argument; the other * elements of this matrix are unchanged; a singular value * decomposition is performed on this object's upper 3x3 matrix to * factor out the scale, then this object's upper 3x3 matrix components * are replaced by the matrix equivalent of the quaternion, * and then the scale is reapplied to the rotational components. * @param q1 the quaternion that specifies the rotation */ public final void setRotation(Quat4d q1){ double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m00 = (1.0 - 2.0f*q1.y*q1.y - 2.0f*q1.z*q1.z)*tmp_scale[0]; m10 = (2.0*(q1.x*q1.y + q1.w*q1.z))*tmp_scale[0]; m20 = (2.0*(q1.x*q1.z - q1.w*q1.y))*tmp_scale[0]; m01 = (2.0*(q1.x*q1.y - q1.w*q1.z))*tmp_scale[1]; m11 = (1.0 - 2.0f*q1.x*q1.x - 2.0f*q1.z*q1.z)*tmp_scale[1]; m21 = (2.0*(q1.y*q1.z + q1.w*q1.x))*tmp_scale[1]; m02 = (2.0*(q1.x*q1.z + q1.w*q1.y))*tmp_scale[2]; m12 = (2.0*(q1.y*q1.z - q1.w*q1.x))*tmp_scale[2]; m22 = (1.0 - 2.0f*q1.x*q1.x - 2.0f*q1.y*q1.y)*tmp_scale[2]; }
/** * Sets the rotational component (upper 3x3) of this matrix to the * matrix values in the single precision Matrix3f argument; the other * elements of this matrix are unchanged; a singular value * decomposition is performed on this object's upper 3x3 matrix to * factor out the scale, then this object's upper 3x3 matrix components * are replaced by the passed rotation components, * and then the scale is reapplied to the rotational components. * @param m1 single precision 3x3 matrix */ public final void setRotation( Matrix3f m1) { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m00 = m1.m00*tmp_scale[0]; m01 = m1.m01*tmp_scale[1]; m02 = m1.m02*tmp_scale[2]; m10 = m1.m10*tmp_scale[0]; m11 = m1.m11*tmp_scale[1]; m12 = m1.m12*tmp_scale[2]; m20 = m1.m20*tmp_scale[0]; m21 = m1.m21*tmp_scale[1]; m22 = m1.m22*tmp_scale[2]; }
/** * Performs an SVD normalization of this matrix to calculate * and return the uniform scale factor. If the matrix has non-uniform * scale factors, the largest of the x, y, and z scale factors will * be returned. This matrix is not modified. * @return the scale factor of this matrix */ public final double getScale() { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); return( Matrix3d.max3( tmp_scale )); }
double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot );
double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot );
getScaleRotate( tmp_scale, tmp_rot );
/** * Performs an SVD normalization of this matrix to calculate * the rotation as a 3x3 matrix, the translation, and the scale. * None of the matrix values are modified. * @param m1 the normalized matrix representing the rotation * @param t1 the translation component * @return the scale component of this transform */ public final double get(Matrix3f m1, Vector3d t1){ double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); m1.m00 = (float)tmp_rot[0]; m1.m01 = (float)tmp_rot[1]; m1.m02 = (float)tmp_rot[2]; m1.m10 = (float)tmp_rot[3]; m1.m11 = (float)tmp_rot[4]; m1.m12 = (float)tmp_rot[5]; m1.m20 = (float)tmp_rot[6]; m1.m21 = (float)tmp_rot[7]; m1.m22 = (float)tmp_rot[8]; t1.x = m03; t1.y = m13; t1.z = m23; return( Matrix3d.max3( tmp_scale )); }
/** * Performs an SVD normalization of this matrix to calculate * the rotation as a 3x3 matrix, the translation, and the scale. * None of the matrix values are modified. * @param m1 the normalized matrix representing the rotation * @param t1 the translation component * @return the scale component of this transform */ public final double get(Matrix3d m1, Vector3d t1) { 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]; t1.x = m03; t1.y = m13; t1.z = m23; return( Matrix3d.max3( tmp_scale )); }