Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetAngle(Cx,Cy)
- if (Cx > x) then
- return (Cy <= y) and (270 - CalcAngle(Cx,Cy)) or (270 + CalcAngle(Cx,Cy))
- elseif (Cx < x) then
- return (Cy <= y) and (90 + CalcAngle(Cx,Cy)) or (90 - CalcAngle(Cx,Cy))
- else
- return (Cy <= y) and (180) or (0)
- end
- end
- function CalcAngle(Cx,Cy)
- local DistX = math.abs(Cx - x)
- local DistY = math.abs(Cy - y)
- return math.atan(DistY/DistX) * (180/math.pi)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement