Gimbal Lock is a problem that arises when using Euler angles to perform rotations on objects in three dimensional space, most commonly experienced in 3D computer programs. It occurs when two axis become aligned during rotational operations. When this happens one degree of freedom is lost and cannot be regained using Euler angle rotations, an external intervention is required.
The reason Gimbal lock occurs is because when Euler angles are used to perform a rotation, each axis is processed independently, one after the other (e.g. X, Y then Z), leading to the possibility that an object could have its axis rotated such that by the time the last axis is processed one of the axis could be aligned to another, and due to the way Euler angles function, trying to perform a rotation while two axis are aligned will produce unexpected results.
For example, if we yaw (rotation about y-axis) 45° and then pitch (rotation about x-axis) -90° it is the equivalent of a pitch of -90° and then a roll (rotation about z-axis) of 45°. In fact, if the pitch rotation is ±90° it will cause the roll and yaw (z and x) axis to be aligned.
If this is hard to understand, try standing up, holding your arm stretched out so that it is parallel to the floor with your fingers extended (pointing away from you), now pitch your arm -90° (place your arm by your side, making your fingertips point towards the floor), now you can twist your arm (roll) without moving your body, but try walking around in a circle (keep your arm by your side) notice this is the same as rolling! But if you perform the same circle when your arm is out parallel to the ground it actually changes the direction your arm is pointing (yaw), you have just witnessed the y and z axis (yaw and roll) becoming aligned, a Gimbal Lock.
There is an interactive demo that can be used to demonstrate this at "http://gamemath.com/Euler.htm", try entering the angles as described to create a Gimbal lock and then try adjusting the "Heading" and "Bank" angles. Note: Heading = Yaw (y-axis), Bank = Roll (z-axis).
3D software and game developers will come across Gimbal lock at some point as it is a common and well known problem and can be very frustrating to debug without prior knowledge of its existence. Popular 3D modelling programs that use Euler Angles to perform rotations, and therefore suffer from Gimbal Lock include:
There are ways to keep Gimbal lock to a minimum when programming 3D rotations, if performing a rotation on only one axis, ensure it is the first axis to be processed, if performing two rotations, make sure they are the first and last axis to be processed.
To avoid Gimbal lock completely checks need to be placed in code whenever there is a chance of it occurring, or alternatively a different way of rotating can be used, specifically Quaternion Rotations. These types of rotation are confusing and hard to understand, but not particular hard to implement (see Quaternion).
- DUNN, Fletcher & PARBERRY, Ian (2002) "3D Math Primer for Graphics and Game Development": Worldware Publishing Inc. ISBN: 1-55622-911-9
- Wikipedia - Gimbal Lock: "http://en.wikipedia.org/wiki/Gimbal_lock/" Accessed: 27 March 2004 23:48 GMT
- Anticz.com - EularQuats: "http://www.anticz.com/eularqua.htm" Accessed: 27 March 2004 23:30 GMT
- 3D Studio Max Website: "http://www.discreet.com/3dsmax/"
- Lightwave Website: "http://www.newtek.com/products/lightwave/"
- Maya Website: "http://www.alias.com/eng/products-services/maya/"
- Softimage Website: "http://www.softimage.com/home/"