Difference between revisions of "findRotation"
(Created page with "This function takes two sets of XY coordinates. It returns the direction from point A to point B. [edit] *Original function by Doomed_Space_Marine. Fixed, tested. Wiki-fied by...") |
|||
Line 1: | Line 1: | ||
This function takes two sets of XY coordinates. It returns the direction from point A to point B. | This function takes two sets of XY coordinates. It returns the direction from point A to point B. | ||
− | |||
− | *Original function by Doomed_Space_Marine. Fixed, tested. | + | *Original function by Doomed_Space_Marine. Fixed, tested by robhol. Wikified by qaisjp. |
==Syntax== | ==Syntax== |
Revision as of 17:08, 4 November 2012
This function takes two sets of XY coordinates. It returns the direction from point A to point B.
- Original function by Doomed_Space_Marine. Fixed, tested by robhol. Wikified by qaisjp.
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