/** * Performs singular value decomposition normalization of this matrix. */ public final void normalize(){ double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); this.m00 = (float)tmp_rot[0]; this.m01 = (float)tmp_rot[1]; this.m02 = (float)tmp_rot[2]; this.m10 = (float)tmp_rot[3]; this.m11 = (float)tmp_rot[4]; this.m12 = (float)tmp_rot[5]; this.m20 = (float)tmp_rot[6]; this.m21 = (float)tmp_rot[7]; this.m22 = (float)tmp_rot[8]; }
/** * Sets the scale component of the current matrix by factoring * out the current scale (by doing an SVD) and multiplying by * the new scale. * @param scale the new scale amount */ public final void setScale(float scale) { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate( tmp_scale, tmp_rot ); this.m00 = (float)(tmp_rot[0] * scale); this.m01 = (float)(tmp_rot[1] * scale); this.m02 = (float)(tmp_rot[2] * scale); this.m10 = (float)(tmp_rot[3] * scale); this.m11 = (float)(tmp_rot[4] * scale); this.m12 = (float)(tmp_rot[5] * scale); this.m20 = (float)(tmp_rot[6] * scale); this.m21 = (float)(tmp_rot[7] * scale); this.m22 = (float)(tmp_rot[8] * scale); }
/** * 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 float getScale() { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate(tmp_scale, tmp_rot); return( (float)Matrix3d.max3(tmp_scale )); }