Microsoft DirectX 8.1 (Visual Basic) |
Type D3DQUATERNION w As Single x As Single y As Single z As Single End Type
Quaternions add a fourth element to the [x, y, z] values that define a vector, resulting in arbitrary 4-D vectors. However, the following 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 CCW rotation about 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)