Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.42 KB | None | 0 0
  1. function GetAngle(Cx,Cy)
  2.  
  3.     if (Cx > x) then
  4.         return (Cy <= y) and (270 - CalcAngle(Cx,Cy)) or (270 + CalcAngle(Cx,Cy))
  5.     elseif (Cx < x) then
  6.         return (Cy <= y) and (90 + CalcAngle(Cx,Cy)) or (90 - CalcAngle(Cx,Cy))
  7.     else
  8.         return (Cy <= y) and (180) or (0)
  9.     end
  10. end
  11.  
  12. function CalcAngle(Cx,Cy)
  13.  
  14.     local DistX = math.abs(Cx - x)
  15.     local DistY = math.abs(Cy - y)
  16.    
  17.     return math.atan(DistY/DistX) * (180/math.pi)
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement