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.DatatypesAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Quaternion type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | Quaternion(String) | Initializes a new instance of the Quaternion class |
![]() | Quaternion(Single, Single, Single, Single) | Initializes a new instance of the Quaternion class |
Methods
Name | Description | |
---|---|---|
![]() | CalculateAxisAngle | |
![]() | CalculateRotationAxis | |
![]() | Conjugate | |
![]() ![]() | CreateLookAt | |
![]() | Dot | |
![]() | Equals | |
![]() ![]() | FromAxisAngle | |
![]() ![]() | FromRotationMatrix | |
![]() | Lerp | |
![]() ![]() | Normalize | |
![]() | Slerp | |
![]() | ToEuler | |
![]() | ToString | (Overrides ValueType ToString .) |
Operators
Name | Description | |
---|---|---|
![]() ![]() | Addition | |
![]() ![]() | Multiply(Quaternion, Quaternion) | |
![]() ![]() | Multiply(Quaternion, Vector3D) | |
![]() ![]() | Multiply(Quaternion, Single) |
Fields
Name | Description | |
---|---|---|
![]() ![]() | Identity |
Properties
Name | Description | |
---|---|---|
![]() | Length | |
![]() | Vector3D | |
![]() | W | |
![]() | X | |
![]() | Y | |
![]() | Z |
Remarks
Examples
[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