在我的代码,我有:为什么我的程序使电脑看起来做不好的三角?
console.log(distance_along);
console.log('Cosine: ' + Math.cos(2 * Math.PI * distance_along));
var added_degrees =
(ANCIENT_CLOCK.cos(2 * Math.PI * distance_along) * ANCIENT_CLOCK.earth_tilt);
这将产生输出:
-0.2567721374914637
Cosine: -0.04253775592822526
随着越来越多的代码在http://JonathansCorner.com/ancient-clock
我做了什么错,我怎么能解决这个问题?第一个记录值以弧度为单位(以2 π的乘数为模),第二个记录值是完全不同数字的余弦值。为什么?
我以前的帖子给人的印象是我不知道Math.cos()
。我确实知道Math.cos()
,并且不知道为什么它会为其他人在JavaScript和PHP中报告的cos(-0.2567721374914637)
产生差异值。
我正在运行Mint Chrome。
你想到'COS(-0.2567721374914637)'和'cos(2 * Math.PI * -0.2567721374914637)'是相同的值? – 2013-05-05 23:59:55
可能重复[如何在JavaScript中使用trig?](http://stackoverflow.com/questions/16387316/how-does-trig-work-in-javascript) – 2013-05-06 00:04:56
我也很困惑,javascripts'Math.cos (-1.6)'='〜-0.029',但我的Windows计算器说'cos(-1.6)'='〜1' – 2013-05-06 00:07:43