# Avoiding gimbal lock

I am not really sure if I understand the phenomenon of gimbal lock correctly.

Say I have a vector $\begin{pmatrix} x\\ y\\ z \end{pmatrix}$.

And I want to keep the vector's length fixed but move it in a given direction with respect to the $x, y$ or $z$ axis - i.e. rotate it in that direction.

So, for instance, if I want to rotate it $30$ degrees about the $z$-axis, I would multiply by the matrix $$\begin{pmatrix} \cos(30°) & -\sin(30°) & 0\\ \sin(30°) & \cos(30°) & 0\\ 0 & 0 & 1\end{pmatrix}_.$$

And likewise for the other two axes. Will some sequence of these rotations eventually cause "gimbal lock?" Or will no problem arise using this method?

## 1 Answer

Gimbal lock occurs when one of the rotation matrices reduces to the identity. Then you effectively reduce one degree of freedom.

Let $R_x(\alpha)$ denote a rotation matrix around $x$ by $\alpha$.

Then, a general rotation can be written as $R = R_x(\alpha) R_y (\beta) R_z(\gamma)$. Suppose that $R_x(\alpha)$ becomes the identity map. Then $R = R_y(\beta) R_z(\gamma)$ in the new coordinate frame, and hence there is no longer any notion about "rotation around $x$."

• Right, but I'm doing rotations in sequence, and only about x, y, or z. I.e. I do not have "general rotations" - my rotations are only $R_x(\alpha), R_y(\beta), R_z(\gamma)$, but no combination of these. My coordinate frame is not changing. Commented May 30, 2014 at 23:52
• When you apply a rotation matrix, the next rotation applies along the new coordinate axes. Commented May 31, 2014 at 0:04
• But my axes remain x, y, and z - I'm not changing the coordinate axes. Commented May 31, 2014 at 4:53
• You're missing the key. $R_1$ rotates around your first set of axes. $R_2$ rotates around the set of axes determined by $R_1$, whether you like it or not. Play with some examples and see. Commented May 31, 2014 at 14:47
• Hmm. Well, it indeed locked, so I guess I was wrong. I should review the math again, because this is too simple for me to misunderstand like this. Commented May 31, 2014 at 21:36