tags:

views:

87

answers:

3

By using left hand rule, I rotate one object left and right using y axis, and rotate up/down using x axis. After first object is rotated to the right, the up/down rotation should be using z axis.

However, when I try to rotate using z axis, after the first rotation, it has the same effect when I rotate using y axis.

Anyone has any ideas?

Thanks

A: 

The proper order of rotations in order to keep everything straight is roll, pitch, yaw. That is, rotation around the X axis, rotation around the Y axis, rotation around the Z axis.

Ignacio Vazquez-Abrams
A: 

Not sure what your question is, but if you're asking why this happens, the answer is that rotations are not commutative. That is, a rotation of theta about axis A followed by a rotation of phi around axis B is not the same as rotation of phi around axis B followed by a rotation of theta around axis A.

If you're asking why a sequence of operations that seems okay when you visualise it fails to work in code, be sure you're using a right-handed coordinate system. Also, it might be helpful to work through your various rotation matrices for the x, y and z axes using the unit vector (1,0,0) - in fact, if you do it on paper you'll get a better intuition for what's happening.

Martin DeMello
A: 

Thanks for all the answers:

Sorry I didn't state the problem clearly. That's the typical gimbal lock problem. and my solution is to use quaternion rotation

Leo
Welcome to StackOverflow! You shouldn't post this as a separate answer, though -- edit it into your original question using the `edit` link under the main text.
Lucas Jones