<blockquote>
<p>its not how I understand aircraft mechanics to work</p>
</blockquote>
<p>Good, because they aren't supposed to.</p>
<p>The aircraft in these examples are just models that have a well-defined front and up. They could be any model or even no model at all, just a set of coordinate axes. The point is to show the behavior of the <em>gimbals</em>, to show that no change of the yaw/pitch/roll gimbals array are able to orient the model along the locked-out axis.</p>
<p>Aircraft fly based on aerodynamics, not mechanical structures wrapped around the plane that orient it. You're taking an analogy literally when you aren't supposed to.</p>

CC BY-SA 4.0
2022-08-21T02:41:25.633Z
The issue I have is when a 3D model is rotated up 90deg (for example in the images), why does it not rotate the Z axis as well and perform sequenced rotations on the intermediate frames in between? Seems like only child axes are rotated, which I don't get why 3D software would do that and not rotate the body-fixed frame?
pstatix
CC BY-SA 4.0
2022-08-21T03:25:00.243Z
@pstatix: "*rotate the Z axis*" Which "Z axis"? The job of a rotation is to rotate the thing it rotates. The Z axis of the model being rotated was in fact... rotated. It did its job. "*I don't get why 3D software would do that and not rotate the body-fixed frame?*" What does "body-fixed frame" mean? Do you mean to rotate around the axis of the object? If so... which axis? Each of the three rotations *changes* the axes. And they do so in a fixed order.
Nicol Bolas
CC BY-SA 4.0
2022-08-21T11:34:50.327Z
@pstatix It is because they are modeling a system of gimbals. If you wish for the axes to rotate too, then instead of incrementing angles: $pitch += \Delta pitch, \, yaw += \Delta yaw, \, roll += \Delta roll$ and then building the rotation as: $R = R_z(roll) R_y(yaw) R_x(pitch)$, you should use: $R = R_z(\Delta roll) R_y(\Delta yaw) R_x(\Delta pitch)R$, where R is the previous state of the rotation matrix.
lightxbulb
CC BY-SA 4.0
2022-08-21T23:24:32.540Z
@lightxbulb So perhaps you can explain why 3D software (or at least all the examples I've found about gimbal lock and software) models motion using gimbals? If they are using Euler angles for this, why not start with $R_a$ as the initial XYZ frame, then rotate any axis and store that next state in $R_b$, then apply the next rotation and get $R_c$ and so on and so forth? 1/2
pstatix
CC BY-SA 4.0
2022-08-21T23:26:35.043Z
To me it seems so silly/odd that a single model would have an XYZ axis frame associated with it, but be bound by having gimbals as the rotation system. You could yaw around the $Z$ axis of the frame, and that would change where $X$ and $Y$ are pointing as a normal ZYX ordered gimbal; in addition, using that say XYZ axis frame, you could first pitch up 90 degrees around the $Y$ axis, and that would change where $Z$ and $X$ are pointing. This notion that software uses gimbals to model motion is what really confuses me about this whole topic. 2/2.
pstatix
CC BY-SA 4.0
2022-08-21T23:30:30.963Z
@NicolBolas Suppose you have an aircraft model in software oriented level and flying north such that the $X$ axis extends tail to nose, the $Y$ axis extends from wing to wing and the $Z$ axis is perpendicular to the tail and $X$ axis (as shown in my first image). According to everything I have seen here and elsewhere, making a 90 degree rotation around $Y$ only changes where the $X$ axis points, and does not rotated the $Z$ axis. 1/2
pstatix
CC BY-SA 4.0
2022-08-21T23:32:19.903Z
@NicolBolas This seems counter intuitive, why would the $Z$ axis not rotate as well as depicted in my second image? Thus allowing the model to yaw appropriate and not behave like a roll on the $X$ axis? Surely software today can do a rotation around a single axis, save that new XYZ orientation, perform the second rotation around an axis, save that orientation, and so on? Why are models beholding to gimbals that behave in this chained order way? 2/2.
pstatix
CC BY-SA 4.0
2022-08-21T23:45:59.080Z
@pstatix: "*explain why 3D software [...] models motion using gimbals?*" They don't model "motion"; they model *orientation*. YPR is easy for people to conceptualize, but not easy for them to use to animate a thing. Most modelling software can let you reach into the model and drag its orientation around, so what it uses to represent that orientation only matters for interpolation between orientations.
Nicol Bolas
CC BY-SA 4.0
2022-08-21T23:48:50.603Z
@pstatix: "*Surely software today can do a rotation around a single axis, save that new XYZ orientation, perform the second rotation around an axis, save that orientation, and so on?*" Nobody said that they couldn't. But that's not how YPR orientation works. You're basically asking, "why is this orientation scheme that is susceptible to gimbal lock used in examples of gimbal lock?" Your question kind of answers itself.
Nicol Bolas
CC BY-SA 4.0
2022-08-22T00:09:03.983Z
@pstatix "perhaps you can explain why 3D software models motion using gimbals?" - that's not a question I can answer, you will have to ask the authors of the specific software/examples you are referring to. It's a design decision for a human-computer interface so it's not like there is an objectively correct choice either. My perspective is more formal: if you want to model a system of gimbals, then you rebuild the rotation matrix each time by chaining rotations and incrementing their angles. If you want to model incremental rotations that are not fixed to a static system of gimbals, 1/2
lightxbulb
CC BY-SA 4.0
2022-08-22T00:16:48.183Z
@pstatix then you can keep track of the axes (arranged in your rotation natrix $R$) and then compose that matrix with the delta rotations to get the desired result. Personally if I were to model controls for a plane I would model it using a joystick (again using incremental rotations, but there's also a nice formula there without chained rotations), such that the plane always aligns so that its local up vector aligns with the joystick's axis, and rotating the joystick around its axis would provide the third degree of freedom. 2/2
lightxbulb
CC BY-SA 4.0
2022-08-22T19:59:37.017Z
@lightxbulb the reason its modeled thisway is more to do with navigation and air trafic control. The plane controls are not probably modeled thisway. The reason for this is that a commercial plane will probably not pitch more than 60 angle and probably also not roll more than 30. This makes communication of tracking relatively easy to communicate with radio. It also nicely explains the flight characteristics and control surfaces inner workings within the bounds with simplified models. Yeah it does probably not model acrobatic situations very well but thats hardly a problem for most situations.
joojaa
CC BY-SA 4.0
2022-08-22T20:06:40.633Z
See the flight dynamics like lift and so on are relative to the horisontal 'plane'. So probably easier to calculate, been a while since i did this kind of stuff. But atleast my multibody books had the dynamics developped for euler angles, probably for legacy reasons. I once saw a energy balancing development for quats, but even the euler derivation was insane, the quat one was really really long. So its probably more to do that the work has been done allready. Its a bit similar how engineers know how to calculate beam bending for large angles but still largely use small angles simplification.
joojaa
CC BY-SA 4.0
2022-08-22T20:13:25.060Z
The gimbal lock also does not really play a role in larangian dynamics simulation as it sidesteps the problem. So one derived it does not lock up to my understanding. Its a bit on the edge of what i did in my studies but i did derive it once.
joojaa
CC BY-SA 4.0
2022-08-22T20:15:34.987Z
@joojaa This provides some context, so I guess they probably just copied this regardless of the fact that it is not a good model for a flight simulation. In a flight simulator I would keep the orthonormal basis of the airplane $r,u,f$, and would sample the flight stick's direction vector $f'$ (normalized), then one may compute the new vectors: $r' = r - \frac{(r\cdot f')}{1+(f\cdot f')}(f+f')$ and $u' = u-\frac{(u\cdot f')}{1+(f\cdot f')}(f+f')$ for the new orthonormal basis $r', u', f'$. The only singularity is for $f' = -f$, however this is physically impossible with an actual joystick.
lightxbulb
CC BY-SA 4.0
2022-08-22T20:17:16.570Z
@lightxbulb its a good model for the simulation. The results can then just be translated as quata for the animation and directions.
joojaa
CC BY-SA 4.0
2022-08-22T20:18:06.157Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/138695/discussion-between-lightxbulb-and-joojaa).
lightxbulb
CC BY-SA 4.0
2022-08-19T04:06:10.030Z
2022-08-19T04:06:10.030Z
Nicol Bolas
<p>Summary taken from my original question and answer <a href="https://computergraphics.stackexchange.com/questions/6233/euler-angles-gimbal-lock-why-non-orthogonal-axes">here</a>..</p>
<p>First of all as Nicol suggested you are mixing up the reality with how computers or the mechanics of the gimbals work. You are taking an analogy literally.</p>
<p>If we scratch the whole concept of gimbals and see how rotations work in terms of maths, the idea is quite simple. The rotations around the 3 axes are described by the matrices..</p>
<p><a href="https://i.sstatic.net/agrEP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/agrEP.png" alt="enter image description here" /></a></p>
<p>Note however, that these matrices don't know the difference between global and local axes. By global, I mean axes that remain fixed in space no matter the rotations applied and the local are axes/frame fixed with the body so it moves accordingly. So when it comes down to math the rotation matrix is going to change the values in the same way it was doing the first time. So for e.g if we apply a <span class="math-container">$A_{x}({90^{\circ}})$</span> to a standard frame like in your first picture, it'd move the <span class="math-container">$Y$</span> axis to <span class="math-container">$Z$</span> and <span class="math-container">$Z$</span> to <span class="math-container">$-Y$</span> assuming counter-clockwise rotation for right handed system. Now if you apply a <span class="math-container">$A_{y}({u^{\circ}})$</span> with a random angle, the matrix is still gonna rotate around the previous <span class="math-container">$Y$</span> which is currently the local <span class="math-container">$-Z$</span> not the new local <span class="math-container">$Y$</span> axis.</p>
<p>This is because matrix multiplication only modifies the respective columns/rows. If Y-axis was in the middle column at the beginning and then after a rotation the middle column values changed to Z-axis <span class="math-container">$(0,0,1)$</span> that doesn't mean it's going to rotate around the Z-axis next. Graphically speaking the rotation is still around the global Y-axis no matter what the values of the middle column are. If you have trouble understanding this try doing what I explained on a piece of paper and you'll see what I mean.</p>
<p>Moving on, once you understand that, the second concept to understand is that euler angles work with chained rotations. So stuff like <span class="math-container">$x-y-z$</span> or <span class="math-container">$z-y-z$</span>. The key thing to note is that the concept of gimbal lock appears after you apply 1 or 2 of those rotations in order <em>within</em> a specific chained rotation, say <span class="math-container">$x-y-z$</span>. This is important because if you forget this you are gonna ask the question &quot;Well, why can't we just move the other axes?&quot; You can't because you are following a specific order of three chained rotations and you have already done the first one or two rotations.</p>
<p>That being said, now you can imagine an aeroplane with the orientation</p>
<p><a href="https://i.sstatic.net/5jGNQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5jGNQ.png" alt="enter image description here" /></a></p>
<p>Note here, that if you rotate around the <span class="math-container">$X$</span> you'll either roll left/right. Assume we are following the order <span class="math-container">$x-y-z$</span>. Next assume we rotated around the <span class="math-container">$X$</span> axis a little so we can see the plane's bottom and then rotated <span class="math-container">$90$</span> degrees around the <span class="math-container">$Y$</span>. This is how it'd look like</p>
<p><a href="https://i.sstatic.net/7cgdo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7cgdo.png" alt="enter image description here" /></a></p>
<p>Now here's the gimbal lock. If you try to rotate around the <span class="math-container">$Z$</span> axis it's the same rotation back when you were rotating around the <span class="math-container">$X$</span>. That is, the plane is only rolling. We lost 1 degree of freedom.</p>
<p>You might be thinking well but now, rotation around the <span class="math-container">$X$</span> rotates differently so we haven't lost any freedom at all. True but that's thinking again outside the concept of the chained rotation order. We have already done rotation around <span class="math-container">$X$</span> and <span class="math-container">$Y$</span> so the order only leaves us <span class="math-container">$Z$</span> but due to a certain angle of rotation around the <span class="math-container">$Y$</span> we can't uniquely rotate it in the third dimension. That's the gimbal lock. If you break free from the order, then it's really hard to perceive the idea of the loss of the degree of freedom.</p>
<p>In applied mathematics terms, this is what's happening...</p>
<p>We have our rotation order <span class="math-container">$x-y-z$</span> with the corresponding angles <span class="math-container">$\alpha-\beta-\gamma$</span>,</p>
<p><span class="math-container">$$
R = 
\begin{bmatrix}
\cos \gamma &amp; -\sin \gamma &amp; 0 \\
\sin \gamma &amp; \cos \gamma &amp; 0 \\
0 &amp; 0 &amp; 1 
\end{bmatrix}
\begin{bmatrix}
\cos \beta &amp; 0 &amp; \sin \beta \\
0 &amp; 1 &amp; 0 \\
-\sin \beta &amp; 0 &amp; \cos \beta
\end{bmatrix}
\begin{bmatrix}
1 &amp; 0 &amp; 0 \\
0 &amp; \cos \alpha &amp; -\sin \alpha \\
0 &amp; \sin \alpha &amp; \cos \alpha 
\end{bmatrix}
$$</span></p>
<p>Now just to explain what's really going on we skip applying the first rotation and directly rotate 90 degrees around <span class="math-container">$Y$</span> which would be <span class="math-container">$\beta = 90$</span></p>
<p><span class="math-container">$$
R = 
\begin{bmatrix}
\cos \gamma &amp; -\sin \gamma &amp; 0 \\
\sin \gamma &amp; \cos \gamma &amp; 0 \\
0 &amp; 0 &amp; 1 
\end{bmatrix}
\begin{bmatrix}
0 &amp; 0 &amp; 1 \\
0 &amp; 1 &amp; 0 \\
-1 &amp; 0 &amp; 0 
\end{bmatrix}
\begin{bmatrix}
1 &amp; 0 &amp; 0 \\
0 &amp; \cos \alpha &amp; -\sin \alpha \\
0 &amp; \sin \alpha &amp; \cos \alpha
\end{bmatrix}
$$</span></p>
<p><span class="math-container">$$
R = 
\begin{bmatrix}
\cos \gamma &amp; -\sin \gamma &amp; 0 \\
\sin \gamma &amp; \cos \gamma &amp; 0 \\
0 &amp; 0 &amp; 1 \end{bmatrix}
\begin{bmatrix}
0 &amp; \sin \alpha &amp; \cos \alpha \\
0 &amp; \cos \alpha &amp; -\sin \alpha \\
-1 &amp; 0 &amp; 0 \end{bmatrix}
$$</span></p>
<p>Now multiplying these, we get,</p>
<p><span class="math-container">$$
R = 
\begin{bmatrix}
0 &amp; \cos\gamma * \sin\alpha -\sin \gamma * \cos\alpha &amp; \cos\gamma * \cos\alpha + \sin \gamma * \sin \alpha \\
0 &amp; \cos\gamma * \cos\alpha + \sin \gamma * \sin \alpha &amp; -\cos\gamma * \sin\alpha +\sin \gamma * \cos\alpha \\
-1 &amp; 0 &amp; 0 \end{bmatrix}
$$</span></p>
<p><span class="math-container">$$
R = 
\begin{bmatrix}
0 &amp; \sin(\alpha - \gamma) &amp; \cos(\alpha - \gamma) \\
0 &amp; \cos(\alpha - \gamma) &amp; -\sin(\alpha - \gamma) \\
-1 &amp; 0 &amp; 0 \end{bmatrix}
$$</span></p>
<p>As you can see, changing either <span class="math-container">$\alpha$</span> or <span class="math-container">$\gamma$</span> here gives us the same matrix. Which means rotation around the <span class="math-container">$X$</span> or the <span class="math-container">$Z$</span> axis gives us the same result resulting in a loss of 1 degree of freedom.</p>
<p>Personally speaking all those images of gimbals always confused the hell out of me. For a graphics guy it'd have been much more clearer if people explained it more in terms of applied mathematics i.e. Matrices and such and used the diagrams of perpendicular axes instead of gimbals.</p>
<p>What the artiles explaining this concept in terms of gimbals don't do is map the gimbal analogy to the axes analogy. In gimbals there is the concept of parenting. So moving the innermost or I guess the red gimbal in your case won't move the outer two. Moving the outermost will move the other two. This feels really confusing if you have the global/local axes analogy in mind and you are thinking of the gimbals as axes since here both local/global seem all mixed. The idea of the gimbals and parenting here is to preserve the way the previous rotation rotates the object so that when the gimbals align you can actually see that the previous and the new rotation rotate in the same way. So if we have the order <span class="math-container">$x-y-z$</span> The innermost gimbal would correspond to <span class="math-container">$x$</span>. Think of the gimbals appearing one by one after each rotation is applied and not being there from the start.</p>
<p>So considering my example of the plane, rotation around the <span class="math-container">$x$</span> does the rolling. The gimbal tied to it is the innermost. So that when you apply rotations around <span class="math-container">$y$</span> and <span class="math-container">$z$</span> the <span class="math-container">$x$</span> gimbal would move with them in order to preserve the rolling aspect.</p>

CC BY-SA 4.0
2022-11-12T09:53:24.260Z
+1 I read through your two answers and I think they are closely related to my question of not understanding gimbal lock.  I still don't get a qualitative understanding of why gimbal lock happens to an object and perhaps you can take a shot at answering my question there [How can a plane or an object gimbol lock itself](https://aviation.stackexchange.com/questions/95860/how-can-a-plane-or-an-object-gimbal-lock-itself)
KMC
CC BY-SA 4.0
2022-08-21T09:58:52.890Z
2022-08-21T09:58:52.890Z
gallickgunner
<p>I'm having difficult understanding the issue with gimbal lock, namely why so many diagrams show an aircraft in apparent gimbal lock unable to turn about an axis conventionally, using yaw/pitch/roll. For example, below are some diagrams depicting a common scene of gimbal lock.</p>
<p>In the first one, let us call it <strong>Frame A</strong> we start in a position where the Euler angles are all 0 and the aircraft is flying level:</p>
<p><a href="https://i.sstatic.net/V5hY7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/V5hY7.png" alt="enter image description here" /></a></p>
<p>Depicted are the gimbles aligned with their respective axis on the <strong>body frame</strong> denoted in yellow. Now, in the second image, we have pitched up 90 degrees, and we are in what, all resources I've found, is called gimbal lock:</p>
<p><a href="https://i.sstatic.net/f8rlF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/f8rlF.png" alt="enter image description here" /></a></p>
<p>If you notice the second graphic, called <strong>Frame B</strong>, the body frame has followed along and we can see the intermediate frame after the pitch. The y-gimble and the z-gimble are now aligned however, and adjusting yaw results in the same response as adjusting roll:</p>
<p><a href="https://i.sstatic.net/abAkk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/abAkk.png" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/kmT5g.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kmT5g.png" alt="enter image description here" /></a></p>
<p>But this is where to me that doesn't make any sense. If we refer back to <strong>Frame B</strong> and look at our body frame, the yellow, it indicates that a roll does what we see in the two images above as the x-axis, or roll axis, is extending through the nose, but the z-axis, or the yaw axis, is perpendicular. Thus, the aircraft should be able to yaw appropriately (given rudder control surfaces and thrust).</p>
<p>So why is it depicted here as if the body frame after <strong>Frame A</strong> is like so:</p>
<p><a href="https://i.sstatic.net/CKajO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CKajO.png" alt="enter image description here" /></a></p>
<p>With this axis that makes sense, but its not how I understand aircraft mechanics to work.</p>

CC BY-SA 4.0
2022-08-19T16:31:46.310Z
Yes aircrafts are not attached to a system of gimbals. Prople modeling aircraft orientation using gimbals are simply using the wrong mathematical model.
lightxbulb
CC BY-SA 4.0
2022-08-22T13:40:40.937Z
THis is a cross post form engineering.se: https://engineering.stackexchange.com/questions/52185/confusion-regarding-euler-rotations-and-gimbal-lock
joojaa
CC BY-SA 4.0
2022-08-22T14:29:13.903Z
@joojaa Yes its a cross post, but CG vs Engineering are two different fields of study. In the other post, the answer pertains to aerodynamics and my post here pertains to gimbals in a CG setting. There is nothing wrong with cross posting communities w.r.t. different fields of study...
pstatix
CC BY-SA 4.0
2022-08-22T14:31:31.783Z
@pstatix no but its a good idea to indicate that wish
joojaa
<transformations>
Confusion surrounding Gimbal Lock
pstatix
# Confusion surrounding Gimbal Lock

(Asked by: username_0 on 2022-08-19)

I'm having difficult understanding the issue with gimbal lock, namely why so many diagrams show an aircraft in apparent gimbal lock unable to turn about an axis conventionally, using yaw/pitch/roll. For example, below are some diagrams depicting a common scene of gimbal lock.

In the first one, let us call it **Frame A** we start in a position where the Euler angles are all 0 and the aircraft is flying level:

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

Depicted are the gimbles aligned with their respective axis on the **body frame** denoted in yellow. Now, in the second image, we have pitched up 90 degrees, and we are in what, all resources I've found, is called gimbal lock:

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

If you notice the second graphic, called **Frame B**, the body frame has followed along and we can see the intermediate frame after the pitch. The y-gimble and the z-gimble are now aligned however, and adjusting yaw results in the same response as adjusting roll:

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

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

But this is where to me that doesn't make any sense. If we refer back to **Frame B** and look at our body frame, the yellow, it indicates that a roll does what we see in the two images above as the x-axis, or roll axis, is extending through the nose, but the z-axis, or the yaw axis, is perpendicular. Thus, the aircraft should be able to yaw appropriately (given rudder control surfaces and thrust).

So why is it depicted here as if the body frame after **Frame A** is like so:

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

With this axis that makes sense, but its not how I understand aircraft mechanics to work.

**Tags:** transformations

> **Comments:**
> **username_1**: Yes aircrafts are not attached to a system of gimbals. Prople modeling aircraft orientation using gimbals are simply using the wrong mathematical model.  
> **username_2**: THis is a cross post form engineering.se: https://engineering.stackexchange.com/questions/52185/confusion-regarding-euler-rotations-and-gimbal-lock  
> **username_0**: @username_2 Yes its a cross post, but CG vs Engineering are two different fields of study. In the other post, the answer pertains to aerodynamics and my post here pertains to gimbals in a CG setting. There is nothing wrong with cross posting communities w.r.t. different fields of study...  
> **username_2**: @username_0 no but its a good idea to indicate that wish  

---

## 2 answers

### Answer by username_3 on 2022-08-19. Score: 3

> its not how I understand aircraft mechanics to work

Good, because they aren't supposed to.

The aircraft in these examples are just models that have a well-defined front and up. They could be any model or even no model at all, just a set of coordinate axes. The point is to show the behavior of the *gimbals*, to show that no change of the yaw/pitch/roll gimbals array are able to orient the model along the locked-out axis.

Aircraft fly based on aerodynamics, not mechanical structures wrapped around the plane that orient it. You're taking an analogy literally when you aren't supposed to.

> **Comments:**
> **username_0**: The issue I have is when a 3D model is rotated up 90deg (for example in the images), why does it not rotate the Z axis as well and perform sequenced rotations on the intermediate frames in between? Seems like only child axes are rotated, which I don't get why 3D software would do that and not rotate the body-fixed frame?  
> **username_3**: @username_0: "*rotate the Z axis*" Which "Z axis"? The job of a rotation is to rotate the thing it rotates. The Z axis of the model being rotated was in fact... rotated. It did its job. "*I don't get why 3D software would do that and not rotate the body-fixed frame?*" What does "body-fixed frame" mean? Do you mean to rotate around the axis of the object? If so... which axis? Each of the three rotations *changes* the axes. And they do so in a fixed order.  
> **username_1**: @username_0 It is because they are modeling a system of gimbals. If you wish for the axes to rotate too, then instead of incrementing angles: $pitch += \Delta pitch, \, yaw += \Delta yaw, \, roll += \Delta roll$ and then building the rotation as: $R = R_z(roll) R_y(yaw) R_x(pitch)$, you should use: $R = R_z(\Delta roll) R_y(\Delta yaw) R_x(\Delta pitch)R$, where R is the previous state of the rotation matrix.  
> **username_0**: @username_1 So perhaps you can explain why 3D software (or at least all the examples I've found about gimbal lock and software) models motion using gimbals? If they are using Euler angles for this, why not start with $R_a$ as the initial XYZ frame, then rotate any axis and store that next state in $R_b$, then apply the next rotation and get $R_c$ and so on and so forth? 1/2  
> **username_0**: To me it seems so silly/odd that a single model would have an XYZ axis frame associated with it, but be bound by having gimbals as the rotation system. You could yaw around the $Z$ axis of the frame, and that would change where $X$ and $Y$ are pointing as a normal ZYX ordered gimbal; in addition, using that say XYZ axis frame, you could first pitch up 90 degrees around the $Y$ axis, and that would change where $Z$ and $X$ are pointing. This notion that software uses gimbals to model motion is what really confuses me about this whole topic. 2/2.  
> **username_0**: @username_3 Suppose you have an aircraft model in software oriented level and flying north such that the $X$ axis extends tail to nose, the $Y$ axis extends from wing to wing and the $Z$ axis is perpendicular to the tail and $X$ axis (as shown in my first image). According to everything I have seen here and elsewhere, making a 90 degree rotation around $Y$ only changes where the $X$ axis points, and does not rotated the $Z$ axis. 1/2  
> **username_0**: @username_3 This seems counter intuitive, why would the $Z$ axis not rotate as well as depicted in my second image? Thus allowing the model to yaw appropriate and not behave like a roll on the $X$ axis? Surely software today can do a rotation around a single axis, save that new XYZ orientation, perform the second rotation around an axis, save that orientation, and so on? Why are models beholding to gimbals that behave in this chained order way? 2/2.  
> **username_3**: @username_0: "*explain why 3D software [...] models motion using gimbals?*" They don't model "motion"; they model *orientation*. YPR is easy for people to conceptualize, but not easy for them to use to animate a thing. Most modelling software can let you reach into the model and drag its orientation around, so what it uses to represent that orientation only matters for interpolation between orientations.  
> **username_3**: @username_0: "*Surely software today can do a rotation around a single axis, save that new XYZ orientation, perform the second rotation around an axis, save that orientation, and so on?*" Nobody said that they couldn't. But that's not how YPR orientation works. You're basically asking, "why is this orientation scheme that is susceptible to gimbal lock used in examples of gimbal lock?" Your question kind of answers itself.  
> **username_1**: @username_0 "perhaps you can explain why 3D software models motion using gimbals?" - that's not a question I can answer, you will have to ask the authors of the specific software/examples you are referring to. It's a design decision for a human-computer interface so it's not like there is an objectively correct choice either. My perspective is more formal: if you want to model a system of gimbals, then you rebuild the rotation matrix each time by chaining rotations and incrementing their angles. If you want to model incremental rotations that are not fixed to a static system of gimbals, 1/2  
> **username_1**: @username_0 then you can keep track of the axes (arranged in your rotation natrix $R$) and then compose that matrix with the delta rotations to get the desired result. Personally if I were to model controls for a plane I would model it using a joystick (again using incremental rotations, but there's also a nice formula there without chained rotations), such that the plane always aligns so that its local up vector aligns with the joystick's axis, and rotating the joystick around its axis would provide the third degree of freedom. 2/2  
> **username_2**: @username_1 the reason its modeled thisway is more to do with navigation and air trafic control. The plane controls are not probably modeled thisway. The reason for this is that a commercial plane will probably not pitch more than 60 angle and probably also not roll more than 30. This makes communication of tracking relatively easy to communicate with radio. It also nicely explains the flight characteristics and control surfaces inner workings within the bounds with simplified models. Yeah it does probably not model acrobatic situations very well but thats hardly a problem for most situations.  
> **username_2**: See the flight dynamics like lift and so on are relative to the horisontal 'plane'. So probably easier to calculate, been a while since i did this kind of stuff. But atleast my multibody books had the dynamics developped for euler angles, probably for legacy reasons. I once saw a energy balancing development for quats, but even the euler derivation was insane, the quat one was really really long. So its probably more to do that the work has been done allready. Its a bit similar how engineers know how to calculate beam bending for large angles but still largely use small angles simplification.  
> **username_2**: The gimbal lock also does not really play a role in larangian dynamics simulation as it sidesteps the problem. So one derived it does not lock up to my understanding. Its a bit on the edge of what i did in my studies but i did derive it once.  
> **username_1**: @username_2 This provides some context, so I guess they probably just copied this regardless of the fact that it is not a good model for a flight simulation. In a flight simulator I would keep the orthonormal basis of the airplane $r,u,f$, and would sample the flight stick's direction vector $f'$ (normalized), then one may compute the new vectors: $r' = r - \frac{(r\cdot f')}{1+(f\cdot f')}(f+f')$ and $u' = u-\frac{(u\cdot f')}{1+(f\cdot f')}(f+f')$ for the new orthonormal basis $r', u', f'$. The only singularity is for $f' = -f$, however this is physically impossible with an actual joystick.  
> **username_2**: @username_1 its a good model for the simulation. The results can then just be translated as quata for the animation and directions.  
> **username_1**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/138695/discussion-between-username_1-and-username_2).  

---

### Answer by username_4 on 2022-08-21. Score: 1

Summary taken from my original question and answer [here](https://computergraphics.stackexchange.com/questions/6233/euler-angles-gimbal-lock-why-non-orthogonal-axes)..

First of all as username_3 suggested you are mixing up the reality with how computers or the mechanics of the gimbals work. You are taking an analogy literally.

If we scratch the whole concept of gimbals and see how rotations work in terms of maths, the idea is quite simple. The rotations around the 3 axes are described by the matrices..

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

Note however, that these matrices don't know the difference between global and local axes. By global, I mean axes that remain fixed in space no matter the rotations applied and the local are axes/frame fixed with the body so it moves accordingly. So when it comes down to math the rotation matrix is going to change the values in the same way it was doing the first time. So for e.g if we apply a $A\_{x}({90^{\circ}})$ to a standard frame like in your first picture, it'd move the $Y$ axis to $Z$ and $Z$ to $-Y$ assuming counter-clockwise rotation for right handed system. Now if you apply a $A\_{y}({u^{\circ}})$ with a random angle, the matrix is still gonna rotate around the previous $Y$ which is currently the local $-Z$ not the new local $Y$ axis.

This is because matrix multiplication only modifies the respective columns/rows. If Y-axis was in the middle column at the beginning and then after a rotation the middle column values changed to Z-axis $(0,0,1)$ that doesn't mean it's going to rotate around the Z-axis next. Graphically speaking the rotation is still around the global Y-axis no matter what the values of the middle column are. If you have trouble understanding this try doing what I explained on a piece of paper and you'll see what I mean.

Moving on, once you understand that, the second concept to understand is that euler angles work with chained rotations. So stuff like $x-y-z$ or $z-y-z$. The key thing to note is that the concept of gimbal lock appears after you apply 1 or 2 of those rotations in order *within* a specific chained rotation, say $x-y-z$. This is important because if you forget this you are gonna ask the question "Well, why can't we just move the other axes?" You can't because you are following a specific order of three chained rotations and you have already done the first one or two rotations.

That being said, now you can imagine an aeroplane with the orientation

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

Note here, that if you rotate around the $X$ you'll either roll left/right. Assume we are following the order $x-y-z$. Next assume we rotated around the $X$ axis a little so we can see the plane's bottom and then rotated $90$ degrees around the $Y$. This is how it'd look like

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

Now here's the gimbal lock. If you try to rotate around the $Z$ axis it's the same rotation back when you were rotating around the $X$. That is, the plane is only rolling. We lost 1 degree of freedom.

You might be thinking well but now, rotation around the $X$ rotates differently so we haven't lost any freedom at all. True but that's thinking again outside the concept of the chained rotation order. We have already done rotation around $X$ and $Y$ so the order only leaves us $Z$ but due to a certain angle of rotation around the $Y$ we can't uniquely rotate it in the third dimension. That's the gimbal lock. If you break free from the order, then it's really hard to perceive the idea of the loss of the degree of freedom.

In applied mathematics terms, this is what's happening...

We have our rotation order $x-y-z$ with the corresponding angles $\alpha-\beta-\gamma$,

$$
R =
\begin{bmatrix}
\cos \gamma & -\sin \gamma & 0 \\
\sin \gamma & \cos \gamma & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
\cos \beta & 0 & \sin \beta \\
0 & 1 & 0 \\
-\sin \beta & 0 & \cos \beta
\end{bmatrix}
\begin{bmatrix}
1 & 0 & 0 \\
0 & \cos \alpha & -\sin \alpha \\
0 & \sin \alpha & \cos \alpha
\end{bmatrix}
$$

Now just to explain what's really going on we skip applying the first rotation and directly rotate 90 degrees around $Y$ which would be $\beta = 90$

$$
R =
\begin{bmatrix}
\cos \gamma & -\sin \gamma & 0 \\
\sin \gamma & \cos \gamma & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
0 & 0 & 1 \\
0 & 1 & 0 \\
-1 & 0 & 0
\end{bmatrix}
\begin{bmatrix}
1 & 0 & 0 \\
0 & \cos \alpha & -\sin \alpha \\
0 & \sin \alpha & \cos \alpha
\end{bmatrix}
$$

$$
R =
\begin{bmatrix}
\cos \gamma & -\sin \gamma & 0 \\
\sin \gamma & \cos \gamma & 0 \\
0 & 0 & 1 \end{bmatrix}
\begin{bmatrix}
0 & \sin \alpha & \cos \alpha \\
0 & \cos \alpha & -\sin \alpha \\
-1 & 0 & 0 \end{bmatrix}
$$

Now multiplying these, we get,

$$
R =
\begin{bmatrix}
0 & \cos\gamma \* \sin\alpha -\sin \gamma \* \cos\alpha & \cos\gamma \* \cos\alpha + \sin \gamma \* \sin \alpha \\
0 & \cos\gamma \* \cos\alpha + \sin \gamma \* \sin \alpha & -\cos\gamma \* \sin\alpha +\sin \gamma \* \cos\alpha \\
-1 & 0 & 0 \end{bmatrix}
$$

$$
R =
\begin{bmatrix}
0 & \sin(\alpha - \gamma) & \cos(\alpha - \gamma) \\
0 & \cos(\alpha - \gamma) & -\sin(\alpha - \gamma) \\
-1 & 0 & 0 \end{bmatrix}
$$

As you can see, changing either $\alpha$ or $\gamma$ here gives us the same matrix. Which means rotation around the $X$ or the $Z$ axis gives us the same result resulting in a loss of 1 degree of freedom.

Personally speaking all those images of gimbals always confused the hell out of me. For a graphics guy it'd have been much more clearer if people explained it more in terms of applied mathematics i.e. Matrices and such and used the diagrams of perpendicular axes instead of gimbals.

What the artiles explaining this concept in terms of gimbals don't do is map the gimbal analogy to the axes analogy. In gimbals there is the concept of parenting. So moving the innermost or I guess the red gimbal in your case won't move the outer two. Moving the outermost will move the other two. This feels really confusing if you have the global/local axes analogy in mind and you are thinking of the gimbals as axes since here both local/global seem all mixed. The idea of the gimbals and parenting here is to preserve the way the previous rotation rotates the object so that when the gimbals align you can actually see that the previous and the new rotation rotate in the same way. So if we have the order $x-y-z$ The innermost gimbal would correspond to $x$. Think of the gimbals appearing one by one after each rotation is applied and not being there from the start.

So considering my example of the plane, rotation around the $x$ does the rolling. The gimbal tied to it is the innermost. So that when you apply rotations around $y$ and $z$ the $x$ gimbal would move with them in order to preserve the rolling aspect.

> **Comments:**
> **username_5**: +1 I read through your two answers and I think they are closely related to my question of not understanding gimbal lock.  I still don't get a qualitative understanding of why gimbal lock happens to an object and perhaps you can take a shot at answering my question there [How can a plane or an object gimbol lock itself](https://aviation.stackexchange.com/questions/95860/how-can-a-plane-or-an-object-gimbal-lock-itself)  

---

