Reverse_Gecko 122 Report post Posted July 26, 2002 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. 0 Share this post Link to post Share on other sites

Vaporisator 122 Report post Posted July 26, 2002 Look here http://freespace.virgin.net/hugo.elias/routines/r_dot.htmThe math you need is called "Dot Product" Yesterday we still stood at the verge of the abyss,today we''re a step onward! 0 Share this post Link to post Share on other sites

RapidStunna 122 Report post Posted July 26, 2002 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 equationP . 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 SiteCome join us on IRC in #directxdev @ irc.afternet.org 0 Share this post Link to post Share on other sites

Zipster 2393 Report post Posted July 27, 2002 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. 0 Share this post Link to post Share on other sites

Reverse_Gecko 122 Report post Posted July 27, 2002 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. 0 Share this post Link to post Share on other sites

Dean Harding 546 Report post Posted July 27, 2002 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. 0 Share this post Link to post Share on other sites

Vaporisator 122 Report post Posted July 28, 2002 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! 0 Share this post Link to post Share on other sites

Guest Anonymous Poster Report post Posted July 29, 2002 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. 0 Share this post Link to post Share on other sites

python_regious 929 Report post Posted July 29, 2002 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. 0 Share this post Link to post Share on other sites

Vaporisator 122 Report post Posted July 31, 2002 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! 0 Share this post Link to post Share on other sites