Jump to content
  • Advertisement
Sign in to follow this  
pathon

Extracting yaw from a normalized vector?

This topic is 3446 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, I am trying to extract the yaw from a normalized vector: Normalize(vectorDest - vectorSource) I end up with a vector that features -1 to 1, but I need -6 to 6 (PI * 2). The closest I could get was by using cosf, but that was 0 to 3 (PI). How can I do this correctly? [Edited by - pathon on January 9, 2009 7:34:31 AM]

Share this post


Link to post
Share on other sites
Advertisement
If you just want the yaw relative to the positive x-axis, then this should do:
yaw = atan2(n.Z, n.X)
(If you need to find the yaw relative to some arbitrary coordinate system, then you'll have to use a simple matrix transformation first, but don't worry about that if you're just measuring in standard world space.)
See here for the definition of atan2 if you're not sure. The function is included in the standard maths library of pretty much every language.

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!