Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1. function GetAngleBeetweenTwoPoints(x1, y1, x2, y2)
  2.   local plus = 0.0
  3.     local mode = 1
  4.     if x1 < x2 and y1 > y2 then plus = math.pi/2; mode = 2; end
  5.     if x1 < x2 and y1 < y2 then plus = math.pi; end
  6.     if x1 > x2 and y1 < y2 then plus = math.pi*1.5; mode = 2; end
  7.     local lx = x2 - x1
  8.     local ly = y2 - y1
  9.     lx = math.abs(lx)
  10.     ly = math.abs(ly)
  11.     if mode == 1 then ly = ly/lx;
  12.     else ly = lx/ly; end
  13.     ly = math.atan(ly)
  14.     ly = ly + plus
  15.     return ly
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement