C 库函数 - atan2( )
https://www.runoob.com/cprogramming/c-function-atan2.html
C库函数double atan2(double y,double x)返回以弧度表示的y/x的反正切
y和x的值的符号决定了正确的象限
弧度区间为[-pi,+pi]
#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);
}
运行结果:
x = -7.000000, y = 7.000000 的反正切是 135.000000 度