Gimbal lock#

See also: https://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:

_images/spitfire_0.png

Imagine we wanted to do a slight roll with the left wing tilting down (rotation about x) like this:

_images/spitfire_x.png

followed by a violent pitch so we are pointing straight up (rotation around y axis):

_images/spitfire_y.png

Now we’d like to do a turn of the nose towards the viewer (and the tail away from the viewer):

_images/spitfire_hoped.png

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 ±π/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(β)=0, where β 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 α radians around x, followed by a rotation β around y, followed by rotation γ around z, the rotation matrix R is:

R=(cos(β)cos(γ)cos(α)sin(γ)+cos(γ)sin(α)sin(β)sin(α)sin(γ)+cos(α)cos(γ)sin(β)cos(β)sin(γ)cos(α)cos(γ)+sin(α)sin(β)sin(γ)cos(γ)sin(α)+cos(α)sin(β)sin(γ)sin(β)cos(β)sin(α)cos(α)cos(β))

When cos(β)=0, sin(β)=±1 and R simplifies to:

R=(0cos(α)sin(γ)+±1cos(γ)sin(α)sin(α)sin(γ)+±1cos(α)cos(γ)0cos(α)cos(γ)+±1sin(α)sin(γ)cos(γ)sin(α)+±1cos(α)sin(γ)±100)

When sin(β)=1:

R=(0cos(γ)sin(α)cos(α)sin(γ)cos(α)cos(γ)+sin(α)sin(γ)0cos(α)cos(γ)+sin(α)sin(γ)cos(α)sin(γ)cos(γ)sin(α)100)

From the angle sum and difference identities (see also geometric proof, Mathworld treatment) we remind ourselves that, for any two angles α and β:

sin(α±β)=sinαcosβ±cosαsinβcos(α±β)=cosαcosβsinαsinβ

We can rewrite R as:

R=(0V1V20V2V1100)

where:

V1=cos(γ)sin(α)cos(α)sin(γ)=sin(αγ)V2=cos(α)cos(γ)+sin(α)sin(γ)=cos(αγ)

We immediately see that α and γ 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(β)=1 - see http://www.gregslabaugh.name/publications/euler.pdf.