PDA

View Full Version : A simple question about rotation


Eric_Pines
12-08-2003, 12:04 AM
Greetings.

I'm hoping someone could help out a newbie with a simple question.

If I have a euler axis that uses coordinates with Y as Up/Down and Z as Depth, but need to convert it to a coordinate system that has Z as up down and Y inversed as depth? How do I do this?

Anything would be a great help, even just the proper term for what the above tries to do, so I can better search for the answer with Google.

Thanks

PS - Can someone see something wrong with this function used to add euler rotations? To me it does not work the way I think it does. (I have to reverse the original rotation be the value to rotate by when I call it.)

Function Add_Rotation(orig As VertexData, rotateBy As VertexData) As VertexData

Dim rotated As VertexData

rotated.vX = orig.vX
rotated.vY = Cos(rotateBy.vX) * orig.vY - Sin(rotateBy.vX) * orig.vZ
rotated.vZ = Sin(rotateBy.vX) * orig.vY + Cos(rotateBy.vX) * orig.vZ

rotated.vX = Cos(rotateBy.vY) * rotated.vX - Sin(rotateBy.vY) * rotated.vY
rotated.vY = Sin(rotateBy.vY) * rotated.vX + Cos(rotateBy.vY) * rotated.vY
rotated.vZ = rotated.vZ

rotated.vX = Cos(rotateBy.vZ) * rotated.vX - Sin(rotateBy.vZ) * rotated.vZ
rotated.vY = rotated.vY
rotated.vZ = Sin(rotateBy.vZ) * rotated.vX + Cos(rotateBy.vZ) * rotated.vZ

Add_Rotation.vX = rotated.vX
Add_Rotation.vY = rotated.vY
Add_Rotation.vZ = rotated.vZ

End Function

geosync
12-11-2003, 05:30 AM
If you are programming in Direct8.1 research the D3DX helper code as it deals with Euler angles (and Quaternions too).

Andy H.

dead_eye
12-11-2003, 07:00 AM
Originally posted by Eric_Pines
If I have a euler axis that uses coordinates with Y as Up/Down and Z as Depth, but need to convert it to a coordinate system that has Z as up down and Y inversed as depth? How do I do this?
Anything would be a great help, even just the proper term for what the above tries to do, so I can better search for the answer with Google.
Thanks


Multiple all points by this matrix:
[ 1 0 0 0 ]
[ 0 0 1 0 ]
[ 0 1 0 0 ]
[ 0 0 0 1 ]
What it does is it's an orthogonal matrix, that maps points on the y-axis to the z-axis, and points on the z-axis to the y-axis. It's the same thing that you'd get if you'd do a rotation matrix about the x-axis for 90 degrees.

Also, for euler angles (heading, pitch, and banking angles), what they normally do is convert them to quaternions, and then convert them to rotation matrices. It's all in the book, Real-Time Rendering, by Tomas Moller, be sure to pick a copy up.

CGTalk Moderation
01-16-2006, 09:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.