# rotation matrix to euler angles with gimbal lock

How do i determine which angle i can negate when gimbal lock occurs.

As i've understood with gimbal lock that it remove one degree of freedom, but how do i determine which degree can be removed when a value R[1][3] of a rotation matrix (size 3x3) has the value 1. Is it the Roll, Pitch or yaw which can be taken out from the equation?

• What do you mean "which dimension can be removed"? Gimbal lock removes a degree of freedom, but if you're using a 3x3 rotation matrix I don't understand what you're trying to "remove". – Chuck Oct 7 '15 at 1:44

I think you may be misunderstanding the nature of gimbal lock. It sounds like you may be trying to remove an actual term in a rotation matrix calculation , but this is incorrect because each axis is still able to rotate. What happens with gimbal lock is that one of the rotational degrees of freedom of the object you are rotating is removed. This happens when two rotational axes become aligned.

In the image on the left, pins that allow the blue and orange rings to rotate are aligned. This means that the blue ring may rotate to allow pitch, the green ring may rotate to allow yaw, but the orange ring does not allow roll. The orange ring is aligned with the blue ring, meaning that it also can only allow pitch motion.

The way to achieve roll is to separate the blue and orange rings, as shown on the right image above. To pitch the orange ring moves, and then yaw and roll are movements of the blue and green rings together.

Notice again that, even in gimbal lock, each ring (each axis) can still move - no term would be removed from a rotation matrix equation. Instead, the object is "locked" on the roll axis because the physical arrangement is such that there is no way to roll.

All rotation matrices can be expressed in Euler angles. Precisely, all 3D rotations can be expressed as 3 subsequent unit axis rotations. (Note there are 24 different, equally valid conventions of unit axes to write Euler angles.)

For Euler angles, a "gimbal lock" occurs iff the Euler angle representation for a given rotation matrix is not unique, i.e. there are infinite solutions. At the same time, the mapping from the rotation matrix to Euler angles is non-smooth.

In the case of z-x-z extrinsic Euler angles, this special case is for R[3][3]==0. You could than apply an arbitrary z-rotation before and its inverse after without an effect.

https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Rotation_matrix_.E2.86.92_Euler_angles_.28z-x-z_extrinsic.29

There is no angle that should be removed. At a gimbal lock, you are able to express an orientation in an infinite amount of ways if you use a three-angle representation. At a gimbal lock, axes of two angular rotations are aligned. As such, their rotations are no unique solution to a given orientation. It depends on the representation which axes are considered here.

I'll try to find time later to add a can-in-series example to further clarify this.

I suggest you never ever look back at three-angle representations, such as pitch-yaw-roll, Euler angles or Tait-Bryan angles. The theory is flawed as it does not make any sense mathematically. It's like trying to flatten a piece of paper over a globe.