Gimbal lock
See also: http://en.wikipedia.org/wiki/Gimbal_lock
Euler angles have a major deficiency, and that is, that it is possible,
in some rotation sequences, to reach a situation where two of the three
Euler angles cause rotation around the same axis of the object. In the
case below, rotation around the \(x\) axis becomes indistinguishable in
its effect from rotation around the \(z\) axis, so the \(z\) and \(x\) axis
angles collapse into one transformation, and the rotation reduces from
three degrees of freedom to two.
Imagine that we are using the Euler angle convention of starting with a
rotation around the \(x\) axis, followed by the \(y\) axis, followed by the
\(z\) axis.
Here we see a Spitfire aircraft, flying across the screen. The \(x\) axis
is left to right (tail to nose), the \(y\) axis is from the left wing tip
to the right wing tip (going away from the screen), and the \(z\) axis is
from bottom to top:
Imagine we wanted to do a slight roll with the left wing tilting down
(rotation about \(x\)) like this:
followed by a violent pitch so we are pointing straight up (rotation
around \(y\) axis):
Now we’d like to do a turn of the nose towards the viewer (and the tail
away from the viewer):
But, wait, let’s go back over that again. Look at the result of the
rotation around the \(y\) axis. Notice that the \(x\) axis, as was, is now
aligned with the \(z\) axis, as it is now. Rotating around the \(z\) axis
will have exactly the same effect as adding an extra rotation around the
\(x\) axis at the beginning. That means that, when there is a \(y\) axis
rotation that rotates the \(x\) axis onto the \(z\) axis (a rotation of
\(\pm\pi/2\) around the \(y\) axis) - the \(x\) and \(y\) axes are “locked”
together.
Mathematics of gimbal lock
We see gimbal lock for this type of Euler axis convention, when
\(\cos(\beta) = 0\), where \(\beta\) is the angle of rotation around the \(y\)
axis. By “this type of convention” we mean using rotation around all 3
of the \(x\), \(y\) and \(z\) axes, rather than using the same axis twice -
e.g. the physics convention of \(z\) followed by \(x\) followed by \(z\) axis
rotation (the physics convention has different properties to its gimbal
lock).
We can show how gimbal lock works by creating a rotation matrix for the
three component rotations. Recall that, for a rotation of \(\alpha\)
radians around \(x\), followed by a rotation \(\beta\) around \(y\), followed
by rotation \(\gamma\) around \(z\), the rotation matrix \(R\) is:
\[\begin{split}R = \left(\begin{smallmatrix}\operatorname{cos}\left(\beta\right) \operatorname{cos}\left(\gamma\right) & - \operatorname{cos}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) + \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\beta\right) & \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) + \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\beta\right)\\\operatorname{cos}\left(\beta\right) \operatorname{sin}\left(\gamma\right) & \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\gamma\right) + \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\beta\right) \operatorname{sin}\left(\gamma\right) &- \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\alpha\right) + \operatorname{cos}\left(\alpha\right) \operatorname{sin}\left(\beta\right) \operatorname{sin}\left(\gamma\right)\\- \operatorname{sin}\left(\beta\right) & \operatorname{cos}\left(\beta\right) \operatorname{sin}\left(\alpha\right) & \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\beta\right)\end{smallmatrix}\right)\end{split}\]
When \(\cos(\beta) = 0\), \(\sin(\beta) = \pm1\) and \(R\) simplifies to:
\[\begin{split}R = \left(\begin{smallmatrix}0 & - \operatorname{cos}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) + \pm{1} \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\alpha\right) & \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) + \pm{1} \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\gamma\right)\\0 & \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\gamma\right) + \pm{1} \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) & - \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\alpha\right) + \pm{1} \operatorname{cos}\left(\alpha\right) \operatorname{sin}\left(\gamma\right)\\- \pm{1} & 0 & 0\end{smallmatrix}\right)\end{split}\]
When \(\sin(\beta) = 1\):
\[\begin{split}R = \left(\begin{smallmatrix}0 & \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\alpha\right) - \operatorname{cos}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) & \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\gamma\right) + \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\gamma\right)\\0 & \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\gamma\right) + \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) & \operatorname{cos}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) - \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\alpha\right)\\-1 & 0 & 0\end{smallmatrix}\right)\end{split}\]
From the angle sum and difference identities
(see also geometric proof, Mathworld treatment) we
remind ourselves that, for any two angles \(\alpha\) and \(\beta\):
\[ \begin{align}\begin{aligned}\sin(\alpha \pm \beta) = \sin \alpha \cos \beta \pm \cos \alpha \sin \beta \,\\\cos(\alpha \pm \beta) = \cos \alpha \cos \beta \mp \sin \alpha \sin \beta\end{aligned}\end{align} \]
We can rewrite \(R\) as:
\[\begin{split}R = \left(\begin{smallmatrix}0 & V_{1} & V_{2}\\0 & V_{2} & - V_{1}\\-1 & 0 & 0\end{smallmatrix}\right)\end{split}\]
where:
\[ \begin{align}\begin{aligned}V_1 = \operatorname{cos}\left(\gamma\right) \operatorname{sin}\left(\alpha\right) - \operatorname{cos}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) = \sin(\alpha - \gamma) \,\\V_2 = \operatorname{cos}\left(\alpha\right) \operatorname{cos}\left(\gamma\right) + \operatorname{sin}\left(\alpha\right) \operatorname{sin}\left(\gamma\right) = \cos(\alpha - \gamma)\end{aligned}\end{align} \]
We immediately see that \(\alpha\) and \(\gamma\) are going to lead the same
transformation - the mathematical expression of the observation on the
spitfire above, that rotation around the \(x\) axis is equivalent to
rotation about the \(z\) axis.
It’s easy to do the same set of reductions, with the same conclusion,
for the case where \(\sin(\beta) = -1\) - see
http://www.gregslabaugh.name/publications/euler.pdf.