atan2(y,x)函数怎么用

来源:百度知道 编辑:UC知道 时间:2024/05/18 18:41:06
比如我输入x=3,y=3,怎么用这个函数,得到什么结果?

atan2(y,x)是表示X-Y平面上所对应的(x,y)坐标的角度,它的值域范围是(-Pi,Pi)
用数学表示就是:atan2(y,x)=arg(y/x)-Pi
当y<0时,其值为负,
当y>0时,其值为正.

例子:
#include <stdio.h>
#include <math.h>

int main(void)
{
double result;
double x = 20.0, y = 10.0;

result = atan2(y, x);
printf("The arc tangent ratio of %lf is %lf\n", (y / x), result);
return 0;
}