【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;
}

posted @ 2013-10-29 16:00  ssh_alitheia  阅读(7328)  评论(0编辑  收藏  举报