Deriving an angle from three points

Mark Swindell mdswindell at cruzio.com
Thu Dec 17 01:22:47 EST 2009


Thank you to all who provided code suggestions and insight into solving this problem (James, Colin, Mark W. gMc, Pierre, Jacques, Phil).

I'd have taken forever to figure this out without such a helpful (and clever) bunch of allies.  

Mark

On Dec 16, 2009, at 1:57 AM, gmccarthy wrote:

> 
> 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.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the Use-livecode mailing list