| 1 |
<html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 |
<title>arctan2</title> |
| 3 |
<style> |
| 4 |
td { padding-left: 5pt; padding-right: 5pt; } |
| 5 |
th { padding-left: 5pt; padding-right: 5pt; } |
| 6 |
code { white-space: pre-wrap; } |
| 7 |
dd { white-space: pre-wrap; } |
| 8 |
</style> |
| 9 |
</head><body bgcolor="#FFFFFF"> |
| 10 |
|
| 11 |
<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Monaco,Courier" size=6 color="#999900"><b> |
| 12 |
arctan2 |
| 13 |
</b></font></table></table> |
| 14 |
<p>A function that can be used in <a href="Formulas.html">Formulas</a>. The argument angle.</p> |
| 15 |
<h2>Syntax and semantics</h2> |
| 16 |
<dl> |
| 17 |
<dt><b><code><font size=+1>arctan2</font></code></b> (<i><code><font size=+1>y</font></code></i>, <i><code><font size=+1>x</font></code></i>) |
| 18 |
<dd>the angle (in radians) from the <i>X</i> axis to the point (<i>x</i>, <i>y</i>) in two-dimensional space; positive (i.e. measured counterclockwise) for <i>y</i> > 0, and negative (and measured clockwise) for <i>y</i> < 0. For <i>y</i> = 0, it’s 0 if <i>x</i> > 0, and <i>π</i> if <i>x</i> < 0. In the point (0, 0), <code><font size=+1>arctan2</font></code> is undefined.</dd> |
| 19 |
</dl> |
| 20 |
<h2>Tests</h2> |
| 21 |
<code> <a href="_assert_.html">assert</a> <b>arctan2</b> (0.0, 3.0) = 0<br></code> |
| 22 |
<code> <a href="_assert_.html">assert</a> <a href="_abs_.html">abs</a> (<b>arctan2</b> (3.0, 3.0) - pi/4) < 1e-17<br></code> |
| 23 |
<code> <a href="_assert_.html">assert</a> <a href="_abs_.html">abs</a> (<b>arctan2</b> (3.0, 0.0) - pi/2) < 1e-17<br></code> |
| 24 |
<code> <a href="_assert_.html">assert</a> <a href="_abs_.html">abs</a> (<b>arctan2</b> (3.0, -3.0) - 3*pi/4) < 1e-17<br></code> |
| 25 |
<code> <a href="_assert_.html">assert</a> <a href="_abs_.html">abs</a> (<b>arctan2</b> (0.0, -3.0) - pi) < 1e-17<br></code> |
| 26 |
<code> <a href="_assert_.html">assert</a> <a href="_abs_.html">abs</a> (<b>arctan2</b> (-3.0, -3.0) + 3*pi/4) < 1e-17<br></code> |
| 27 |
<code> <a href="_assert_.html">assert</a> <a href="_abs_.html">abs</a> (<b>arctan2</b> (-3.0, 0.0) + pi/2) < 1e-17<br></code> |
| 28 |
<code> <a href="_assert_.html">assert</a> <a href="_abs_.html">abs</a> (<b>arctan2</b> (-3.0, 3.0) + pi/4) < 1e-17<br></code> |
| 29 |
<code> ;<a href="_assert_.html">assert</a> <b>arctan2</b> (0.0, 0.0) = undefined<br></code> |
| 30 |
<h2>Edge cases</h2> |
| 31 |
<p>In C, and therefore in Numpy, <code><font size=+1>arctan2</font></code> has arbitrary values where it cannot be defined. Thus <code><font size=+1>numpy.arctan2 (0.0, +0.0)</font></code> is 0, <code><font size=+1>numpy.arctan2 (+0.0, -0.0)</font></code> is +<i>π</i>, and <code><font size=+1>numpy.arctan2 (-0.0, -0.0)</font></code> is −<i>π</i>. The function is then even defined for e.g. <i>x</i> = −∞ and <i>y</i> = +∞, where it is 3<i>π</i>/4. In all these cases, <code><font size=+1>arctan</font></code> returns <code><font size=+1>undefined</font></code> in Praat. This doesn’t mean that the function is very sane in Praat, as it is still discontinuous for small <i><code><font size=+1>y</font></code></i>:</p> |
| 32 |
<code> writeInfoLine: <b>arctan2</b> (1e-308, -1.0), " ", <b>arctan2</b> (-1e-308, -1.0)<br></code> |
| 33 |
<code style="color:red">=></code><br> |
| 34 |
<code> 3.141592653589793 -3.141592653589793<br></code> |
| 35 |
<p>which are indistinguishable from +<i>π</i> and −<i>π</i>, respectively.</p> |
| 36 |
<h3>Links to this page</h3> |
| 37 |
<ul> |
| 38 |
<li><a href="Functions.html">Functions</a> |
| 39 |
</ul> |
| 40 |
<hr> |
| 41 |
<address> |
| 42 |
<p>© Paul Boersma 2023</p> |
| 43 |
</address> |
| 44 |
</body> |
| 45 |
</html> |