Sin cos 函数给出大于 90 度的错误结果
Sin cos function giving wrong results for degrees greater than 90
当我使用
cout<<"Cos: "<<cos(_theta)<<" Sin: "<<sin(_theta)<<endl;
其中 _theta = 180,它给出输出,
Cos: -0.59846 Sin: -0.801153
但输出应该是
Cos: -1 Sin: 0
我不明白为什么会这样!
函数 cos 和 sin 接收以弧度而不是度为单位的角度。
询问 google 关于 "cos(180)" => -0.59846006905
这是因为它使用的是弧度而不是度数。
以弧度表示,180°是半个圆,所以是pi,求google cos(pi) => -1
:)
当我使用
cout<<"Cos: "<<cos(_theta)<<" Sin: "<<sin(_theta)<<endl;
其中 _theta = 180,它给出输出,
Cos: -0.59846 Sin: -0.801153
但输出应该是
Cos: -1 Sin: 0
我不明白为什么会这样!
函数 cos 和 sin 接收以弧度而不是度为单位的角度。
询问 google 关于 "cos(180)" => -0.59846006905
这是因为它使用的是弧度而不是度数。
以弧度表示,180°是半个圆,所以是pi,求google cos(pi) => -1
:)