atan2()                  Calculate Arc Tangent of y/x
 
 #include <math.h>
 
 double     atan2(y,x);                  Arc tangent (in radians)
 double     y;                           y coordinate value
 double     x;                           x coordinate value
 
    atan2() returns the arc tangent of 'y'/'x' in radians.  The return
    value will be in the range -pi to pi.  'x' and 'y' cannot both be
    0.0.
 
    Returns:    Arc tangent of 'y'/'x'.  If both 'x' and 'y' are 0.0,
                then matherr() is called with a DOMAIN error; a domain
                error message is printed to 'stderr'; 'errno' (defined in
                <stdlib.h>) is set to EDOM (defined in math.h), and 0.0
                is returned.
 
      Notes:    Error handling can be modified by using the matherr()
                routine.
 
 
  -------------------------------- Example ---------------------------------
 
    The following statements print the arc tangent of 20.0/0.0 and try to
    calculate the arc tangent of 0.0/0.0, which causes an EDOM error.
 
         #include <math.h>        /* for atan2() and EDOM */
         #include <stdio.h>       /* for printf() */
         #include <stdlib.h>      /* for errno */
 
         main()
         {
             double arc_tan;
 
             arc_tan = atan2(20.0, 0.0);  /* arc_tan = pi/2 (1.570796) */
             printf("arc tangent of 20/0 is %.6f radians\n", arc_tan);
             errno = 0;
             arc_tan = atan2(0.0, 0.0);  /* arc_tan = 0.0, causes an error */
             /* a DOMAIN error message is also printed to stderr */
             if (errno == EDOM)
                 printf("DOMAIN error in atan2()\n");
         }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster