private final void getScaleRotate(double scales[], double rots[]) { double[] tmp = new double[9]; // scratch matrix tmp[0] = m00; tmp[1] = m01; tmp[2] = m02; tmp[3] = m10; tmp[4] = m11; tmp[5] = m12; tmp[6] = m20; tmp[7] = m21; tmp[8] = m22; Matrix3d.compute_svd( tmp, scales, rots); return; }
/** * 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_scale = new double[3]; // scratch matrix double[] tmp_rot = new double[9]; // scratch matrix getScaleRotate(tmp_scale, tmp_rot); return( max3(tmp_scale) ); }
Matrix3d m3d = new Matrix3d();
shift = compute_shift( s[1], e[1], s[2]); f = (Math.abs(s[0]) - shift) * (d_sign(c_b48, s[0]) + shift/s[0]); g = e[0]; r = compute_rot(f, g, sinr, cosr, 0, first); f = cosr[0] * s[0] + sinr[0] * e[0]; e[0] = cosr[0] * e[0] - sinr[0] * s[0]; s[1] = cosr[0] * s[1]; r = compute_rot(f, g, sinl, cosl, 0, first); first = 0; s[0] = r; e[1] = cosl[0] * e[1]; r = compute_rot(f, g, sinr, cosr, 1, first); e[0] = r; f = cosr[1] * s[1] + sinr[1] * e[1]; r = compute_rot(f, g, sinl, cosl, 1, first); s[1] = r; f = cosl[1] * e[1] + sinl[1] * s[2]; compute_2X2( s[0],e[0],s[1],s,sinl,cosl,sinr,cosr, 0); v[7] = -sinr[0]*vtemp + cosr[0]*v[7]; } else { compute_2X2( s[1],e[1],s[2],s,sinl,cosl,sinr,cosr,1);
compute_qr( single_values, e, u1, v1); if(almostEqual(Math.abs(scales[0]), 1.0) && almostEqual(Math.abs(scales[1]), 1.0) && almostEqual(Math.abs(scales[2]), 1.0)) { transpose_mat(u1, t1); transpose_mat(v1, t2); svdReorder( m, t1, t2, scales, outRot, outScale);
mat_mul(t1,t2,rot); if(almostEqual(Math.abs(scales[0]), Math.abs(scales[1])) && almostEqual(Math.abs(scales[1]), Math.abs(scales[2])) ){ for(i=0;i<9;i++){ outRot[i] = rot[i];
/** * 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 = tmp_rot[0]; this.m01 = tmp_rot[1]; this.m02 = tmp_rot[2]; this.m10 = tmp_rot[3]; this.m11 = tmp_rot[4]; this.m12 = tmp_rot[5]; this.m20 = tmp_rot[6]; this.m21 = tmp_rot[7]; this.m22 = tmp_rot[8]; }
t = d_sign(c_b3, ft) * d_sign(c_b4, gt); } else { t = gt / d_sign(d, ft) + m / t; tsign = d_sign(c_b4, csr[0]) * d_sign(c_b4, csl[0]) * d_sign(c_b4, f); tsign = d_sign(c_b4, snr[0]) * d_sign(c_b4, csl[0]) * d_sign(c_b4, g); tsign = d_sign(c_b4, snr[0]) * d_sign(c_b4, snl[0]) * d_sign(c_b4, h); single_values[index] = d_sign(ssmax, tsign); d__1 = tsign * d_sign(c_b4, f) * d_sign(c_b4, h); single_values[index+1] = d_sign(ssmin, d__1);
Matrix3d m3d = new Matrix3d();
/** * 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(double scale) { double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix getScaleRotate(tmp_scale, tmp_rot); this.m00 = tmp_rot[0] * scale; this.m01 = tmp_rot[1] * scale; this.m02 = tmp_rot[2] * scale; this.m10 = tmp_rot[3] * scale; this.m11 = tmp_rot[4] * scale; this.m12 = tmp_rot[5] * scale; this.m20 = tmp_rot[6] * scale; this.m21 = tmp_rot[7] * scale; this.m22 = tmp_rot[8] * scale; }
Matrix3d m3d = new Matrix3d();
private final void getScaleRotate(double scales[], double rots[]) { double[] tmp = new double[9]; // scratch matrix tmp[0] = m00; tmp[1] = m01; tmp[2] = m02; tmp[3] = m10; tmp[4] = m11; tmp[5] = m12; tmp[6] = m20; tmp[7] = m21; tmp[8] = m22; Matrix3d.compute_svd( tmp, scales, rots); return; }
syntaxError(st, file, "All rows must have three elements") ; return new Matrix3d(((Point3d)elements.get(0)).x, ((Point3d)elements.get(0)).y, ((Point3d)elements.get(0)).z,
/** * perform SVD (if necessary to get rotational component */ void getScaleRotate( double[] scales, double[] rot ) { double[] tmp = new double[9]; // scratch matrix tmp[0] = m00; tmp[1] = m01; tmp[2] = m02; tmp[3] = m10; tmp[4] = m11; tmp[5] = m12; tmp[6] = m20; tmp[7] = m21; tmp[8] = m22; Matrix3d.compute_svd(tmp, scales, rot); return; }
final Matrix3d rotm = new Matrix3d( o[0].x, o[1].x, o[2].x, o[0].y, o[1].y, o[2].y,
/** * perform SVD (if necessary to get rotational component */ final void getScaleRotate(double scales[], double rots[]) { double[] tmp = new double[9]; // scratch matrix tmp[0] = m00; tmp[1] = m01; tmp[2] = m02; tmp[3] = m10; tmp[4] = m11; tmp[5] = m12; tmp[6] = m20; tmp[7] = m21; tmp[8] = m22; compute_svd( tmp, scales, rots); return; }
tmp[8] = m1.m20*m2.m02 + m1.m21*m2.m12 + m1.m22*m2.m22; Matrix3d.compute_svd( tmp, tmp_scale, tmp_rot);
/** * Perform singular value decomposition normalization of matrix m1 * and place the normalized values into this. * @param m1 the matrix values to be normalized */ public final void normalize(Matrix3f m1){ double[] tmp = new double[9]; // scratch matrix double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix tmp[0] = m1.m00; tmp[1] = m1.m01; tmp[2] = m1.m02; tmp[3] = m1.m10; tmp[4] = m1.m11; tmp[5] = m1.m12; tmp[6] = m1.m20; tmp[7] = m1.m21; tmp[8] = m1.m22; Matrix3d.compute_svd( tmp, 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]); }
/** * Perform singular value decomposition normalization of matrix m1 and * place the normalized values into this. * @param m1 Provides the matrix values to be normalized */ public final void normalize(Matrix3d m1){ double[] tmp = new double[9]; // scratch matrix double[] tmp_rot = new double[9]; // scratch matrix double[] tmp_scale = new double[3]; // scratch matrix tmp[0] = m1.m00; tmp[1] = m1.m01; tmp[2] = m1.m02; tmp[3] = m1.m10; tmp[4] = m1.m11; tmp[5] = m1.m12; tmp[6] = m1.m20; tmp[7] = m1.m21; tmp[8] = m1.m22; compute_svd( tmp, tmp_scale, tmp_rot); this.m00 = tmp_rot[0]; this.m01 = tmp_rot[1]; this.m02 = tmp_rot[2]; this.m10 = tmp_rot[3]; this.m11 = tmp_rot[4]; this.m12 = tmp_rot[5]; this.m20 = tmp_rot[6]; this.m21 = tmp_rot[7]; this.m22 = tmp_rot[8]; }
tmp[8] = m1.m20*m2.m02 + m1.m21*m2.m12 + m1.m22*m2.m22; compute_svd( tmp, tmp_scale, tmp_rot);