Intrinsic-57 ATan2

Intrinsic-57 ATan2

Top  Previous  Next

57: real:= ATan2(real Y, real X);

 

This intrinsic computes the arc-tangent of Y divided by X in radians. If the computed angle is in the range ±pi/2 (±90 degrees) then X can be 1.0. However, if an angle over the entire range of a circle (±pi or ±180 degrees) is to be computed then the signed values of the Y and X coordinates are used. This converts rectangular coordinates to polar coordinates. For example:

 

       Angle:= ATan2(0.5, 1.0);    \Angle:= ATan(0.5) (= 26.56505)

       Angle:= ATan2(13.0, -13.0); \Angle:= 3/4 pi (= 135)

       Angle:= ATan2(-5.0, -5.0);  \Angle:= -3/4 pi (= -135)