DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS


     #include <math.h>

     double
     atan2(double y, double x)

     float
     atan2f(float y, float x)


DESCRIPTION

     The atan2() and atan2f() functions compute the principal value of the arc
     tangent of y/x, using the signs of both arguments to determine the quad-
     rant of the return value.


RETURN VALUES

     The atan2 function, if successful, returns the arc tangent of y/x in the
     range [-pi, +pi] radians.  If both x and y are zero, the global variable
     errno is set to EDOM. On the VAX:

     atan2(y, x):=        atan(y/x)            if x > 0,
                          sign(y)*(pi - atan(|y/x|))         if x < 0,
                          0                    if x = y = 0, or
                          sign(y)*pi/2         if x = 0 y.


NOTES

     The function atan2() defines "if x > 0," atan2(0, 0) = 0 on a VAX despite
     that previously atan2(0, 0) may have generated an error message.  The
     reasons for assigning a value to atan2(0, 0) are these:

           1.   Programs that test arguments to avoid computing atan2(0, 0)
                must be indifferent to its value.  Programs that require it to
                be invalid are vulnerable to diverse reactions to that inva-
                lidity on diverse computer systems.

           2.   The atan2() function is used mostly to convert from rectangu-
                lar (x,y) to polar (r,theta) coordinates that must satisfy x =
                r*cos theta and y = r*sin theta.  These equations are satis-
                fied when (x=0,y=0) is mapped to (r=0,theta=0) on a VAX.  In
                general, conversions to polar coordinates should be computed
                thus:

                      r    := hypot(x,y);  ... := sqrt(x*x+y*y)
                      theta     := atan2(y,x).

           3.   The foregoing formulas need not be altered to cope in a rea-
                sonable way with signed zeros and infinities on a machine that
                conforms to IEEE 754; the versions of hypot(3) and atan2()
                provided for such a machine are designed to handle all cases.
                That is why atan2(+-0, -0) = +-pi for instance.  In general
                the formulas above are equivalent to these:

                      r := sqrt(x*x+y*y); if r = 0 then x := copysign(1,x);

Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.