c++ atna2 特殊值处理
atan2是求解反正切角度的函数,返回值为 (-Pi, Pi]
#include <iostream>
int main()
{
float y1 = -0.000000;
float x1= -0.000000;
float y2 = 0.000000;
float x2 = -0.000000;
float deg1 = atan2(y1, x1);
float deg2 = atan2(y2, x2);
printf("deg1: %f and deg2: %f\n", deg1, deg2);
getchar();
return 0;
}
当x值为0,y值为-0.000000/0.000000时候,返回值需要注意
deg1: -3.141593 and deg2: 3.141593