| Firebird Documentation Index → Firebird 2.1 Language Ref. Update → Internal functions → ATAN2() |
![]() |
Find a more recent version at Firebird 5.0 Language Reference: ATAN2()
Available in: DSQL, PSQL
Added in: 2.1
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 -π/2 and π/2.
Result type: DOUBLE PRECISION
Syntax:
ATAN2 (y,x)
The result is an angle in the range [-π, π].
If
xis negative, the result is π ifyis 0, and -π ifyis -0.If both
yandxare 0, the result is meaningless. Starting with Firebird 3 (!), an error will be raised if both arguments are 0.
If the external function
ATAN2 is declared in your database, it will override the
internal function. To make the internal function available, DROP or ALTER the external
function (UDF).
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 that ATAN2(0, 0) is undefined.
If x is greater than 0,
ATAN2(y, x)
is the same as
ATAN(y/x).
If both sine and cosine of the angle are already known,
ATAN2(sin,
cos) gives the angle.
| Firebird Documentation Index → Firebird 2.1 Language Ref. Update → Internal functions → ATAN2() |