
A function that can be used in Formulas. The argument angle.
arctan2
(y
, x
)
arctan2
is undefined.
assert arctan2 (0.0, 3.0) = 0
assert abs (arctan2 (3.0, 3.0)  pi/4) < 1e17
assert abs (arctan2 (3.0, 0.0)  pi/2) < 1e17
assert abs (arctan2 (3.0, 3.0)  3*pi/4) < 1e17
assert abs (arctan2 (0.0, 3.0)  pi) < 1e17
assert abs (arctan2 (3.0, 3.0) + 3*pi/4) < 1e17
assert abs (arctan2 (3.0, 0.0) + pi/2) < 1e17
assert abs (arctan2 (3.0, 3.0) + pi/4) < 1e17
;assert arctan2 (0.0, 0.0) = undefined
In C, and therefore in Numpy, arctan2
has arbitrary values where it cannot be defined. Thus numpy.arctan2 (0.0, +0.0)
is 0, numpy.arctan2 (+0.0, 0.0)
is +π, and numpy.arctan2 (0.0, 0.0)
is −π. The function is then even defined for e.g. x = −∞ and y = +∞, where it is 3π/4. In all these cases, arctan
returns undefined
in Praat. This doesn’t mean that the function is very sane in Praat, as it is still discontinuous for small y
:
writeInfoLine: arctan2 (1e308, 1.0), " ", arctan2 (1e308, 1.0)
=>
3.141592653589793 3.141592653589793
which are indistinguishable from +π and −π, respectively.
© Paul Boersma 2023