Jump to content
  • Advertisement
Sign in to follow this  
Helo7777

how to get orientation from a target vector?

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

Hi, Im looking for a way to get an orientation from a direction vector. Im using quaternions for orientation and its in 3D. For example, I have an entity at position v1 and I want the orientation to the target position v2 so it can face in that direction. Thanks for the help.

Share this post


Link to post
Share on other sites
Advertisement
It is simple enough to make a matrix from that, and convert it to a quaternion.

ndir = Normalize(dir);
orientMat.at = ndir;
orientMat.left = Cross(UpVectorGuess, orientMat.at);
orientMat.Up = Cross(orientMat.at, orientMat.left);
convertToQuat ( orientMat );

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!