|
Post by eyfenna on Oct 22, 2016 11:40:43 GMT -6
For the arcustangens function with two arguments here's an implementation in two functions that is going to output the angle in degrees
function atan2(x1,y1) if x1 > 0 then return atan(y1/x1) elseif x1 < 0 and y1 >= 0 then return atan(y1/x1) + 3.14159 elseif x1 < 0 and y1 < 0 then return atan(y1/x1) - 3.14159 elseif x1 = 0 and y1 > 0 then return 3.14159/2 elseif x1 = 0 and y1 < 0 then return -3.14159/2 elseif x1 = 0 and y1 = 0 then return 0 end if end function
function getAngle(x1,y1,x2,y2) angel = 0 angle = atan2(x1 - x2, y1-y2) angle = 180/3.14159 * angle return angle +90 end function
|
|