Quaternion FromRotationMatrix Method Delta Engine Documentation

Namespace: DeltaEngine.Datatypes
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public static Quaternion FromRotationMatrix(
	Matrix m
)

Return Value

Type: Quaternion
Remarks

Tests: DeltaEngine.Tests.Datatypes.QuaternionTests
Examples

2 unit tests call DeltaEngine.Datatypes.Quaternion.FromRotationMatrix(DeltaEngine.Datatypes.Matrix)
[Test]
public void MultiplyingTwoQuaternionsMatchesMultiplyingTwoMatrices()
{
    var q1 = Quaternion.FromAxisAngle(Vector3D.Normalize(new Vector3D(1, 2, 3)), 40.0f);
    var q2 = Quaternion.FromAxisAngle(Vector3D.Normalize(new Vector3D(4, -5, 6)), -10.0f);
    var q3 = q1 * q2;
    var m1 = Matrix.FromQuaternion(q1);
    var m2 = Matrix.FromQuaternion(q2);
    var m3 = m1 * m2;
    Assert.AreEqual(q3, Quaternion.FromRotationMatrix(m3));
}
[Test]
public void CheckCreateLookAt()
{
    var matLookAt = Matrix.CreateLookAt(Vector3D.One, Vector3D.UnitY, Vector3D.UnitZ);
    var quaternion = Quaternion.CreateLookAt(Vector3D.One, Vector3D.UnitY, Vector3D.UnitZ);
    Assert.AreEqual(quaternion, Quaternion.FromRotationMatrix(matLookAt));
}
See Also