# Question about cumulative rotations

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

## Recommended Posts

Hello all, I have noticed that Direct3D provides methods to generate a rotation matrix or a quaternion based on Yaw, Pitch and Roll angles all in one call. What I am wondering is, doesn't the order that these rotations get applied matter? And if so, how do I know what order they are multiplying them into the matrix? For example, suppose you have a spaceship facing down the Z axis and you want to apply two rotations. One rotation is PI/2 around the Z axis, and one is PI/4 around the Y axis. If you do the Z rotation first, and then the Y, you will be still parallel to the X and Z axes, but you will be twisted ( rolled ). However, if you do the Y rotation first, and then the Z, you will have rotated AROUND the Z axis at a certain radius, giving you a heading vector with some component of X, Y and Z ( as opposed to previously, which had no Y ). Now, I KNOW that happens if you multiply rotation matrices in the two orders I described. But maybe there is a way of getting multiple rotations into matrix form WITHOUT building up the rotation matrices and multiplying them together? Something that produces the same result every time, without order making a difference? If there is, I'd love to know about it, and how it works. If not, then isn't there some implicit order going on under the hood of the "YawPitchRoll" calls that will determine what actually happens to the model? I'd appreciate any advice any one can give me. jujumbura

##### Share on other sites
Yes, any non-generic (such as DX's) Euler-angle function will apply the rotations in a certain order. I'm not sure what the order is in DX, but you can probably find out online.

In general, the first rotation applied appears to be about the corresponding local axis of the object; the last rotation applied appears to be about the corresponding global axis; and the middle rotation appears to be about an arbitrary axis (depending on other factors).

Sometimes this is the desired behavior. For example, in a first-person shooter you often want pitch to be about the local side axis and yaw to be about global up. The proper Euler sequence (with no roll) will give you exactly this.

In other cases, Euler angles are not as effective. In a 6DOF environment (such as a space sim, or the game Descent), it's difficult (if not impossible) to get the desired behavior with Euler angles. For these sorts of applications you instead want to represent your orienation as a matrix or quaternion and update it incrementally to reflect rotations about the local axes of the object.

I don't know if that answers your question, so please ask if you need further info.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632998
• Total Posts
3009808
• ### Who's Online (See full list)

There are no registered users currently online

×