| Return Value | The atan2 function returns the arc tangent of y / x. For y = 0 and x = 0, atan2 → NaN. For y = 0 and x > 0, atan2 → 0. For y = 0 and x < 0, atan2 → 2π. |
| Example |
#include <math.h>
#include <stdio.h> /* for printf */
void tst_atan2 (void) {
float x;
float y;
float z;
x = -1.0;
for (y = -10.0; y < 10.0; y += 0.1) {
z = atan2 (y,x);
printf ("ATAN2(%f/%f) = %f\n", y, x, z);
}
/* z approaches -pi as y goes from -10 to 0 */
/* z approaches +pi as y goes from +10 to 0 */
}
|