Hugh,

You'll love the atan2 function. It takes care of all nasty bits at 90 and 270 
degrees as well as dealing with the quadrants issues.

Use atan2(y,x) for angles measure clockwise from the x-axis

Use atan2(-y,x) for angles measure counterclockwise from the x-axis.

Jim Hurley


 --| Get the point's relative coordinates...
  put pointX - objX into x
  put pointY - objY into y

  if y=0 then
    --| Handle the exceptions...
    if x>0 then put 0 into tAngle
    else put 180 into tAngle
  else
    put atan ((x*H)/(y*W)) into tAngle
    --| Convert from radians to degrees...
    put (tAngle * 180 / pi) into tAngle
    --| Adjust the angle according to the quadrant...
    put (tAngle MOD 180)+90 into tAngle
    if y>0 then add 180 to tAngle
  end if



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to