Purpose
The ATAN2 function returns the angle between the x-axis and the line from the origin to the point (x, y). The result is in radians and ranges from -π to π.
Syntax
ATAN2(y,x)
Parameters
| Parameter | Description |
|---|---|
| x | The x-coordinate. |
| y | The y-coordinate. |
Note
y and x can be numeric data types or parameters that can be implicitly converted to numeric data types. They cannot both be 0.
Return type
If either parameter is of type BINARY_FLOAT or BINARY_DOUBLE, the function returns BINARY_DOUBLE. Otherwise, it returns a NUMBER value.
Examples
Return the arctangent of the following points: (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
