OxMQuaternion Class
Quaternions are 4D vectors that represent rotations in 3D space. The most useful aspect about quaternions is the ability to combine rotations via multiplication, and interpolate rotations between two quaternions. The OxMQuaternion class supports the multiply ( * ) operator for more natural expressions, but also provides methods to multiply in-place to reduce object overhead.
Important: Quaternions are non-commutative - quat1*quat2 does not equal quat2*quat1.
Constructors
Expand All | Collapse All
-
OxMQuaternion
Default constructor, creates a normalized quaternion with a null rotation. -
OxMQuaternion ( rx As Double, ry As Double, rz As Double )
Set the rotation using three Doubles representing a Euler rotation vector. Note: This is not very efficient and not recommended for general use. -
OxMQuaternion ( axisang As OxMAxisAngle )
Set the rotation by converting an axis-angle. -
OxMQuaternion ( quat As OxMQuaternion )
Set the rotation to a copy of the passed quaternion. -
OxMQuaternion ( v As OxMVector3, ang As Double )
Set the rotation using an axis vector and angle in radians.
Properties
Methods
Expand All | Collapse All
-
Angle ( q As OxMQuaternion ) As Double
Returns the angle (in radians) between this quaternion and the passed quaternion. -
Copy ( q As OxMQuaternion )
Set the rotation to a copy of the passed quaternion. -
CopyInverse ( q As OxMQuaternion )
Set the rotation to an inverted (opposite) copy of the passed quaternion. -
DotProduct ( q As OxMQuaternion ) As Double
Returns the dot product (or inner product) of this quaternion and the passed quaternion. -
Equals ( q As OxMQuaternion ) As Boolean
Returns True if the quaternion has the exact same value as the passed quaternion.
Note: This is not generally useful due to floating point errors, however it can be handy to compare a quaternion's current state with a previously stored state prior to executing potentially expensive operations such as interpolation. -
Identity
Sets the quaternion to a normalized null rotation. -
Inverse As OxMQuaternion
Returns a quaternion that is the inverse (opposite or conjugate) of this quaternion. -
Invert
Sets the rotation to the inverse (opposite or conjugate) of the current rotation. -
MultiplyForward ( q As OxMQuaternion )
Multiply this quaternion with the passed quaternion and store the result. This is equivalent to:
self = self * q
-
MultiplyReverse ( q As OxMQuaternion )
Multiply the passed quaternion with this quaternion and store the result. This is equivalent to:
self = q * self
-
Normalize
Scales the quaternion to unit length (1.0). -
SetBetween ( q1 As OxMQuaternion, q2 As OxMQuaternion, pos As Double )
Uses spherical-linear (slerp) interpolation to set this quaternion to a rotation between the passed quaternions given a normalized fractional position. E.g. a pos value of 0.0 will set the rotation to q1, a value of 1.0 will set the rotation to q2, and a value of 0.5 will set the rotation to half-way between q1 and q2. -
SetBetweenFast ( q1 As OxMQuaternion, q2 As OxMQuaternion, pos As Double )
Same as the SetBetween method, but uses faster linear interpolation. SetBetween will usually give better results for large interpolations and is already optimized to use faster linear interpolation for small rotations. -
SetRotate ( rx As Double, ry As Double, rz As Double )
Set the rotation using three Doubles representing a Euler rotation vector. Note: This is not very efficient and not recommended for general use. -
SetRotate ( aX As Double, aY As Double, aZ As Double, angle As Double )
Set the rotation using an axis represented by three Double values, and the angle in radians using a fourth Double. -
SetRotate ( axisang As OxMAxisAngle )
Set the rotation by converting an axis-angle. -
SetRotate ( v As OxMVector3, ang As Double )
Set the rotation using an axis vector and angle in radians. -
SetRotateX ( angle As Double )
Set the rotation to the passed angle (in radians) around the X axis. -
SetRotateY ( angle As Double )
Set the rotation to the passed angle (in radians) around the Y axis. -
SetRotateZ ( angle As Double )
Set the rotation to the passed angle (in radians) around the Z axis. -
ToEuler As OxMVector3
Converts the quaternion to a Euler rotation vector. Note: This conversion is not very efficient and not recommended for general use.