Gimbal &Quats

EularTitle.jpg (8438 bytes) What is Gimbal Lock and why does it occur?

What is gimbal lock? Gimbal lock is the phenomenon of two rotational axis of an object pointing in the same direction. Simply put, it means your object won't rotate how you think it ought to rotate. Gimbal lock is frustrating problem that every CG artist will face sometime in their career and it always happens at the worst possible time. Gimbal lock occurs when animating an object with a rotational matrix known as Eular (pronounced Oiler) angles. It's a general limitation of that type of rotational matrix.

Any system that uses Eular angles (Maya, Max, Lightwave, Softimage) will have problems with gimbal lock. The reason for this is that Eular angles evaluate each axis independently in a set order. In the case of   3DS Max that order is generally X,Y,Z (you can change the order to whatever you'd like however) meaning ... first the object travels down the X axis. When that operation is complete it then travels down the Y axis, and finally the Z axis. The problem with gimbal lock occurs when you rotate the object down the Y axis, say 90 degrees. Since the X component has already been evaluated it doesn't get carried along with the other two axis. What winds up happening is the X and Z axis get pointed down the same axis.

gimbal.gif (62815 bytes)

Here's a sample of that phenomenon in 3DS Max. If you download and open the Gimbal lock.max file, select the dummy and rotate it down it's local Y axis 90 degrees you will actually see it's matrix gimbal lock. If your going to use Eular angles (and every 3D package has them somewhere) your going to have problems with gimbal lock. The only advantage to using Eular angles is that they are much easier for an artist to read and conceptualize than a Quaternion Rotation.

Quaternion Rotations are far more powerful and robust. In Max, TCB controllers use Quaternion math to find their orientation. Quat rotations evaluate all three axis at the same time to find a direction to travel and a fourth value (the w component or up vector) to tell the matrix how far to travel. The advantage to using Quat rotation is that you never have to worry about Gimbal Lock. It simply can not happen because all three axis get updated at the same time. The down side to using Quats is they are far more complicated to read and conceptualize than an Eular angle. RotationScript controllers in Max are Quat rotations which makes them far more powerful than Eular angles and expressions but they are also much more difficult to use and understand.  

I generally chose to use Eular angles on my puppets because they are easy to understand and animate with. You just have to keep in mind that an Eular angle, no matter what you call it (Local Eular, World Eular, XYZ Bezier) is still an Eular angle and as such, has severe limitations.

A few things to keep in mind when working with Eular angles to keep you from going Postal:

1. If your object only needs to rotate along one axis, change the order of axis to match i.e.. if your rotating down the Y axis make the order of axis Y,Z,X.

2. If your rotating down two axis, change the order of axis to correspond with the first and last axis i.e... if your rotating down the X and Y axis, change the order of axis to X,Z,Y 

3. If your rotating down all three axis be aware that there will be areas where gimbal lock will occur. Try to place those areas far enough out of the way that they won't be a problem or separate the axis with an additional node (even this isn't enough sometimes)

4. In certain specific cases, the parent of an object can actually gimbal lock it's child (I won't go into the math involved here) Try placing an extra Quat node in the chain between these two nodes. You can see a good example of this in 3DS Max if you link anything using Eular angles to a Biped. Instant Gimbal Lock. One workaround is to link a dummy with TCB controllers (Quat) to the biped first, then link your chain to the dummy.

5. The first axis evaluated will always happen in the objects local coordinate orientation

6. The last axis evaluated will generally happen in a world coordinate orientation

With careful planning and a little fore thought you'll be able to keep gimbal lock to a minimum. Happy animating.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章