正弦函数 [英] Sine function

查看:86
本文介绍了正弦函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能给我一个粗略的想法,如何获得像Math.Sin这样的三角函数
函数的值?算法是什么?我发现在这个函数中放置一个

大数字(> 8000)确实减慢了速度。为什么

那个?


谢谢,


Owkmann

解决方案



罪(360)=罪(0)。


这样做。

Sin(largeNumber%360);


首先,Math.Sin以弧度为单位,而不是度数,所以

360是错误的分母。


其次,参数是双精度的,其中没有模数

运算符,即使你可以得到一个相当准确的2p值。

甚至Math.DivRem都没有为双打提供过载。


相信我无需考虑逻辑通过即可回复。


角度以弧度为单位,因此它不应该是360度,而是2 pi。


免责声明:

未经测试的代码。


jliu

johnliu.net


Can someone give me a rough idea how a value is obtained for a trigonometric
function like Math.Sin? What is the algorithm? I''m finding that putting a
large number in this function ( > 8000 ) really slows things down. Why is
that?

Thanks,

Owkmann

解决方案


Sin(360) = Sin(0).

do this.

Sin( largeNumber % 360 );


First of all, Math.Sin takes its argument in radians, not degrees, so
360 is the wrong denominator.

Second, the argument is a double, for which there is no modulo
operator, even if you could get a reasonably accurate value for 2p.
Not even Math.DivRem provides an overload for doubles.


Trust me to reply without thinking the logic through.

The angle is measured in radians, so it shouldn''t be 360, but 2 pi.

Disclaimer:
Untested code.

jliu
johnliu.net


这篇关于正弦函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆