# Rotation Problem

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

## 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 on other sites
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 on other sites
Learn quaternions NOW! They will suffice for almost anything you will do.

##### 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?

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633694
• Total Posts
3013378
×