#### Archived

This topic is now archived and is closed to further replies.

# Angle Between Some Vectors

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

## Recommended Posts

Okay. I have the xyz coords of three points ABC that make a triangle, and point Z on the same plane. I need to find the angle between vector za vector zb, and between vector va and vc. The angles need to be from 0 to 360.

##### Share on other sites
This is directly from Mathematics for 3D Game Programmers and Computer Graphics:

Theorem 1.4. Given two n-dimensional vectors P and Q, the dot product P . Q satisfies the equation

P . Q = ||P|| * ||Q|| * cos(a)

It should be pretty easy to solve for a. just a bit of easy math. Anyways, remember, a is in radians, not degrees. You have to convert it to degrees using *180/pi

---
My Site

##### Share on other sites
And just to extend on that formula:

P . Q = P.x*Q.x + P.y*Q.y + P.z*Q.z = ||P|| * ||Q|| * cos(a)

It''s nice to have that equation if you want to explore the mechanics of the dot product and why it works and how; i.e the mathamatics behind it.

##### Share on other sites
i know what the dot product is, but I dont know if the dot product will return an angle over 180. like of the angle is 350 then it would return 10 instead of 350.

##### Share on other sites
Using the dot product with give you the cosine of the angle, so just plug it into acos(), which will return a number between 0 and 2pi, it''s just a matter or re-scaling that value to your [-180, 180] range.

codeka.com - Just click it.

##### Share on other sites
quote:
Original post by Reverse_Gecko
i know what the dot product is, but I dont know if the dot product will return an angle over 180. like of the angle is 350 then it would return 10 instead of 350.

If at all, it would return -10, so it''s just a matter of checking the sign...

Yesterday we still stood at the verge of the abyss,
today we''re a step onward!

##### Share on other sites
but of course it would be in radians, not degrees. Radians are the mathematically natural way to represent angle. Degrees were invented to make division simple.

##### Share on other sites
The angle will ALWAYS be between 0 and pi radians. It will not be negative, or above pi. Finding the angle using the dot product will find the inner angle between two vectors, which, if you think about it, is always between 0 and pi. Everybody who says you''ll get "-10" as an angle and all that, is, quite simply, wrong.

Death of one is a tragedy, death of a million is just a statistic.

##### Share on other sites
Ooops, definetly right! Mixed it up with something else...

Yesterday we still stood at the verge of the abyss,
today we''re a step onward!

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 33
• ### Forum Statistics

• Total Topics
632633
• Total Posts
3007543
• ### Who's Online (See full list)

There are no registered users currently online

×