www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 503] New: Names of arguments to atan2 are backwards

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=503

           Summary: Names of arguments to atan2 are backwards
           Product: D
           Version: 0.173
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: wbaxter gmail.com


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 -π/2 to π/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); }


-- 
Nov 13 2006
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=503


wbaxter gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from wbaxter gmail.com  2006-12-03 01:22 -------
Looks to be fixed.


-- 
Dec 02 2006