[Previous]
[Contents]
[Next]

atan2()

compute the arctangent, determining the quadrant

Synopsis:

#include <math.h>
double atan2( double y, double x );

Description:

The atan2() function computes the principal value of the arctangent of y/x, using the signs of both arguments to determine the quadrant of the return value. A domain error occurs if both arguments are zero.

Returns:

The arctangent of y/x, in the range (-PI, PI).

When the argument is outside the permissible range, the matherr() function is called. Unless the default matherr() function is replaced, it will set the global variable errno to EDOM, and print a "DOMAIN error" diagnostic message using the stderr stream.

Examples:

#include <stdio.h>
#include <math.h>

void main()
  {
    printf( "%f\n", atan2( .5, 1. ) );
  }

produces the output:

0.463648

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

acos(), asin(), atan(), errno, matherr()


[Previous]
[Contents]
[Next]