Deriving an angle from three points

Mark Swindell mdswindell at cruzio.com
Thu Dec 17 01:13:50 EST 2009


Colin,
Thanks, this appears to be a very succinct solution.  Very much appreciated.
Mark

On Dec 16, 2009, at 8:01 AM, Colin Holgate wrote:

> 
> On Dec 16, 2009, at 1:21 AM, Mark Swindell wrote:
> 
>> 40,116
>> 98,186
>> 132,118
>> 
>> How would one determine the angle created from three points, such as those above?
> 
> 
> All of the suggested scripts seem quite long. Try putting this script into three buttons. The script uses the Other Mark's way of dragging the button around (and it doesn't hilite the button as he claims):
> 
> on mouseDown
>    repeat until the mouse is up with messages
>         set the loc of me to the mouseLoc
>         wait 0 millisecs with messages
>      end repeat      
>   put 180 - angler(loc of btn 1,loc of btn 2,loc of btn 3)/pi*180
> end mouseDown
> function angler p1, p2, p3
>   put atan2(item 2 of p2-item 2 of p1,item 1 of p2 - item 1 of p1) into angle1
>   put atan2(item 2 of p3-item 2 of p2,item 1 of p3 - item 1 of p2) into angle2
>   return abs(angle2-angle1)
> end angler
> 
> The bit that calculates the angle could be done in a single line:
> 
> put 180 - (atan2(item 2 of p3-item 2 of p2,item 1 of p3 - item 1 of p2)-atan2(item 2 of p2-item 2 of p1,item 1 of p2 - item 1 of p1))/pi*180
> 
> 
> _______________________________________________
> 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