Quaternions
Eric Bainville - Mar 2007Unit 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(u) = q × u × q*
rq has the following properties:
- rq(u) is a 3-vector: rq is a transformation of R3.
- rq(a.u + b.v) = a.rq(u)+b.rq(v): rq is a linear transformation of R3.
- <rq(u),rq(v)> = <u,v> (preserves the dot product): rq is an orthogonal transformation of R3.
- rq = r-q: q and -q correspond to the same transformation.
- r1 is the identity.
- rq-1 = rq*: q and q* represent inverse transformations.
- rp(rq(u)) = rp×q(u): p × q corresponds to rp o rq.
- If x is the vector part of q, then rq(x) = x: x is invariant by rq.
Developping the product, we can obtain the 3×3 matrix Mq of rq, for q=(s,u):
s2+ux2-uy2-uz2 | 2(ux.uy-s.uz) | 2(ux.uz+s.uy) |
2(ux.uy+s.uz) | s2-ux2+uy2-uz2 | 2(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.
Quaternions : Definitions | Top of Page | Quaternions : Conversions |