Question about order of rotations

Started by
4 comments, last by flounder 15 years, 10 months ago
I recently realized that I don't understand rotations as well as I thought. To clarify some things for myself, I wrote a program that rotates a teapot around the 3 axes. In the program, I construct 3 rotations matrices, one for each axis, and then concatenate them to create the world matrix. No matter what order I concatenate the matrices in, the first two rotations always occur around the object's local axes, while the last one occurs around the global axis. My question is - how can I understand this geometrically? I know the question isn't as clear as it could be, but I'm not sure how else to put it. Basically I'm trying to get an intuitive understanding of why this works the way it does. Thanks in advance.
Advertisement
Are you suffering from gimbal lock?
I understand what gimbal lock means theoretically (two of the three axis become aligned), but I don't fully understand how that affects the rotations in practice, so I'm not sure how to answer your question (but thanks for the link, interesting reading). BTW, the last two points at the link mention this behavior, but it's not really explained.

I should also mention that this also happens if I only use two of the three matrices. In that case, the first rotates around the local axis, and the second around the global axis. Can gimbal lock occur with just 2 rotations as well?

Also, it seems that this behavior is relied upon in this tutorial (the last paragraph), which also makes me think that it's not related to gimbal lock. That tutorial uses quaternions but I don't think that matters in this case.
EDIT: Are the rotations working incorrectly, or do you just want to get a better understanding of them?

It might be the way you're calculating the world rotation matrix. Are you currently doing something like "render(object,rotation_matrix)"? If so, you might want to try applying each of the 3 matrices individually to the vertices and then rendering the teapot.

I've never dealt with gimbal lock though, so it may just as well be that.
Quote:Original post by flounder
It might be the way you're calculating the world rotation matrix. Are you currently doing something like "render(object,rotation_matrix)"? If so, you might want to try applying each of the 3 matrices individually to the vertices and then rendering the teapot.


I'm not sure what you mean. If it helps, here's the important part of the code (using C# and MDX):

    Matrix rotX = Matrix.RotationX(xRot);    Matrix rotY = Matrix.RotationY(yRot);    Matrix rotZ = Matrix.RotationZ(zRot);    device.Transform.World = rotX * rotY * rotZ;    teapot.DrawSubset(0);


EDIT:

Quote:Are the rotations working incorrectly, or do you just want to get a better understanding of them?


Basically the latter, though I'm not sure what "incorrectly" means in this case...
Quote:Original post by Gage64
Basically the latter, though I'm not sure what "incorrectly" means in this case...


When I first read your initial post, I thought you were saying the teapot wasn't rotating correctly because of some matrix math. When I reread it, I realized you could have the matrices working correctly and you just wanted to understand how they were working. In that case, I have no idea how they work.

This topic is closed to new replies.

Advertisement