- Categories:
Numeric functions (Trigonometric)
ATAN2¶
Computes the inverse tangent (arc tangent) of the ratio of its two arguments.
For example, if x > 0, then the expression ATAN2(y, x) is equivalent to ATAN(y/x).
The arc tangent is the angle between:
The X axis.
The ray from the point (0,0) to the point (X, Y) (where X and Y are not both 0).
- See also:
Syntax¶
ATAN2( <y> , <x> )
Note that the first parameter is the Y coordinate, not the X coordinate.
Arguments¶
yThis parameter is the Y coordinate of the point at the end of the ray. The data type must be FLOAT or DECFLOAT.
xThis parameter is the X coordinate of the point at the end of the ray. The data type must be FLOAT or DECFLOAT.
Returns¶
If any of the input expressions is of type DECFLOAT, the returned type is DECFLOAT. Otherwise, the returned type is FLOAT.
The returned value is in radians, not degrees.
The returned value is a number in the interval [-pi, pi].
Usage notes¶
If the data type of an argument is a numeric data type other than DOUBLE, then the value is converted to DOUBLE.
If the data type of an argument is string, the value is converted to DOUBLE if possible.
If the data type of an argument is any other data type, the function returns an error.
If either argument is NULL, the returned value is NULL.
Examples¶
SELECT ATAN2(5, 5);
--------------+
ATAN2(5, 5) |
--------------+
0.7853981634 |
--------------+