PDA

Click to See Complete Forum and Search --> : Some Trig


Zaei
Feb 18th, 2001, 08:42 PM
I want to find the angle between 2 points. For
example, i am at point (1,2), and i want to be at (8,6).
First i need to rotate X degrees, until i face my
destination, then move N spaces, until i am there.

So, to make a right triangle, i take Point1.Y (2) and
Point2.X (8) to form the right angle at (8,2). Any
algorithm for this?

kedaman
Feb 19th, 2001, 07:14 AM
Check out my sample rotation using guv's safe arctangent function:
http://forums.vb-world.net/showthread.php?s=&threadid=53924
If you want to rotate 90 degrees you switch dx and dy as follows:
to the left
x = cx + dy
y = cy - dx
to the right
x = cx - dy
y = cy + dx

Feb 19th, 2001, 10:47 AM
I figured it out last night, but thanks kedaman. =)