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

## Recommended Posts

I have an object, lets say a spaceship the spaceship starts out pointing up (+ on the y axis) if i have a thrust of 1 my heading would be (x,y,z) (0,1,0) so if i rotate my shpaceship on all 3 axis say (.5,-1,.25) how do i find my heading again? is there some math equation I can perform? thanks

##### Share on other sites
Quote:
 how do i find my heading again? is there some math equation I can perform?
Yes. Aside from the fact that you could accomplish this through glRotate() and glGetFloatv(), this problem is independent of OpenGL. What you're probably looking for is Euler angles. You construct the appropriate rotation matrix for each of the three rotations, and then concatenate them. This can be optimized if desired to remove unnecessary operations. The resulting matrix is the ship's new orientation, from which you can extract the direction vector. If you don't have a matrix library of your own, you can hack this together using OpenGL functions.

If you want your ship to have natural 6dof motion, you may find that constructing your orientation matrix from scratch each frame using Euler angles is not an ideal approach.

##### Share on other sites
I have to say this. You could use Quaternions. But notice I said "could". As in, you can get it right with just matrices. But the Euler angles don't work against Gimbal Lock.

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

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

• Total Topics
633701
• Total Posts
3013435
×