Bobster@cup.portal.com (Robert Jules Shaughnessy) (11/04/90)
If your into flamming the neophytes do not read any further... I am having troubles finding the angle from one point on a 2D plane to another. For instance at point A, what direction would I need to go to hit point B, in degrees. I do have something that works, I take the ATN of x1-x2/y1-y2 and this works ok, but will only show 90 degrees. I have to use a few if then statement to find out when to add and subract 90 180 270 degrees to get it to work all the way around point A. There simply must be a better way and I cant find it in the geometry books! Thanks in advance!
Bobster@cup.portal.com (Robert Jules Shaughnessy) (11/04/90)
Thanks for all the replies... They were very helpful!
dave@viper.Lynx.MN.Org (David Messer) (11/09/90)
In article <35558@cup.portal.com> Bobster@cup.portal.com (Robert Jules Shaughnessy) writes: > > I am having troubles finding the angle from one point on a 2D plane to >another. For instance at point A, what direction would I need to go to hit >point B, in degrees. > I do have something that works, I take the ATN of x1-x2/y1-y2 and this >works ok, but will only show 90 degrees. There is a function in the standard C library called atan2() that handles this (call as "angle = atan2( x1-x2, y1-y2 )" ). If you don't have the standard C functions, writing this shouldn't be particularly difficult. The CRC Standard Math Tables book is a good place to start for information on formulas. -- How can you tell if Bush is lying? | David Messer dave@Lynx.MN.Org -or- Watch his lips... | Lynx Data Systems ...!bungia!viper!dave