math:atan2
Returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis.
Signature
math:atan2(
$y as xs:double,
$x as xs:double
) as xs:doubleProperties
This function is deterministic, context-independent, and focus-independent.
Rules
The result is the value of atan2(y, x) as defined in the [IEEE 754-2008] specification of the atan2 function applied to
64-bit binary floating point values. The result is in the range -π
to +π radians.
Notes
The treatment of the underflow exception is defined in Arithmetic operators on numeric values.
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.
Examples
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.