English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C library function double atan2(double y, double x) Returns the value in radians y/x The sign of y and x determines the correct quadrant.
The following is atan2() function declaration.
double atan2(double y, double x)
x -- Represents the floating-point value of the x-axis coordinate.
y -- Represents the floating-point value of the y-axis coordinate.
This function returns y in radians./The inverse tangent of x, the radian interval is [-pi,+pi].
The following example demonstrates atan2() function usage.
#include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, y, ret, val; x = -7.0; y = 7.0; val = 180.0 / PI; ret = atan2 (y,x) * val; printf("x = %lf, y = %lf 的反正切", x, y); printf("Is %lf degrees\n", ret); return(0); }
Let's compile and run the above program, which will produce the following result:
x = -7.000000, y = 7The arctan of .000000 is 135.000000 degrees