Quaternions

Eric Bainville - Mar 2007

Unit quaternions and rotations

A unit quaternion is a quaternion q of norm |q|=1. The set of unit quaternions is a non-commutative multiplicative group. Given a unit quaternion q, let's define the function rq operating on 3-vectors as follows:

rq has the following properties:

Developping the product, we can obtain the 3×3 matrix Mq of rq, for q=(s,u):

s2+ux2-uy2-uz22(ux.uy-s.uz)2(ux.uz+s.uy)
2(ux.uy+s.uz)s2-ux2+uy2-uz22(uy.uz-s.ux)
2(ux.uz-s.uy)2(uy.uz+s.ux)s2-ux2-uy2+uz2

After reduction, it appears that det(Mq)=|q|6=1: rq is a rotation.

Up to the identification of q and -q, rq is an isomorphism between the group of rotations in R3, and the group of unit quaternions.

Computing the product of two rotations requires 16.mul+12.add in quaternion form, and 27.mul+18.add in matrix form. Computing the image of a vector by a rotation requires 28.mul+20.add in quaternion form (using two consecutive quaternion products), and 9.mul+6.add in matrix form. Computing Mq requires 10.mul+21.add.

Using quaternions is a faster and more stable way of composing a large number of rotations. To apply the rotation itself to any number of vectors (even to one vector, unless it is known to have two zero coordinates), it is more convenient to precompute the matrix form, then compute matrix-vector products.