Jump to content
  • Advertisement
Sign in to follow this  
Pickl3d

Quaternions again!

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

Hello there, I have a Quaternion which rotates (left/right look) sucessfully so I figured that much out... I was wondering if I have a pitch as a separate value in radians (up/down look), then how can I combine this data with the Quaternion so that I can "face" a point in space at x,y,z. Thanks for any suggestions, i'm slowly trying to understand this...

Share this post


Link to post
Share on other sites
Advertisement
If you have a point p1 you are currently looking at target point p2 you want to look at after some rotation, you can build the rotation quaternion like this:

Let c be the current location (or the rotation center):

axis = cross( p2 - c, p1 - c );
angle = arccos( dot( p2 - c, p1 - c ) )

quat = rotation( normalize( axis ), angle )


So much in theory. In praxis you do it little different to avoid numerical issues. Here is some good references (scroll down to the bottom of the page):

http://www.essentialmath.com/tutorial.htm


You can actually read everything from this page and I also recommend the book!

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!