findRotation
This function takes two sets of XY coordinates. It returns the direction from point A to point B.
Syntax
float findRotation(float Xa, float Ya, float Xb, float Yb)
Required Arguments
- Xa: The X coordinate of the starting point.
- Ya: The Y coordinate of the starting point.
- Xb: The X coordinate of the target point.
- Yb: The Y coordinate of the target point.
Source
function findRotation(x1,y1,x2,y2)
local t = -math.deg(math.atan2(x2-x1,y2-y1))
if t < 0 then t = t + 360 end;
return t;
end