Quaternion StructureDelta Engine Documentation
Useful for processing 3D rotations. Riemer's XNA tutorials have a nice introductory example of use: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Quaternions.php http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Flight_kinematics.php View code on GitHub

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

public struct Quaternion : IEquatable<Quaternion>, 
	Lerp<Quaternion>, Lerp

The Quaternion type exposes the following members.

Constructors

  NameDescription
Public methodQuaternion(String)
Initializes a new instance of the Quaternion class
Public methodQuaternion(Single, Single, Single, Single)
Initializes a new instance of the Quaternion class
Top
Methods

  NameDescription
Public methodCalculateAxisAngle
Public methodCalculateRotationAxis
Public methodConjugate
Public methodStatic memberCreateLookAt
Public methodDot
Public methodEquals
Public methodStatic memberFromAxisAngle
Public methodStatic memberFromRotationMatrix
Public methodLerp
Public methodStatic memberNormalize
Public methodSlerp
Public methodToEuler
Public methodToString (Overrides ValueType ToString .)
Top
Operators

  NameDescription
Public operatorStatic memberAddition
Public operatorStatic memberMultiply(Quaternion, Quaternion)
Public operatorStatic memberMultiply(Quaternion, Vector3D)
Public operatorStatic memberMultiply(Quaternion, Single)
Top
Fields

  NameDescription
Public fieldStatic memberIdentity
Top
Properties

  NameDescription
Public propertyLength
Public propertyVector3D
Public propertyW
Public propertyX
Public propertyY
Public propertyZ
Top
Remarks

Tests: DeltaEngine.Tests.Datatypes.QuaternionTests
Examples

19 unit tests call DeltaEngine.Datatypes.Quaternion
[Test]
public void SetQuaternion()
{
    var quaternion = new Quaternion(5.2f, 2.6f, 4.4f, 1.1f);
    Assert.AreEqual(5.2f, quaternion.X);
    Assert.AreEqual(2.6f, quaternion.Y);
    Assert.AreEqual(4.4f, quaternion.Z);
    Assert.AreEqual(1.1f, quaternion.W);
}
[Test]
public void CreateQuaternionFromAxisAngle()
{
    var axis = Vector3D.UnitY;
    const float Angle = 90.0f;
    var quaternion = Quaternion.FromAxisAngle(axis, Angle);
    var sinHalfAngle = MathExtensions.Sin(Angle * 0.5f);
    Assert.AreEqual(quaternion.X, axis.X * sinHalfAngle);
    Assert.AreEqual(quaternion.Y, axis.Y * sinHalfAngle);
    Assert.AreEqual(quaternion.Z, axis.Z * sinHalfAngle);
    Assert.AreEqual(quaternion.W, MathExtensions.Cos(Angle * 0.5f));
}
[Test]
public void Length()
{
    Assert.AreEqual(5.477f, new Quaternion(1, -2, 3, -4).Length, 0.001f);
}
See Also