Ma · Mathematics

Why Do Euler Angles Cause Gimbal Lock?

Published By the 9to5Science editorial team

At a glance

  1. 1. Choose a convention

    Use yaw, pitch, and roll as rotations about z, y, and x, in that order.

  2. 2. Find the singular pose

    At a pitch of plus or minus 90 degrees, two of the rotation axes line up.

  3. 3. See what is lost

    Yaw and roll then describe the same rotational direction, so their effects cannot be distinguished.

  4. 4. Interpret the problem

    The object can still rotate freely; the Euler-angle coordinates have become redundant at that pose.

Advertisement

Euler angles describe a 3D orientation using three successive rotations. They are intuitive and compact, but their coordinates can become singular: at certain orientations, changing two angles produces the same kind of rotation. This is called gimbal lock.

The name comes from a mechanical arrangement of nested rings, or gimbals. When two ring axes line up, the mechanism loses one independent axis of motion. The mathematical issue is closely related, but it is useful to distinguish the two: gimbal lock in Euler angles is a singularity in a way of describing orientation. A rigid object itself does not lose a physical degree of freedom.

A standard yaw–pitch–roll convention

Consider one common convention: yaw ψ\psi about the zz-axis, pitch θ\theta about the yy-axis, and roll ϕ\phi about the xx-axis, with the rotation matrix

R=Rz(ψ)Ry(θ)Rx(ϕ).R=R_z(\psi)R_y(\theta)R_x(\phi).

This is often called the ZYX convention. The exact meaning of “intrinsic” and “extrinsic” rotations depends on how a convention is stated, so the matrix product is the unambiguous definition here. Other Euler-angle conventions have their own singular poses; their angle names and signs may differ.

For this convention, multiplying the three matrices gives

R=[cos⁡ψcos⁡θcos⁡ψsin⁡θsin⁡ϕ−sin⁡ψcos⁡ϕcos⁡ψsin⁡θcos⁡ϕ+sin⁡ψsin⁡ϕsin⁡ψcos⁡θsin⁡ψsin⁡θsin⁡ϕ+cos⁡ψcos⁡ϕsin⁡ψsin⁡θcos⁡ϕ−cos⁡ψsin⁡ϕ−sin⁡θcos⁡θsin⁡ϕcos⁡θcos⁡ϕ].R=\begin{bmatrix} \cos\psi\cos\theta & \cos\psi\sin\theta\sin\phi-\sin\psi\cos\phi & \cos\psi\sin\theta\cos\phi+\sin\psi\sin\phi\\ \sin\psi\cos\theta & \sin\psi\sin\theta\sin\phi+\cos\psi\cos\phi & \sin\psi\sin\theta\cos\phi-\cos\psi\sin\phi\\ -\sin\theta & \cos\theta\sin\phi & \cos\theta\cos\phi \end{bmatrix}.

Away from a singular pose, the three angles can locally vary independently to describe orientation. The problem appears when the pitch reaches θ=π/2\theta=\pi/2 or θ=−π/2\theta=-\pi/2, where cos⁡θ=0\cos\theta=0.

How the axes become dependent

In the ZYX convention, the three successive rotation axes, expressed in fixed coordinates, are the original zz-axis, the yy-axis after yaw, and the xx-axis after yaw and pitch. At pitch θ=π/2\theta=\pi/2, the last of these lines up with the original zz-axis but points in the opposite direction. Thus, a small change in roll acts along the same axis as a small change in yaw, with the opposite sign.

The angle-to-orientation map therefore loses a degree of local independence. Mathematically, its Jacobian loses rank: it can no longer turn three independent small changes in angles into three independent changes in orientation. A numerical system that tries to recover angular velocity from Euler-angle rates may become unstable or fail to find a unique set of rates at that pose.

A worked example at 90 degrees of pitch

Set θ=90∘\theta=90^\circ. Substituting into the matrix and writing δ=ϕ−ψ\delta=\phi-\psi gives

R=[0sin⁡δcos⁡δ0cos⁡δ−sin⁡δ−100].R=\begin{bmatrix} 0 & \sin\delta & \cos\delta\\ 0 & \cos\delta & -\sin\delta\\ -1 & 0 & 0 \end{bmatrix}.

The matrix depends on yaw ψ\psi and roll ϕ\phi only through their difference. For example, these two triples produce the same orientation:

  • yaw 30∘30^\circ, pitch 90∘90^\circ, roll 10∘10^\circ;
  • yaw 0∘0^\circ, pitch 90∘90^\circ, roll −20∘-20^\circ.

Both have ϕ−ψ=−20∘\phi-\psi=-20^\circ. You cannot infer yaw and roll separately from the orientation at this pitch. There are infinitely many angle pairs with the same difference and therefore the same rotation matrix.

What gimbal lock does—and does not—mean

Gimbal lock does not mean that the object is unable to rotate about one direction. It means that the chosen three numbers are no longer unique or well-behaved coordinates for orientation at that pose. The orientation still exists, and the object can still move in any direction.

It also does not mean that every Euler-angle convention locks at the same numerical angles. In a Tait–Bryan sequence such as ZYX, the middle angle reaches a right angle at the singularity. In a proper Euler sequence, which repeats the first axis (such as ZXZ), the singularities occur when the middle angle is 00 or π\pi. The underlying issue is the same: two axes coincide and the parameterization loses independence.

Common mistakes

  • Blaming the physical object: The singularity is in the coordinates, not in the object’s ability to turn.
  • Assuming every convention uses the same angles: The singular pose depends on the rotation sequence and convention.
  • Treating the angles as globally unique: Even away from gimbal lock, angles can wrap by full turns and multiple triples can represent the same orientation.
  • Thinking a different representation removes every issue: Unit quaternions avoid this particular coordinate singularity, but they use four numbers with a unit-length constraint and have a sign ambiguity: qq and −q-q represent the same rotation.

Euler angles remain useful when their sequence matches the application and singular poses can be avoided or handled. For calculations that need a smooth orientation representation across a broad range of poses, rotation matrices or unit quaternions are common alternatives.

References

  1. John B. Kuipers, Quaternions and Rotation Sequences: A Primer with Applications to Orbits, Aerospace, and Virtual Reality
  2. Herbert Goldstein, Charles Poole, and John Safko, Classical Mechanics

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.