Sign in to follow this  
Helo7777

how to get orientation from a target vector?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this