Quaternion Normalize Method Delta Engine Documentation

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

public static Quaternion Normalize(
	Quaternion q
)

Return Value

Type: Quaternion
Remarks

Tests: DeltaEngine.Tests.Datatypes.QuaternionTests
Examples

2 unit tests call DeltaEngine.Datatypes.Quaternion.Normalize(DeltaEngine.Datatypes.Quaternion)
[Test]
public void Normalize()
{
    var quaternion = new Quaternion(1, 3, 5, 7);
    var expected = new Quaternion(0.1091f, 0.3273f, 0.5455f, 0.7638f);
    Assert.AreEqual(expected, Quaternion.Normalize(quaternion));
}
[Test]
public void RotatingVectorByQuaternionMatchesRotatingItByMatrix()
{
    var axis = new Vector3D(4, 5, 6);
    axis.Normalize();
    var quaternion = Quaternion.FromAxisAngle(axis, 23.0f);
    var direction = new Vector3D(1, 2, 3);
    var rotatedViaMatrix = Matrix.FromQuaternion(quaternion) * direction;
    var rotatedViaQuaternion = quaternion * direction;
    Assert.IsTrue(rotatedViaQuaternion.IsNearlyEqual(rotatedViaMatrix));
}
See Also