Returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis.
math:atan2
( $y
as xs:double
,$x
as xs:double
xs:double
The result is the value of atan2(y, x)
as defined in the specification of the atan2
function applied to
64-bit binary floating point values. The result is in the range -π
to +π radians.
The expression math:atan2(+0.0e0, 0.0e0)
returns 0.0e0
.
The expression math:atan2(-0.0e0, 0.0e0)
returns -0.0e0
.
The expression math:atan2(+0.0e0, -0.0e0)
returns 3.141592653589793e0
.
The expression math:atan2(-0.0e0, -0.0e0)
returns -3.141592653589793e0
.
The expression math:atan2(-1, 0.0e0)
returns -1.5707963267948966e0
.
The expression math:atan2(+1, 0.0e0)
returns 1.5707963267948966e0
.
The expression math:atan2(-0.0e0, -1)
returns -3.141592653589793e0
.
The expression math:atan2(+0.0e0, -1)
returns 3.141592653589793e0
.
The expression math:atan2(-0.0e0, +1)
returns -0.0e0
.
The expression math:atan2(+0.0e0, +1)
returns +0.0e0
.
The treatment of the underflow
exception is defined in .
If either argument is NaN
then the result is NaN
.
If $y
is positive and $x
is positive and finite, then (subject
to rules for overflow, underflow and approximation) the value of atan2($y,
$x)
is atan($y div $x)
.
If $y
is positive and $x
is negative and finite, then (subject
to the same caveats) the value of atan2($y, $x)
is π
- atan($y div $x)
.
Some results for special values of the arguments are shown in the examples below.