• Advertisement
Sign in to follow this  

get angle from a vector to another vector

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

With three points A , B and C make a triangle. We also have two vectors from these points: vector AB and vector AC I want to get angle from vector AB to vector AC. If you know formula or function(s) in C++ can do this please share with me... Thank you very much. Note: Assume i can get value from vector AB to vector AC is a . But if we get angle in opposite (from vector AC to vector AB) then we will get value is -a.

Share this post


Link to post
Share on other sites
Advertisement

the cosine of the angle between the vectors can be calculated with a dot product. From the cosine you can get the angle if you actually need it.

google for dotproduct

Share this post


Link to post
Share on other sites


Mathematically dotproduct is actually defined to take account the vector lengths. Check http://wiki.rednek.net/index.pl?DotProduct

the dotproduct instruction in shader code for example assumes that the vectors are already normalized.

Share this post


Link to post
Share on other sites
Don't know if this is even relevant, but I sped up my physics code alot by not using atan2, and just storing the normalized orientation vector.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement