Math.atan() 返回输入

发布于 2024-10-20 00:08:33 字数 458 浏览 4 评论 0原文

我在 Math.atan 返回与输入相同的值时遇到问题。

public double inchToMOA( double in, double range){
        double rangeIn = 36*range;
        double atan = (in / rangeIn) * -1.0;
        double deg = Math.atan(atan);
        double moa = deg * 60;
        return moa;
    }

我将所有这些都放在一行中,但我将其分解为不同的变量,看看是否能找出它不起作用的原因。如果 in = -10 且 range = 300,则 atan 约为 -.00094。角度应约为 -.053 度,但 math.atan 返回 -.00094,与输入相同。

我的数字对于 math.atan 来说太小了吗?

I'm having a problem with Math.atan returning the same value as the input.

public double inchToMOA( double in, double range){
        double rangeIn = 36*range;
        double atan = (in / rangeIn) * -1.0;
        double deg = Math.atan(atan);
        double moa = deg * 60;
        return moa;
    }

I had this all in one line, but I broke it down into different variables to see if I could find out why it wasn't working. if in = -10 and range = 300, then atan is about -.00094. The angle should be about -.053 degrees, but math.atan is returning -.00094, the same as the input.

Is my number too small for math.atan?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酷炫老祖宗 2024-10-27 00:08:33

反正切在这里描述:

http://mathworld.wolfram.com/InverseTangent.html

我不知道不认为你的论点是这里的问题。

当然,您意识到计算机三角函数处理的是弧度而不是度数,对吧?

Inverse tangent is described here:

http://mathworld.wolfram.com/InverseTangent.html

I don't think your argument is the problem here.

You realize, of course, that computer trig functions deal in radians rather than degrees, right?

等风也等你 2024-10-27 00:08:33

可能只是这样。如果您查看数学中正切函数的严格定义,您会发现对于较小的“x”值,tan(x) = sin(x)/cos(x)

lim x->0, sin(x) = x
lim x->0, cos(x) = 1

因此,您可以看到 lim x->0, tan(x) -> x 表示它的倒数,arctan,返回给定的值。至于 Math.atan 的数值准确性,我认为作者已经竭尽全力确保其数值准确性。

It might just be. If you look at the strict definition of the tangent function in mathematics what you see if that tan(x) = sin(x)/cos(x) for small values of "x"

lim x->0, sin(x) = x
lim x->0, cos(x) = 1

hence, you could see that lim x->0, tan(x) -> x meaning that it's inverse, arctan, returns the value it is given. As to the numerical accuracy of Math.atan I would think that the authors had gone to great lengths to ensure it's numerical accuracy.

夜深人未静 2024-10-27 00:08:33

Math.atan 没有任何问题。对于接近零的输入,其值接近 1:1 线性,与原点相交。因此,越接近零,输入的变化就越小。

There's nothing wrong with Math.atan. Its value is nearly 1:1 linear, intersecting the origin, for inputs close to zero. So the closer you are to zero the less change from the input there will be.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文