Extracting yaw from a normalized vector?

Started by
1 comment, last by pathon 15 years, 3 months ago
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]
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.
Thanks

[Edited by - pathon on January 10, 2009 9:20:33 PM]

This topic is closed to new replies.

Advertisement