Archived

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

Reverse_Gecko

Angle Between Some Vectors

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 this post


Link to post
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
Come join us on IRC in #directxdev @ irc.afternet.org

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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 this post


Link to post
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 this post


Link to post
Share on other sites