Purpose
You can call this function to return the arc tangent of y and x, which is the angle between the ray from (0,0) to the point (x,y) and the x-axis. The return value is expressed in radians and falls 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
yandxare of a numeric data type where their values are not both0, 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