8.2.5. ATAN2()
Available in
DSQL, PSQL
Possible name conflict
YES → Read details
Syntax
ATAN2 (y, x)
Parameter | Description |
---|---|
y | An expression of a numeric type |
x | An expression of a numeric type |
Result type
DOUBLE PRECISION
Description
Returns the angle whose sine-to-cosine ratio is given by the two arguments, and whose sine and cosine signs correspond to the signs of the arguments. This allows results across the entire circle, including the angles -pi/2 and pi/2.
The result is an angle in the range [-pi, pi].
If x is negative, the result is pi if y is 0, and -pi if y is -0.
If both y and x are 0, the result is meaningless. Starting with Firebird 3, an error will be raised if both arguments are 0. At v.2.5.4, it is still not fixed in lower versions. For more details, visit Tracker ticket CORE-3201.
Notes
A fully equivalent description of this function is the following:
ATAN2(*y*, *x*)
is the angle between the positive X-axis and the line from the origin to the point (x, y). This also makes it obvious thatATAN2(0, 0)
is undefined.If x is greater than 0,
ATAN2(*y*, *x*)
is the same asATAN(*y*/*x*)
.If both sine and cosine of the angle are already known,
ATAN2(*sin*, *cos*)
gives the angle.