NAME trans_2d FUNCTION trans_2d(x0, y0, x1, y1) NOTES Calculate 2D transformation from (x0, y0) to (x1, y1). INPUTS x0, y0 - numbers specify the start point x1, y1 - numbers specify the end point OUTPUTS Distance and the rotation angle. SOURCE function trans_2d(x0, y0, x1, y1) local dx = x1 - x0 local dy = y1 - y0 local d2 = math.sqrt(dx * dx + dy * dy) if (d2 ~= 0) then local phi = 57.29577951 * math.acos(dx / d2) if dy >= 0 then return d2, phi else return d2, -phi end end end