# Question about order of rotations

This topic is 3837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
Are you suffering from gimbal lock?

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites
Quote:
 Original post by flounderIt 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...

##### Share on other sites
Quote:
 Original post by Gage64Basically 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.

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
A4L
13
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633744
• Total Posts
3013657
×