Complex numbers of modulus 1 rotate the plane. Hamilton hoped his numbers would do the same in space, and they do, but in a subtler way than he first imagined.

The recipe

Write a point of space $(x, y, z)$ as the pure quaternion $v = xi + yj + zk$. To rotate by an angle $\theta$ about an axis given by a unit vector $u = u_1 i + u_2 j + u_3 k$, take

$$q = \cos\frac{\theta}{2} + \sin\frac{\theta}{2}\,(u_1 i + u_2 j + u_3 k)$$

and compute

$$v \;\longmapsto\; q\,v\,q^{-1}, \qquad q^{-1} = \cos\frac{\theta}{2} - \sin\frac{\theta}{2}\,(u_1 i + u_2 j + u_3 k).$$

The result is again a pure quaternion: the rotated point. Choose the axis and the angle:

Two things stand out. The first is the half angle: $q$ appears twice in the “sandwich” $q v q^{-1}$, and each side contributes half of the turn. The second follows from it: at $\theta = 360°$ the object is back in place, but $q = \cos 180° = -1$. The quaternions $q$ and $-q$ give the same rotation. It takes two full turns for the quaternion to return to its start as well, a property that reappears, a century later, in the spin of the electron.

Composing is multiplying

Rotating first by $q_1$ and then by $q_2$ gives $q_2 (q_1 v q_1^{-1}) q_2^{-1} = (q_2 q_1)\,v\,(q_2 q_1)^{-1}$. The combined rotation is simply the product $q_2 q_1$. And since rotations in space do not commute (turn a book half a turn about two different axes, in both orders, and compare), it is natural that quaternions do not commute either. The flaw that so troubled Hamilton’s contemporaries is in fact a virtue.

From Apollo to the phone

Rotations can also be described by three angles, like those of an aircraft (heading, pitch and roll), but these angles have a flaw: in certain positions two axes line up and a degree of freedom is lost, the so-called gimbal lock. On Apollo 11 the navigation platform had three gimbals and had to avoid that position; the astronaut Michael Collins joked over the radio, asking for “a fourth gimbal for Christmas”. Quaternions do not have this problem. Since Ken Shoemake showed in 1985 how to interpolate smoothly between two rotations with quaternions, they have become standard in computer animation, video games, robotics, spacecraft and the orientation sensors of mobile phones.

Exercise: a quarter turn about k

Rotate the point $v = i$ (the point $(1, 0, 0)$) by $90°$ about the axis $k$.

$q = \cos 45° + \sin 45°\,k = \frac{1 + k}{\sqrt2}$ and $q^{-1} = \frac{1 - k}{\sqrt2}$. Then $q\,i\,q^{-1} = \frac{(1 + k)\,i\,(1 - k)}{2} = \frac{(i + j)(1 - k)}{2} = \frac{i - ik + j - jk}{2} = \frac{i + j + j - i}{2} = j$. The point $(1, 0, 0)$ has gone to $(0, 1, 0)$, a quarter turn.

Exercise: two half turns

A half turn ($180°$) about $i$ corresponds to $q_1 = i$; about $j$, to $q_2 = j$. What is the combined rotation, first about $i$, then about $j$?

$q_2 q_1 = ji = -k = \cos 90° + \sin 90°\,(-k)$: a half turn about the axis $-k$, which is the same half turn about $k$. Two half turns about perpendicular axes give a half turn about the third axis.

Sources: Olinde Rodrigues, “Des lois géométriques qui régissent les déplacements d’un système solide dans l’espace”, Journal de Mathématiques Pures et Appliquées (1840) · Arthur Cayley, “On certain results relating to quaternions”, Philosophical Magazine (1845) · Simon L. Altmann, Rotations, Quaternions, and Double Groups (1986) · Ken Shoemake, “Animating rotation with quaternion curves”, SIGGRAPH (1985).


All topics on William Rowan Hamilton · ← Quaternions: the formula on the bridge · Vectors and scalars: Hamilton’s words →

Image credits.