/** * Sets the Quaternion from the three rotated vectors of an orthogonal basis. * * <p>The three vectors do not have to be normalized but must be orthogonal and direct (i,e., * {@code X^Y=k*Z, with k>0}). * * @param X the first PVector * @param Y the second PVector * @param Z the third PVector * @see #fromRotationMatrix(float[][]) * @see #Quaternion(PVector, PVector) */ public final void fromRotatedBasis(PVector X, PVector Y, PVector Z) { float m[][] = new float[3][3]; float normX = X.mag(); float normY = Y.mag(); float normZ = Z.mag(); for (int i = 0; i < 3; ++i) { m[i][0] = (X.array())[i] / normX; m[i][1] = (Y.array())[i] / normY; m[i][2] = (Z.array())[i] / normZ; } fromRotationMatrix(m); }
/** * Set the Quaternion from a (supposedly correct) 3x3 rotation matrix given in the upper left 3x3 * sub-matrix of the PMatrix3D. * * @see #fromRotationMatrix(float[][]) */ public final void fromMatrix(PMatrix3D pM) { fromRotationMatrix(MathUtils.get3x3UpperLeftMatrixFromPMatrix3D(pM)); }