/// <summary> /// Decompose a matrix to translation, rotation and scale components. Matrix must consist only of translation, /// rotation and uniform scale transformations, otherwise accurate results are not guaranteed. Applying non-uniform /// scale guarantees results will not be accurate. /// </summary> /// <param name="translation">Translation offset.</param> /// <param name="rotation">Rotation quaternion.</param> /// <param name="scale">Scale factors.</param> public void GetTRS(out Vector3 translation, out Quaternion rotation, out Vector3 scale) { Matrix3 m3x3 = ToMatrix3(this); Matrix3 matQ; Vector3 vecU; m3x3.QDUDecomposition(out matQ, out scale, out vecU); rotation = Quaternion.FromRotationMatrix(matQ); translation = new Vector3(m03, m13, m23); }
/// <summary> /// Converts an orthonormal matrix to quaternion representation. /// </summary> /// <returns>Quaternion representing the rotation in this matrix.</returns> public Quaternion ToQuaternion() { return(Quaternion.FromRotationMatrix(this)); }