Euler
angles describe any orientation with three numbers — yaw,
pitch, and roll — applied as three nested turns. It is the
most intuitive way to point a camera or an aircraft, and it has a fatal flaw hiding in plain
sight. At one special orientation, two of your three knobs quietly start doing the
same thing. That collapse is gimbal lock, and it is the reason
serious 3-D code reaches for quaternions
instead.
Three nested rings
Picture a physical gimbal: three rings mounted one inside the other, each free to spin on a
single pin. The outer ring carries the yaw rotation (about the vertical
axis), the middle ring carries the pitch, and the inner ring carries the
roll. Crucially, each ring's axis is dragged around by the rings outside it
— so the roll axis depends on where pitch and yaw have already pointed it. We apply the three
rotations in order:
R(\text{yaw}, \text{pitch}, \text{roll}) = R_z(\text{yaw})\, R_y(\text{pitch})\, R_x(\text{roll}).
Read it right-to-left: first roll about x, then pitch about
y, then yaw about z. As long as the
middle ring sits at a generic angle the three axes point in three different directions, and
all is well. The trouble begins when the middle ring swings to a right angle.
Watch the degree of freedom vanish
Let us drive the pitch (the middle ring) all the way to
\text{pitch} = 90° and follow the axes line by line. Use the
compact 3\times 3 rotation matrices, with
c_\theta = \cos\theta and s_\theta = \sin\theta.
Step 1 — the three turns. Yaw about z, pitch
about y, roll about x:
R_z(\alpha) = \begin{pmatrix} c_\alpha & -s_\alpha & 0 \\ s_\alpha & c_\alpha & 0 \\ 0 & 0 & 1 \end{pmatrix}, \quad R_y(\beta) = \begin{pmatrix} c_\beta & 0 & s_\beta \\ 0 & 1 & 0 \\ -s_\beta & 0 & c_\beta \end{pmatrix}, \quad R_x(\gamma) = \begin{pmatrix} 1 & 0 & 0 \\ 0 & c_\gamma & -s_\gamma \\ 0 & s_\gamma & c_\gamma \end{pmatrix}.
Step 2 — set the middle ring to its right angle. Put
\beta = 90°, so c_\beta = 0 and
s_\beta = 1. The pitch matrix collapses to a clean swap of axes:
R_y(90°) = \begin{pmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ -1 & 0 & 0 \end{pmatrix}.
Step 3 — push the yaw through the tilted pitch. The pitch has rotated the
roll axis so that it now points along the very axis yaw turns about. Multiply
R_y(90°)\, R_x(\gamma) and compare it with
R_z(\alpha)\, R_y(90°); both leave the middle column fixed and act
as a single planar rotation on the other two axes. Concretely, sandwiching with
R_y(90°) turns a roll into a yaw:
R_y(90°)\, R_x(\gamma) = R_z(\gamma)\, R_y(90°).
Step 4 — collapse the product. Substitute that identity into the full
composition and the two outer rotations fuse into one:
R = R_z(\alpha)\, R_y(90°)\, R_x(\gamma) = R_z(\alpha)\, R_z(\gamma)\, R_y(90°) = R_z(\alpha + \gamma)\, R_y(90°).
Step 5 — read the catastrophe. The whole orientation now depends only on
the sum \alpha + \gamma. Yaw and roll have become the
same knob: turning the outer ring forward by one degree and the inner ring back by one degree
leaves the orientation unchanged. Two of your three controls fight over a single
circle of motion, and the third direction of rotation — tilting the nose left or right of
the locked plane — has no knob left to drive it. You have lost a degree of
freedom.
Nothing broke physically; the rings can still spin. But the parameterisation went
singular. Near \text{pitch} = 90° a small desired motion can
demand an enormous, near-instantaneous spin of yaw and roll to fake it — which is exactly the
violent snap you see when a camera using Euler angles passes over the pole.
For Euler angles R = R_z(\alpha)\, R_y(\beta)\, R_x(\gamma):
-
when the middle rotation reaches a right angle,
\beta = \pm 90°, the outer and inner axes
align — yaw and roll act about the same axis;
-
the orientation then depends only on the combination
\alpha \pm \gamma, so the system loses a degree of
freedom: two knobs do one job and one direction of rotation cannot be commanded
at all;
-
this singularity is intrinsic to Euler angles as a parameterisation —
it is not a hardware fault and no choice of axis order removes it, only moves where it
strikes;
-
it is the standard motivation for axis-angle
and quaternion
representations, which carry no such singularity.
This is not a textbook abstraction — it nearly bit Apollo. The Apollo guidance platform
rode on a three-gimbal inertial measurement unit, and a real lock would have
tumbled the platform and lost the spacecraft's attitude reference. The software guarded a
forbidden cone around the lock, and on Apollo 11 Mike Collins, eyeing how easily a manoeuvre
could stray into it, radioed the famous gripe: “How about sending me a fourth gimbal
for Christmas?” A fourth ring would have given the redundancy to dodge the singularity
— exactly the redundancy that z = w + xi + yj + zk quaternions,
with four numbers for three angles, supply for free. NASA's engineers had chosen three
gimbals to save weight and instead bought themselves a no-fly zone in the sky.