我有一個計算atan在cpp中的問題。 M_PI已經被聲明爲3.14159 ....atan(-M_PI_2)沒有回退-90º
我的代碼是:
double distanceNormalized = 1;// set constant con check value
double angle = atan(distanceNormalized * (-M_PI_2)); // atan(-PI/2) must be -1 in rad
stringstream ss;
ss << " Angle: " << angle*180/M_PI;
cout << ss << endl;
但在日誌中我得到:
Angle: -57.5184
參考說admit [-pi/2,+ PI/2]弧度。 發生了什麼事?
-57是一個rad =) – kassak 2013-03-18 10:54:20