Jump to content
  • Advertisement
Sign in to follow this  
Psyk60

Getting a rotation matrix from up, right and forward vectors

This topic is 4156 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've been following this tutorial to make a space sim style camera http://www.toymaker.info/Games/html/camera.html I have made a few changes to this. I don't reset the up, right and forward each time. That way rotations are done based on the local axes rather than the world axes (correct? It seems to work right), and I rotate by the change in the angle rather than the cumulative value (after all now it's a series of rotations in different directions so a cumulative value wouldn't make sense). Now that works fine for orienting the camera in the right way, but I don't know how to turn these three vectors into a suitable rotation matrix so I can rotate my ship model in world space. I've tried building the matrix in the same way as the view matrix (as described in that tutorial), but that doesn't seem to work at all. Can anyone point me in the right direction here? P.S. I assure you that pun was entirely unintentional.

Share this post


Link to post
Share on other sites
Advertisement
(Assuming a Direct3D style left-handed coordinate frame): If you have three world space vectors, Right (x), Forward (z), and Up (y) that define a coordinate system, and you want to transform from that coordinate system into world space (e.g. the Model->World transform), you just need to place those vectors as the rows in your transformation matrix. If, on the other hand, you need to transform from world space *into* this new coordinate system (such as with the World->View transform), you need the inverse of this matrix, which for a rotation matrix is just the transpose.

So the rotation matrix you're looking for is the transpose of the upper 3x3 portion of the matrix given in that tutorial.

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!