Skip to main content
gamedev.net
🔒 Locked

Angle from two points

Started by DerekDay Mar 15, 2000 at 1:54 AM 3 replies 600+ views
Original Post
DerekDay
DerekDay
I should know this... but anyway... What''s a fast way to calculate the angle between 2 points in the Cartesian coordinates system. -Derek
SiCrane
SiCrane
You mean the angle between the two vectors from the origin to the two points? Take the arccos of the dot product of the two vectors, divided by the magnitude of each vector.

cos theta = a . b / (/a/ * /b/).
SiCrane
SiCrane
I forgot that the board mangles pipes. Those last two /a/ and /b/ respectively refer to magnitude of a and magnitude of b.
Valacar
Valacar
That was my post above, but it looks like it removed the includes....it''s including math.h (for acos()) and iostream.h (for cout()).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.