Purpose
ATAN2() returns the arc tangent of y and x, which is the angle between the ray that runs from (0,0) to (x,y) and the x-axis. The return value is given in radians, in the range of (-π, π].
Syntax
ATAN2(y,x)
Parameters
| Parameter | Description |
|---|---|
| x | The value on the x-axis. |
| y | The value on the y-axis. |
Note
y and x are of a numeric data type where their values are not both 0, or are of any data type that can be implicitly converted to a numeric data type.
Return type
If either parameter is of the BINARY_FLOAT or BINARY_DOUBLE data type, the return type is BINARY_DOUBLE. Otherwise, the return type is NUMBER.
Examples
The following example returns the arc tangents of (0,-1), (0,1), (1,0), and (-1,0).
obclient> SELECT ATAN2(0,-1),ATAN2(0,1),ATAN2(1,0),ATAN2(-1,0) FROM DUAL;
+-----------------------------------------+------------+-----------------------------------------+------------------------------------------+
| ATAN2(0,-1) | ATAN2(0,1) | ATAN2(1,0) | ATAN2(-1,0) |
+-----------------------------------------+------------+-----------------------------------------+------------------------------------------+
| 3.1415926535897932384626433832795028842 | 0 | 1.5707963267948966192313216916397514421 | -1.5707963267948966192313216916397514421 |
+-----------------------------------------+------------+-----------------------------------------+------------------------------------------+
1 row in set