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
posted @ 2020-08-04 16:04  采男孩的小蘑菇  阅读(301)  评论(0编辑  收藏  举报