Jump to content
  • Advertisement
Sign in to follow this  
SelethD

how to calc heading?

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!