This class represents a quaternion type. Quaternions represent a rotation. Typically, they are used for smooth interpolation between two angles, and for avoiding the gimbal lock problem that can occur with euler angles.
Quaternions add a fourth element to the [x, y, z] values that define a vector, resulting in arbitrary 4-D vectors. The following example illustrates how each element of a unit quaternion relates to an axis-angle rotation, where q represents a unit quaternion (x, y, z, w), axis is normalized, and theta is the desired counterclockwise (CCW) rotation around the axis:
- q.x = sin(theta/2) * axis.x
- q.y = sin(theta/2) * axis.y
- q.z = sin(theta/2) * axis.z
- q.w = cos(theta/2)
See Also#
- An article on Quaternions and Spatial Rotation on Wikipedia.
- A video tutorial on moving and rotating the node by using quaternion (C++)
quat Class
Members
quat ( ) #
Default constructor. Produces an identity quaternion (0.0, 0.0, 0.0, 1.0).Last update:
2022-02-04
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)