Deriving an angle from three points

gmccarthy gmccarthy at
Wed Dec 16 04:57:21 EST 2009

What about getting the angle from point B to A, then the angle from point B
to C, then getting the difference:

on mouseUp
   put cd fld "A" into pointA
   put cd fld "B" into pointB -- assumed center of angle
   put cd fld "C" into pointC
   put fGetAngle(pointB, pointA) into angleA
   put fGetAngle(pointB, pointC) into angleC
   if angleC > angleA then
      put angleC - angleA into cd fld "AngleABC"
      put angleA - angleC into cd fld "AngleABC"
   end if
end mouseUp 

function fGetAngle pPoint1, pPoint2
   --angle anticlockwise from X axis
   return atan2(item 2 of pPoint2 - item 2 of pPoint1,item 1 of pPoint2 -
item 1 of pPoint1) * 180 / pi
end fGetAngle 

See atan2 in the dictionary.
By the way, this gives 66.209226 for the angle.

As a test for known angles, try
This is for angles of 45 degrees and 120 degrees.
you should get 75 degrees as your answer.
View this message in context:
Sent from the Revolution - User mailing list archive at

More information about the use-livecode mailing list