Game Development Reference
In-Depth Information
1.5 Quaternions
1.5.1 Definition
Another useful rotation representation is the quaternion. In their most general
form, quaternions are an extension of complex numbers. Recall that a complex
number can be represented as
c = a + bi,
where i 2 =
1.
We can extend this to a quaternion by creating two more imaginary terms, or
q = w + xi + yj + zk,
where i 2 = j 2 = k 2 = ijk =
1. All of a quaternion's properties follow from
this definition. Since i , j ,and k are constant, we can also write this as an ordered
4-tuple, much as we do vectors:
q =( w, x, y, z ) .
Due to the properties of xi + yj + zk , the imaginary part of a quaternion is
often referred to as a vector in the following notation:
q =( w, v ) .
Using the vector form makes manipulating quaternions easier for those who are
familiar with vector operations.
Note that most software packages store a quaternion as ( x, y, z, w ),which
matches the standard layout for vertex positions in graphics.
1.5.2 Basic Operations
Like vectors, quaternions can be scaled and added, as follows:
a q = aw, a v ) ,
q 0 + q 1
= w 0 + w 1 , q 0 + q 1 ) .
There is only one quaternion multiplication operation. In vector form, this is
represented as
q 0 q 1 =( w 0 w 1 v 0 · v 1 ,w 0 v 1 + w 1 v 0 + v 0 × v 1 ) .
Note that due to the cross product, quaternion multiplication is noncommutative.