Sign in to follow this  

rotation order

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by famous
I 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 famous
Now, what is the correct order?


To unambiguate, your sentence might read something like (emphasis mine):

Quote:
Original post by famous
Now 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.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this