I was studying about Euler angles and I came across the problem gimbal lock which can occur by using Euler angles. In gimbal lock we lose one axis of rotation.

But how? And when does it happen? On what conditions?

All I know about Euler angles is that rotation always occurs about the object axes not upright axes (axes whose orientation is always the same as the world axes). And the object axes will remain perpendicular to each other in each rotation.

Could someone use Euler angles and show me how to get to that point of gimbal lock?

How can it affect animations?


2 Answers 2


Rotations in 3D are normally done with matrices. The xyz Euler angles can be converted to matrices so that it can be used in the rotation. That is where something called rotation order comes in. Basically it says in what order you rotate the object. First you rotate the object around the x axis, then the y axis and lastly the z axis for example.

This means that when you rotate the object around the x axis first, you change the way the y axis and z axis rotate. Of course this changes depending on the rotation order.

This GIF shows how changing one axis value can change the others, but it doesn't work that way for everything.

gimbal lock

Here you can also see at the end that I add in that gimbal lock. This is where I lose one axis of rotation.

This could be fixed by changing the rotation order to an order, where it doesn't break the way it should work. It could also be fixed by not using Euler angles but Euler angles are handy and simple in 3D animation.

In 3D animation it could lead to weird rotations since the values of the rotations have to be changed a lot to get a certain rotation that you want. If you would look at the xyz Euler angle values in a graph, you would see spikes because of that. This could lead to weird interpolation of the keyframes and a weird end result.

If you would like to read more about the math behind it, I would recommend reading about rotation matrices in 3D. https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations

A little extra explanation for the animation: Rotation in this case is around axis (shown as circles) and by rotating on one axis, you rotate the other axis. The consequence is that with a normal rotation sphere (the sphere in the animation, but then without the axis being rotated) in the animation, you don't see these axis being rotated. If you get a gimbal lock, one axis is the same as another one, but with a normal rotation sphere it still tries to rotate as if that axis wasn't the same as another one, this means that it uses weird values to get to that rotation and this can make an animation look weird.

I hope this helps!

  • $\begingroup$ I can't tell from the animation what the specific causes and consequences of the gimbal lock are. Could you explain more about what happens and whether it is reversible? $\endgroup$ Commented Dec 30, 2016 at 12:11
  • 2
    $\begingroup$ Oh sorry, rotation in this case is around axis (shown as circles) and by rotating on one axis, you rotate the other axis. The consequence is that with normal rotation sphere (the sphere in the animation) in animation, you don't see these axis being rotated, so if you get a gimbal lock, one axis is the same as another one, but with a normal rotation sphere it still tries to rotate as if that axis wasn't the same as another one, this means that it uses weird values to get to that rotation. I thought that the full post made that clear and that Ankit had some knowledge about it, @trichoplax $\endgroup$
    – bram0101
    Commented Dec 30, 2016 at 14:58
  • $\begingroup$ For me, the extra explanation in your comment makes a big difference, so it might be worth editing it into the answer for future readers (comments aren't guaranteed to stay around). $\endgroup$ Commented Dec 30, 2016 at 15:16
  • $\begingroup$ Gimbal lock has nothing to do with matrices. $\endgroup$
    – joojaa
    Commented Dec 30, 2016 at 19:32
  • 1
    $\begingroup$ @bram0101 sure. Or you can actually not think so abstractly and think of it as actual physical 3 axis gimbal $\endgroup$
    – joojaa
    Commented Dec 30, 2016 at 22:27

A gimbal is a pivoted support that allows you to rotate around one axis. Now it so happens that Euler rotations* work like a set of 3 gimbals attached to each other, one rotation builds upon the next (or previous/whole stack if your inclined to model it that way).

enter image description here

Image 1: Rotation is like a gimbal. Model using yxz rotation (z=blue, x= red and y=green) in a physical 3 axis gimbal structure.

A gimbal lock happens when you turn 2 or 3 of the successive gimbals and they align onto a plane. You succeed in erasing one direction since the angles both operate same same direction.

enter image description here

Image 2: Rotation direction lost because 2 of the rotations overlap.

The only way out is to unwind the structure. Although this is the lock, problems due to diminishing possibilities to turn start earlier than the lock itself.

A more in depth look at things

Now this is where most people stop thinking about the issue and move on with their life. They just conclude that Euler angles are somehow broken. This is also where a lot of misunderstandings happen so it's worth investigating the matter slightly further than what causes gimbal lock.

It is important to understand that this is only problematic if you interpolate in Euler angles**! In a real physical gimbal this is given - you have no other choice. In computer graphics you have many other choices, from normalized matrix, axis angle or quaternion interpolation. Gimbal lock has a much more dramatic implication to designing control systems than it has to 3d graphics. Which is why a mechanical engineer for example will have a very different take on gimbal locking.

You don't have to give up using Euler angles to get rid of gimbal locking, just stop interpolating values in Euler angles. Of course, this means that you can now no longer drive a rotation by doing direct manipulation of one of the channels. But as long as you key the 3 angles simultaneously you have no problems and you can internally convert your interpolation target to something that has less problems.

Using Euler angles is just simply more intuitive to think in most cases. And indeed Euler never claimed it was good for interpolating but just that it can model all possible space orientations. So Euler angles are just fine for setting orientations like they were meant to do. Also incidentally Euler angles have the benefit of being able to model multi turn rotations which will not happen sanely for the other representations.

Problems and how to circumvent them

The fact of the matter is that interpolating in Euler angle space is a bad idea, in general and affects you way before you come close to a true gimbal lock. For this reason NASA lunar orbiter would warn of gimbal lock when you come close to a 70-80 degree angle on a single gimbal's turn. So be aware that people do not necessarily talk of just the actual locking condition when they talk of a gimbal lock. Even worse some people blame all their rotation problems on gimbal locking.

Euler rotation is only safe if you rotate primarily one angle and shallow amounts on the other 2 rotations, which is quite common admittedly. This works fine for describing movement of a commercial airliner, a car etc. But not so well for a jet fighter or an acrobatics plane doing complex air maneuvers. What happens is the rotations start to interfere with each other and you get a weird wobble instead of moving straight from one position to the next.

To fix the wobble problem in shallow cases just swap the rotation order so that the big rotation gets applied on the other rotations. If you need to use more complex rotations then either switch over to other interpolation methods or add even more rotation links to your gimbal (which is a good stopgap measure for cases where you cannot do the switch in a timely manner).

* To be exact most of the time people do not actually use Euler angles but Tait–Bryan angles. Which are nearly the same thing only Euler insisted on repeating the same axis, not very important distinction but good to know if you ever speak to an academic.

** Oh well, if you use Euler–Lagrange equation it won't matter.

  • 5
    $\begingroup$ finally someone saying that gimbal lock is not due to euler angles. Saying that quaternions aren't affected by gimbal lock for example is silly, since when you express a rotation sequence with them (or with rotation matrices for that matter) you get the same exact problem (because both representations are expressed in terms of euler angles). Is the ability to do spherical interpolation from one orientation to another that is correct. $\endgroup$
    – Luca
    Commented Nov 8, 2019 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.