Jump to content
  • Advertisement
Sign in to follow this  
acid2

Rotation

This topic is 4938 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, I'm struggling to understand how rotation works - I know you need to have 3 matrices for yaw, pitch and roll and these are then multiplied together in pitch, yaw, roll order. But is it really that simple? Because if I create those matrices in directx, I get some verrrrry funky results : Can anyone link me to some newbie friendly articles?

Share this post


Link to post
Share on other sites
Advertisement
Hi acid2,

I actually replied to your earlier post on rotation, but as you've posted again, I must not have been very helpful! Sorry about that. But let me take another shot at it :-)

First of all, if you're looking for a single reference that covers most (but not all) of the math for 3d rotation in a really clear way, check out the book '3D Math Primer' - I highly recommend it.
Quote:
I know you need to have 3 matrices for yaw, pitch and roll and these are then multiplied together in pitch, yaw, roll order. But is it really that simple? Because if I create those matrices in directx, I get some verrrrry funky results
You certainly don't need three different matrices. In fact, you don't need Euler angles at all. In fact, you're probably better off without them! It's not surprising that you're getting funky results, as Euler angles can be problematic.

I'll provide a little info here which you can read if you're interested. Or, you can just get ahold of a good reference such as the aforementioned book.

IMO the most important 3d rotation concept to understand is the axis-angle rotation. An axis-angle rotation is defined by a unit-length axis (which can point in any direction) and an angle.

To visualize what it means, imagine a ball centered at the origin. Now take a 'skewer' (the axis) and stick it through the ball in any direction, the only requirement being that the skewer passes through the origin.

You can see that the ball is now physically constrained to rotate about the skewer. By then choosing an amount by which to rotate, you can reach a subset of all the possible orientations for the ball. Note that a rotation of 0 degrees (or any multiple of 360) leaves the orientation of the ball unchanged.

It turns out that if you allow for any angle, and any direction for the axis, you can reach all possible orientations for the ball. So all you need to describe the orientation of a 3d object is a single axis-angle combination. In practice you usually need a matrix representation; fortunately, an axis-angle pair can easily be converted to a matrix.

The three matrices you mentioned are simply special cases of a general axis-angle matrix, where the axis is chosen to be one of the three cardinal axes, x, y, and z. Euler angles work by performing a sequence of rotations about a sequence of axes. Euler angles are handy because they're fairly intuitive, but they introduce some problems as well.

Anyway, I hope I'm not just further confusing the issue. It's actually a fairly deep topic. And please ask if you have further questions or need clarification on any of the above.

Share this post


Link to post
Share on other sites
RotationYawPitchRoll gives me funky results
-----------

Thanks for that huge reply jyk! I think I'm going to get the book you suggested, that will surely be helpful. The reply was incredibly in depth aswell, and was really easy to understand :)

The reason I want to use Euler angles is because they are so much simple for the end user - "10° here and 40° there" - I always thought those 'xAxis, yAxis, zAxis, angle" things, like OGL were harder to work with.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think understanding matrices is a must. A 3x3 matrix (a subset of a 4x4 D3D matrix) can be used to represent all possible rotations. Each row (or column, depending on how the matrix math is worked..) in a typical rotation matrix is a vector which represents one of three different vectors.. Up, Right, and Forward.

If you work out how a vector is multiplied by a matrix, you will see that these vectors are used rather unimaginatively.. ie.. this is actualy simple stuff!

For each (y) in the input vector.. we need to move , for each (x) in the imput vector, we need to move , and for each (z) in the input vector, we need to move .

(* = scaler * vector)

output = input.y * up + input.x * right + input.z * forward

D3D and other API's use 4x4 matrices because they get more bang for the buck, so to speak.. allowing for translation of position.. but the upper left 3x3 area is just a standard rotation matrix as outlined here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!