arc tan2 function

The atan2 function is an inverse trigonometric function. The atan2 function is a two-argument arc tangent (inverse of tan) function, which returns the arc tangent of a coordinate or point in two-dimensional space (n1, n2) calculated as atan(n2/n1).

Syntax:

double atan2(n1,n2)

Semantics:

  • n1, n2: The arguments n1 and n2 are expressions that resolve to numbers.
  • return type: double.

    The resultant angle is expressed in radians and is in the range -pi through pi with the following exceptions:

    • Returns a NULL value in the following cases:
      • If either of the arguments resolves to a NULL value
      • If either of the arguments does not resolve to a number
    • Returns a NaN if either of the arguments resolves to NaN.
Example:
SELECT atan2(n1,n2) FROM Archery
Value of n1 Value of n2 Output
1 1 0.7853981633974483
1 sqrt(3) 1.0471975511965976
2 0 1.5707963267948966