Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetAngleBeetweenTwoPoints(x1, y1, x2, y2)
- local plus = 0.0
- local mode = 1
- if x1 < x2 and y1 > y2 then plus = math.pi/2; mode = 2; end
- if x1 < x2 and y1 < y2 then plus = math.pi; end
- if x1 > x2 and y1 < y2 then plus = math.pi*1.5; mode = 2; end
- local lx = x2 - x1
- local ly = y2 - y1
- lx = math.abs(lx)
- ly = math.abs(ly)
- if mode == 1 then ly = ly/lx;
- else ly = lx/ly; end
- ly = math.atan(ly)
- ly = ly + plus
- return ly
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement