Thursday, September 24, 2009

Quaternions and spatial rotation

Unit quaternions provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Compared to Euler angles they are simpler to compose and avoid the problem of gimbal lock. Compared to rotation matrices they are more numerically stable and may be more efficient. Quaternions have found their way into applications in computer graphics, robotics, navigation, molecular dynamics and orbital mechanics of satellites.

The complex numbers can be defined by introducing an abstract symbol i which satisfies the usual rules of algebra and additionally the rule i2 = −1. This is sufficient to reproduce all of the rules of complex number arithmetic: for example, (a+b\mathbf{i})(c+d\mathbf{i}) = ac + ad\mathbf{i} + b\mathbf{i}c + b\mathbf{i}d\mathbf{i} = ac + ad\mathbf{i} + bc\mathbf{i} + bd\mathbf{i}^2 = (ac - bd) + (bc + ad) \mathbf{i}.
In the same way the quaternions can be defined by introducing abstract symbols i, j, k which satisfy the rules i2 = j2 = k2 = ijk = −1 and the usual algebraic rules except the commutative law of multiplication (a familiar example of such a noncommutative multiplication is matrix multiplication). From this all of the rules of quaternion arithmetic follow: for example, one can show that (a + b\mathbf{i} + c\mathbf{j} + d\mathbf{k}) (e + f\mathbf{i} + g\mathbf{j} + h\mathbf{k}) = (ae - bf - cg - dh) + (af + be + ch - dg) \mathbf{i} + (ag + ce + df - bh) \mathbf{j} + (ah + de + bg - cf) \mathbf{k}.
The imaginary part b\mathbf{i} + c\mathbf{j} + d\mathbf{k} of a quaternion behaves like a vector \vec{v} = (b,c,d) in three dimension vector space, and the real part a behaves like a scalar in \mathbb{R}. When quaternions are used in geometry, it is more convenient to define them as a scalar plus a vector: a + b\mathbf{i} + c\mathbf{j} + d\mathbf{k} = a + \vec{v}.
Those who have studied vectors at school might find strange to add a number to a vector, as they are objects of very different natures, or to multiply two vectors together, as this operation is usually undefined. However, if one remembers that it is a mere notation for the real and imaginary parts of a quaternion, it becomes more legitimate.
We can express quaternion multiplication in the modern language of vector cross and dot products (which were actually inspired by the quaternions in the first place). In place of the rules i2 = j2 = k2 = ijk = −1 we have the vector multiplication rule \vec{v} \vec{w} = \vec{v} \times \vec{w} - \vec{v} \cdot \vec{w}, where:
  • \vec{v} \vec{w} is vector multiplication,
  • \vec{v} \times \vec{w} is vector cross product (a vector),
  • \vec{v} \cdot \vec{w} is vector scalar product (a number).
Vector multiplication is noncommutative (because of the cross product), while scalar-scalar and scalar-vector multiplications commute. From these rules it follows immediately that (s + \vec{v}) (t + \vec{w}) = (s t - \vec{v} \cdot \vec{w}) + (s \vec{w} + t \vec{v} + \vec{v} \times \vec{w}).
The (left and right) multiplicative inverse of a nonzero quaternion is (s + \vec{v})^{-1} = \frac{s - \vec{v}}{s^2 + |\vec{v}|^2}, as can be verified by direct calculation.

No comments:

Post a Comment