# Euler Angles - Gimbal lock, why non-orthogonal axes

Already asked this question on mathexchange but didn't got any promising answers so posting it here Since I'm from a CG background.

I really can't understand how and why gimbal lock occurs using euler angles. First of all let me clear this "I know that gimbal lock occurs when 2 gimbals/axes coincide thus losing 1 degree of freedom"

However what I'm interested in why the axes are coinciding in the first place when they are supposed to remain perpendicular when we move anyone.

According to wikipedia here :

The general problem of decomposing a rotation into three composed movements about intrinsic axes was studied by P. Davenport, under the name "generalized Euler angles", but later these angles were named "Davenport angles" by M. Shuster and L. Markley.

Davenport proved that any orientation can be achieved by composing three elemental rotations using non-orthogonal axes.

That's what I want to hear about more. Why "non-orthogonal" ? I can't see any problems with making the axes orthogonal? What does making the axes non-orthogonal give us?

2) After the above one has been answered. How is this all tied up to rotational matrices? How can we achieve gimbal lock through the matrices when they only rotate a given point/vector around global axis. For example If i multiply a column vector with a Rotation matrix around X-axis Rx and then with Ry It will rotate around the global X-axis first, then global Y-axis second. So how can I achieve the lock situation using matrices?

EDIT:- To make it more clear I've also heard about rotation orders like in the order Y-Z-X when Y axis rotates then Z and X rotate with it but when Z rotates only X rotates with it. thus making the axes non-orthogonal. I am assuming that's what it means by non-orthogonal mentioned in the wiki article. Here is a picture.

As you can see in the Y-Z-X order, the Y axis remains there as in 3rd picture causing the axes to coincide...

• @joojaa - I saw that question. But the answers still don't answer how or why exactly the axes coincide when they are supposed to remain perpendicular. Or if is it related to non-ortho axes mentioned in the OP. Why are we using a non-ortho frame. – gallickgunner Feb 9 '18 at 16:50
• @joojaa - that's what I want to see with the coordinate frame. Show me a situation where I end up with a rotation repeating another rotation? For this to happen in a physical gimbal the rings must coincide, hence for this to happen with a coordinate frame the axes must coincide. If the axes aren't coinciding as you say, then the gimbal lock never happens as all 3 axes point in different directions maintaining the 3 degrees of freedom. – gallickgunner Feb 9 '18 at 17:20
• @joojaa - Every time some one asks this question people start giving examples and pictures of "physical gimbal". I'm asking you to restrict yourself to a coordinate frame even though I know that the concept originated from the physical gimbal. I can understand what's happening in the physical gimbal but not in the coordinate frame. In the picture it says rotation direction is lost but "HOW" is it happening when the 3 coordinate axes don't coincide according to you? – gallickgunner Feb 10 '18 at 10:42
• – joojaa Feb 10 '18 at 10:52

OK I think I know what your problem is, gimbal lock does not really lock anything from a mathematical point if view, only for certain operations. See euler suggested that euler angles can define all space angles. And that is true. Its just that euler does not say that the space is uniform. Highly mathematical people also say that the euler space has impossible solutions since some positions are overlapping, but in practice this is not really a problem.

Now since you can reach any angle, and you can always unwind your angle you can reach any angle in the body. Provided that your ready to unravel the situation and start over for a computer program doing animation and a mathematician this seems reasonable.

However, this is not what most people are doing. Instead if you try to do some physical things like calculating the distance between 2 positions, the energy needed to rotate, use a external force to move the system or make a delta move in the gimbals space then this non uniformity kicks in. Simply the space is not uniform the same way that a real space is at the poles the distance to a position next to you in real space can be surprisingly far away in Euler rotation space.

So when somebody is euler locked it does not mean they can not move anywhere they just can not move in the direction they would want to move in that particular orientation of the gimbal, and close to it. Its a bit like living in the suburbs and wanting to reach your neighbors house (that is 100 m away) but being forced to go trough the center of the city (15 km away). Energetically or time wise highly wasteful.

This is a problem in 3D graphics only if you choose to interpolate in Euler angles. But for a control engineer or a mechanical engineer this can be a nightmare, since you can suddenly have a discrepancy between what your mechanism and your control logic is saying.

Now it is possible to construct the gimbal so that the pole does not really happen, just not with the orthogonal axes the space is still not uniform but it does not experience the extreme case. However it might just be easier to use some other formulation like quaternionions, or axis angle instead. (quaternionions aren't really practical if your building a real mechanism though, its possible but very convoluted)

PS: I would draw an image, its just that drawing something the wraps perfectly upon itself and is a 3d field is a bit difficult to do.

• Ok wait. your post was helpful but I think I finally understand. Will post my own answer shortly. – gallickgunner Feb 10 '18 at 14:01

So thanks to joojaa I finally got a hint, and I searched on the net further and found this link which cleared all the doubts and has my answer. Though I am still posting it here as a summary.

So anyone reading this and who has similar problem to mine here is what I understood. Suppose we are considering the tait-bryan angle order X-Y-Z that is rotate first along X then Y and finally Z. Also to make it clear we are rotating around the "fixed" axes since a rotation matrix always rotates around the fixed axes. The matrix doesn't know anything about the axes moving or anything.

So suppose I have my initial frame like in my picture (original post) leftmost. If I use Ax with angle = 90 degrees then my Y axis becomes Z and Z becomes -Y. However if I now rotate with Ay the matrix will still be rotating around the previous/original fixed Y axis.

Now that's clear take this plane as an example. We want to rotate in the order X-Y-Z.

If we rotate around the X-axis we can see that the plane will either roll left or right. Suppose we rotate a little around the X-axis and then rotate around Y-axis so that it is pointing straight up like this

Now we have to rotate around Z as this is the last in the order. But notice that the rotation around Z is similar to the previous rotation we performed around X. The plane will roll either towards the left or right. This means we lost 1 degree of freedom. I think this is what joojaa was trying to explain to me. So everywhere where people are saying the axis coincide its the local, moving frame coinciding with the original frame. Initially both the local and global frames are coinciding. In this case when we rotated around Y by 90 the local moving X-axis collapsed on to the fixed original Z- axis causing this gimbal lock