<p>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.</p>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<p>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)</p>

<p>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.</p>

CC BY-SA 3.0
2018-02-10T14:01:25.413Z
Ok wait. your post was helpful but I think I finally understand. Will post my own answer shortly.
gallickgunner
CC BY-SA 3.0
2018-02-10T13:26:35.587Z
2018-02-10T13:34:01.327Z
2018-02-10T13:34:01.327Z
joojaa
<p>So thanks to joojaa I finally got a hint, and I searched on the net further and found <a href="https://matthew-brett.github.io/transforms3d/gimbal_lock.html" rel="noreferrer">this link</a> which cleared all the doubts and has my answer. Though I am still posting it here as a summary.</p>

<p>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.</p>

<p><a href="https://i.sstatic.net/agrEP.png" rel="noreferrer"><img src="https://i.sstatic.net/agrEP.png" alt="enter image description here"></a></p>

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

<p>Now that's clear take this plane as an example. We want to rotate in the order X-Y-Z.
<a href="https://i.sstatic.net/5jGNQ.png" rel="noreferrer"><img src="https://i.sstatic.net/5jGNQ.png" alt="enter image description here"></a></p>

<p>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 <code>Y-axis</code> so that it is pointing straight up like this</p>

<p><a href="https://i.sstatic.net/7cgdo.png" rel="noreferrer"><img src="https://i.sstatic.net/7cgdo.png" alt="enter image description here"></a></p>

<p>Now we have to rotate around Z as this is the last in the order. But notice that the rotation around <code>Z</code> is similar to the previous rotation we performed around <code>X</code>. 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 <code>Y</code> by 90 the local moving X-axis collapsed on to the fixed original <code>Z</code>- axis causing this gimbal lock </p>

CC BY-SA 4.0
2022-04-04T03:52:38.520Z
There is the same question about is, https://blender.stackexchange.com/questions/469/could-someone-please-explain-gimbal-lock 
But the answer's video I can't understand. Why do we need to parent the z-axis to the x-axis, and parent the x-axis to the y-axis? I think this is the key point
Liu Hao
CC BY-SA 4.0
2022-04-07T09:18:34.257Z
@Liu Hao - The concept of parenting seems to clear up if you start thinking of ordered rotations. Let's say `X-Y-Z`. Think of the gimbals as they are being used to preserve the way rotation around an axis was supposed to originally move the object. For e.g, in the picture of plane, Rotation around X causes it to roll. Since X is the first in the order it doesn't affect anybody. Once we applied X, that orientation is fixed. So now when you move Y, the gimbal of X moves with it in-order to preserve the way Rotation around X was supposed to move the plane.
gallickgunner
CC BY-SA 4.0
2022-04-07T09:22:04.793Z
If you however, think solely in terms of singular individual non-ordered rotations. You can always find an axis to apply the rotation to get the desired result. The problem lies with ordered rotations since the order has been determined pre-hand. This determining of the order leads to an apparent sense of loss of freedom since you were supposed to Rotate around X again after `X-Y` if you wanted the original rotation around Z. But since the order was fixed pre-hand, you basically lost that degree of freedom due to axes or more specifically "ways of rotation" collapsing onto each other
gallickgunner
CC BY-SA 4.0
2022-11-11T23:29:05.900Z
I think the problem is not that one is missing, but rather that there is one too many. All rotations can be represented by at least one set of Euler angles, so there isn't a shortage of degrees of freedom.
Criticize SE actions means ban
CC BY-SA 3.0
2018-02-10T17:17:31.187Z
2018-02-10T17:17:31.187Z
gallickgunner
<p>Already asked this question on mathexchange but didn't got any promising answers so posting it here Since I'm from a CG background.</p>

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

<p>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.</p>

<p>According to wikipedia <a href="https://en.wikipedia.org/wiki/Davenport_chained_rotations" rel="nofollow noreferrer">here</a> :</p>

<blockquote>
  <p>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.</p>
  
  <p>Davenport proved that any orientation can be achieved by composing
  three elemental rotations using <strong><em>non-orthogonal axes</em></strong>.</p>
</blockquote>

<p>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?</p>

<p>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 <code>Rx</code>  and then with <code>Ry</code> It will rotate around the global X-axis first, then global Y-axis second. So how can I achieve the lock situation using matrices?</p>

<p>EDIT:- 
To make it more clear I've also heard about rotation orders like in the order <code>Y-Z-X</code> when Y axis rotates then <code>Z</code> and <code>X</code> rotate with it but when <code>Z</code> rotates only <code>X</code> 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.</p>

<p><a href="https://i.sstatic.net/FejAW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FejAW.png" alt="enter image description here"></a></p>

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

CC BY-SA 3.0
2018-02-09T16:50:39.503Z
@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
CC BY-SA 3.0
2018-02-09T17:20:07.667Z
@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
CC BY-SA 3.0
2018-02-10T10:42:34.173Z
@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
CC BY-SA 3.0
2018-02-10T10:52:00.943Z
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/72953/discussion-between-joojaa-and-wandering-warrior).
joojaa
CC BY-SA 4.0
2021-04-11T16:20:37.697Z
The question is, even if there is a gimbal lock , what effect will cause ? You can always adjust your rotation to make the plane rotate as what you want. You don't need quaternion.
arthur dent
<geometry>
Euler Angles - Gimbal lock, why non-orthogonal axes
gallickgunner
# Euler Angles - Gimbal lock, why non-orthogonal axes

(Asked by: username_0 on 2018-02-07)

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](https://en.wikipedia.org/wiki/Davenport_chained_rotations) :

> 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.

[![enter image description here](https://i.sstatic.net/FejAW.png)](https://i.sstatic.net/FejAW.png)

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

**Tags:** geometry

> **Comments:**
> **username_0**: @username_1 - 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.  
> **username_0**: @username_1 - 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.  
> **username_0**: @username_1 - 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?  
> **username_1**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/72953/discussion-between-username_1-and-wandering-warrior).  
> **username_2**: The question is, even if there is a gimbal lock , what effect will cause ? You can always adjust your rotation to make the plane rotate as what you want. You don't need quaternion.  

---

## 2 answers

### Answer by username_1 on 2018-02-10. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_0**: Ok wait. your post was helpful but I think I finally understand. Will post my own answer shortly.  

---

### Answer by username_0 on 2018-02-10. Score: 5

So thanks to username_1 I finally got a hint, and I searched on the net further and found [this link](https://matthew-brett.github.io/transforms3d/gimbal_lock.html) 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.

[![enter image description here](https://i.sstatic.net/agrEP.png)](https://i.sstatic.net/agrEP.png)

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.
[![enter image description here](https://i.sstatic.net/5jGNQ.png)](https://i.sstatic.net/5jGNQ.png)

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

[![enter image description here](https://i.sstatic.net/7cgdo.png)](https://i.sstatic.net/7cgdo.png)

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 username_1 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

> **Comments:**
> **username_3**: There is the same question about is, https://blender.stackexchange.com/questions/469/could-someone-please-explain-gimbal-lock  But the answer's video I can't understand. Why do we need to parent the z-axis to the x-axis, and parent the x-axis to the y-axis? I think this is the key point  
> **username_0**: @username_3 - The concept of parenting seems to clear up if you start thinking of ordered rotations. Let's say `X-Y-Z`. Think of the gimbals as they are being used to preserve the way rotation around an axis was supposed to originally move the object. For e.g, in the picture of plane, Rotation around X causes it to roll. Since X is the first in the order it doesn't affect anybody. Once we applied X, that orientation is fixed. So now when you move Y, the gimbal of X moves with it in-order to preserve the way Rotation around X was supposed to move the plane.  
> **username_0**: If you however, think solely in terms of singular individual non-ordered rotations. You can always find an axis to apply the rotation to get the desired result. The problem lies with ordered rotations since the order has been determined pre-hand. This determining of the order leads to an apparent sense of loss of freedom since you were supposed to Rotate around X again after `X-Y` if you wanted the original rotation around Z. But since the order was fixed pre-hand, you basically lost that degree of freedom due to axes or more specifically "ways of rotation" collapsing onto each other  
> **username_4**: I think the problem is not that one is missing, but rather that there is one too many. All rotations can be represented by at least one set of Euler angles, so there isn't a shortage of degrees of freedom.  

---

