# get angle from a vector to another vector

This topic is 4608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
This is what the Dot Product is for..

##### Share on other sites

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.

##### Share on other sites
But be aware that for the dot product the vectors must be normalized...

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

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633373
• Total Posts
3011547
• ### Who's Online (See full list)

There are no registered users currently online

×