C library functions - atan2 ()
description
C library functionsdouble atan2 (doubly y, double x ) Returns the yexpressed in radians/ xarctangent. Symbol values y and x determine the correct quadrant.
statement
The following is a statement atan2 () function.
double atan2(doubly y, double x)
parameter
- x - x coordinate on behalf of floating-point values.
- y - y-axis represents the coordinates of floating-point values.
return value
This function returns the y expressed in radians / x arctangent, in radians interval [-pi, + pi].
Examples
The following example demonstrates the atan2 () function is used.
#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("是 %lf 度\n", ret); return(0); }
Let's compile and run the above program, which will result in the following:
x = -7.000000, y = 7.000000 的反正切是 135.000000 度