Deriving an angle from three points
gmccarthy
gmccarthy at people.net.au
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"
else
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
250,250
200,200
100,373
This is for angles of 45 degrees and 120 degrees.
you should get 75 degrees as your answer.
--
View this message in context: http://n4.nabble.com/Deriving-an-angle-from-three-points-tp964930p965051.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the Use-livecode
mailing list