Jump to content
  • Advertisement
Sign in to follow this  
Horka

Rotation Problem

This topic is 4327 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

Alrighty...say you're rotating along the z-axis to roll(as in a flight sim), that's fine and dandy. But as soon as you pitch down 90 degrees along the x-axis, your roll becomes yaw. Is there a way(preferably simple) around this? How can I rotate relative to my current orientation? Short and sweet, eh? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You're going to need to track those rotations Yourself, separately from the OpenGL rotation functions.
Those are used Only for rendering graphics, but the complex motions by a plane in a flight sim require that you represent it's orientation separatly so that you can allow for rotations relative to its current orientation.

(applying the glrotation functions only moves the graphics, but doesnt return any information about the New Orientation as a result of all those)

to do this, you need to learn about Vectors and Matrices.
Matrix is the most common way to represent the rotation (vectors can suffice, but less common by themselves) and if you get really experienced, look into Quaternions

terms to lookup:
Vector
Matrix
Quaternion
Euler Angles - know what they are, and why to avoid them!

Share this post


Link to post
Share on other sites
Okay, I've inserted values into two different matrices, each for...ah, whatever, here's the code:



//Matrix for first set of rotations(x-axis)
matrix XMatrix = {1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};

//Matrix for second set of rotations(z-axis)
matrix ZMatrix = {1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};

//Apply x-axis rotations
XMatrix[5] = cos(fAx * RADIAN_CONVERSION);
XMatrix[6] = sin(fAx * RADIAN_CONVERSION);
XMatrix[9] = -sin(fAx * RADIAN_CONVERSION);
XMatrix[10] = cos(fAx * RADIAN_CONVERSION);

//Apply z-axis coordinates
ZMatrix[0] = cos(fAz * RADIAN_CONVERSION);
ZMatrix[1] = sin(fAz * RADIAN_CONVERSION);
ZMatrix[4] = -sin(fAz * RADIAN_CONVERSION);
ZMatrix[5] = cos(fAz * RADIAN_CONVERSION);




If I want to build a rotation matrix(to multiply the current one by), how do I combine these two into one? Do I just multiply them together?

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!