角度与弧度间转换
#define PI 3.1415926
#define r2a(x) ((x)*180/PI)
#define a2r(x) ((x)*PI/180)
将角度转换到[0,360)之间的角度
double range_angle_360(double angle)
{
while (angle > 360)
angle -= 360;
while (angle < 0)
angle += 360;
return angle;
}
将角度转换到[-180,180)之间的角度
double range_angle_180(double angle)
{
while (angle >= 180)
angle -= 360;
while (angle < -180)
angle += 360;
return angle;
}
将角度转换到[-PI,PI)之间
double range_angle_PI(double angle)
{
if (angle > M_PI)
angle -= 2 * M_PI;
else if (angle < -M_PI)
angle += 2 * M_PI;
return angle;
}