compute the arctangent, determining the quadrant
#include <math.h> double atan2( double y, double x );
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.
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.
#include <stdio.h> #include <math.h> void main() { printf( "%f\n", atan2( .5, 1. ) ); }
produces the output:
0.463648
ANSI
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
acos(), asin(), atan(), errno, matherr()