Bug 503 – Names of arguments to atan2 are backwards

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2006-11-13T23:54:00Z
Last change time
2014-02-15T13:29:04Z
Assigned to
bugzilla
Creator
wbaxter

Comments

Comment #0 by wbaxter — 2006-11-13T23:54:03Z
As seen in the ddoc here: http://www.digitalmars.com/d/phobos/std_math.html and in the original source code in src/phobos/std.math.d atan2 is documented as taking (x,y) arguments, but it should be (y,x). If you look at the std.c.math.atan2l routine that atan2 calls, you'll see that it indeed is documented as taking y,x parameters, as is standard practice for atan2 calls. atan2(y,x) ~ atan(y/x). The labels on the table are also wrong. Here's a corrected version of the ddoc and function: /*************** * Calculates the arc tangent of y / x, * returning a value ranging from -&pi;/2 to &pi;/2. * * $(TABLE_SV * <tr> <th> y <th> x <th> atan(y, x) * <tr> <td> $(NAN) <td> anything <td> $(NAN) * <tr> <td> anything <td> $(NAN) <td> $(NAN) * <tr> <td> &plusmn;0.0 <td> &gt; 0.0 <td> &plusmn;0.0 * <tr> <td> &plusmn;0.0 <td> &plusmn;0.0 <td> &plusmn;0.0 * <tr> <td> &plusmn;0.0 <td> &lt; 0.0 <td> &plusmn;&pi; * <tr> <td> &plusmn;0.0 <td> -0.0 <td> &plusmn;&pi; * <tr> <td> &gt; 0.0 <td> &plusmn;0.0 <td> &pi;/2 * <tr> <td> &lt; 0.0 <td> &plusmn;0.0 <td> &pi;/2 * <tr> <td> &gt; 0.0 <td> &infin; <td> &plusmn;0.0 * <tr> <td> &plusmn;&infin; <td> anything <td> &plusmn;&pi;/2 * <tr> <td> &gt; 0.0 <td> -&infin; <td> &plusmn;&pi; * <tr> <td> &plusmn;&infin; <td> &infin; <td> &plusmn;&pi;/4 * <tr> <td> &plusmn;&infin; <td> -&infin; <td> &plusmn;3&pi;/4 * ) */ real atan2(real y, real x) { return std.c.math.atan2l(y,x); }
Comment #1 by wbaxter — 2006-12-03T01:22:12Z
Looks to be fixed.