c++角度与弧度转换
Posted itsc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c++角度与弧度转换相关的知识,希望对你有一定的参考价值。
//角度转换为弧度
double angle_to_radian(double degree, double min, double second)
double flag = (degree < 0)? -1.0 : 1.0; //判断正负
if(degree<0)
degree = degree * (-1.0);
double angle = degree + min/60 + second/3600;
double result =flag * (angle * PI)/180;
return result;
//cout<<result<<endl;
//弧度转换为角度
void radian_to_angle(double rad, double ang[])
double flag = (rad < 0)? -1.0 : 1.0;
if(rad<0)
rad = rad * (-1.0);
double result = (rad*180)/PI;
double degree = int(result);
double min =(result - degree)*60;
double second = (min - int(min)) * 60;
ang[0] = flag * degree;
ang[1] = int(min);
ang[2] = second;
以上是关于c++角度与弧度转换的主要内容,如果未能解决你的问题,请参考以下文章