ARCTAN2 accepts any two numbers x and y (except two zeros—that is, both x and y cannot be 0) and returns the arctangent of the quotient of those two numbers.
ARCTAN2 is defined for all real x and y values. This function is adapted to fall in the range of -pi through +pi by choosing it in a quadrant determined by the signs of x and y. In effect, this function is used in complex arithmetic as follows: given the complex number x+iy, ARCTAN2 (x,y) returns the argument of that number between -pi and pi. This function is calculated from the function ARCTAN, as follows:
-
ABS (x) < ABS (y) If y > 0 then ARCTAN2 = ARCTAN(x/y). If y < 0 then ARCTAN2 = ARCTAN(x/y) -sign(x) * pi.
-
ABS(x) >= ABS(y) If x neq 0 then ARCTAN2 = -ARCTAN(y/x) + pi/2 * sign(x). If x = 0 then ARCTAN2 = pi/2.