角度转弧度
要注意此函数输入的为50°45′30″-50.4530为直接变换,以60进一位。
double DMStoRAD(double DMS)//角度转弧度
{
//主函数:
//double DMS;
//cout << "角度:";
//cin >> DMS;
//DMStoRAD(DMS);
const double PI = 3.1415926535;
double RAD;
double d, m, s;
d = int(DMS);
m = int((DMS - d + 10e-10) * 100);//加微小数,防止整数取整时位数变化。
s = int((DMS - d - m/100 + 10e-10) * 10000);
RAD = (d / 180 + m /(60 * 180) + s / (60 * 60 * 180))*PI;
cout << "弧度="<< fixed <<RAD;
return RAD;
}