Jump to content
  • Advertisement
Sign in to follow this  
31337

Position, At, and Up to Rotation Matrix

This topic is 5461 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 a position, an at, and an up vector for a model and I need to create a rotation matrix that will rotate my model so that it is oriented to those vectors. How do I do this? I'm thinking it has something to do with just putting the unit vectors straight into a matrix, but I'm not sure. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Hi,

This should set you straight:

http://www.makegames.com/3drotation/

I found this extremely useful and well written. There's plenty of source code around to achieve this (included with the article too), but this article explains it nicely.

Cheers,

Martin.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Your right, but it does depent what side you multiply from. this would be a general solution assuming z is up and x is left and your doing Mat = vec*Mat:

at_vector = at-position;
Left_vector = CrossProcuct(Up,at_vector);
Matrix = {
Left_vector.x, Left_vector.y, Left_vector.z
at_vector.x, at_vector.y, at_vector.z,
up.x, up.y, up.z,
};

try a few examples to see how it works. also to change back just take the inverse
(i.e. {Left as column | at as column | up as column } )

Share this post


Link to post
Share on other sites
I've actually read that document before. It is very helpful.

Here's what I'm thinking. What if I used the same matrix that I'm using for my viewing matrix (I'm using Direct3D) for my world matrix too, except for I changed the viewing, position, and up that it was generated from?

I'm using a similar setup of position, looking, and up for my camera. Would this work? Thanks

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!