# rotation order

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

## Recommended Posts

Hi,

lets say I'm looking at the z-axis normal vector in 3D space. Now I want to rotate it 90° around the x-axis and 90° around the z-axis. I find it somewhat strange that I get a different result when I invert the rotation order. Now, what is the correct order?

Intuitively I'd also use the object coordinate system for the 2nd rotation but is this correct? This way, I'd also get different results.

##### Share on other sites
I think it's mathematically normal for a different matrix order to cause different results. I'm not sure what works for you but for me I used built in DirectX rotation functions which I converted to a quaternions. For example, to get a rotation about the Z then X axis I went:

Rotate Z - Matrix1
Rotate X - Matrix2

NewMatrix = Matrix1 * Matrix2.

Then I made the NewMatrix a quaternion although that was only so I could use it in the Quaternion Slerp function for animation.

If you went:

NewMatrix = Matrix2 * Matrix1 you're result would be totally different. Hope that helps somewhat?

##### Share on other sites
Quote:
 Original post by famousI find it somewhat strange that I get a different result when I invert the rotation order.

In general, matrix multiplication is noncommutative. Remember to be careful reading sentences like "rotates 90° around the x-axis", since that can raise the question "x-axis in which coordinate frame?". If you follow in your logic of thought the local coordinate frames always when doing rotations, the results can be misleading.

Quote:
 Original post by famousNow, what is the correct order?

Quote:
 Original post by famousNow I want to rotate it first90° around the world space x-axis and then 90° around the world space z-axis.

Answering this question requires knowledge about the logical convention of applying transformations to points in your math library. Does your system use the order M*v or v*M to transform a point?

Assuming M*v, then the correct order is

Rz * Rx, where
Rx is the rotation around the world x-axis and
Rz is the rotation around the world z-axis.
To confirm this, you can just compute
Rz * Rx * v = Rz * (Rx * v), which indeed does apply Rx first to v, followed by Rz.

If your math library uses v*M, then the proper order is Rx * Rz.

Quote:
 Intuitively I'd also use the object coordinate system for the 2nd rotation but is this correct? This way, I'd also get different results.

Only you can tell whether it is correct, since it boils down to what kind of rotation effect you are seeking for. Try looking for articles discussing rotation about different transformation bases, or, concatenating rotations, to see what kind of effect the different rotations produce. Or, if you already have a system set up, it can be useful just to try it out interactively in your program.

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 104
• 11
• ### Forum Statistics

• Total Topics
632978
• Total Posts
3009681
• ### Who's Online (See full list)

There are no registered users currently online

×