关于编程中的正弦

发布于 2024-12-20 11:14:17 字数 378 浏览 0 评论 0 原文

我想了解三角学,简短的回答是我不了解。

我画了一个小三角形来摆弄,然后问自己一个问题:“如果我知道斜边和角度的长度,我如何找到其他边的长度?”。

然后我开始读书。显然,角 A 的正弦值应该等于对边的长度除以斜边的长度。所以我想,使用直角三角形,将斜边的长度乘以角度的正弦值就可以得到对边的长度。

1.414 / 1 = .707blahblah * 1.414 = 1 在我的计算器上。

但在每种编程语言中,我都会尝试 sin(45.0) 等于 .8somethingsomething。我尝试了 c++、c#、java、php 和 lua。

输入没有被解释为度数吗?使用什么单位以及如何转换它?我一直看到弧度这个词,如果有人能解释弧度是什么,那将会很有帮助。

I am trying to understand trigonometry and the short answer is that I do not.

I drew a little triangle to mess around with and I asked myself the question, "If I know the length of the hypotenuse and the angle, how do I find the length of the other edges?".

Then I started reading. Apparently, the sine of angle A is supposed to equal the length of the opposite side divided by the length of the hypotenuse. So I figured that, using a right triangle, multiplying the length of the hypotenuse by the sine of the angle would yield the length of the opposing side.

1.414 / 1 = .707blahblah * 1.414 = 1 on my calculator.

But in every programming language I try sin(45.0) equals .8somethingsomething. I tried c++, c#, java, php, and lua.

Is the input not being interpreted as degrees? What unit is being used and how do I convert it? I've been seeing the word Radians, it would be helpful if someone could explain what a Radian is.

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

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

发布评论

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

评论(6

蓝礼 2024-12-27 11:14:17

弧度是角度测量单位,与度一样,只不过圆中有 360 度,而圆中有 2*pi(约 6.28)弧度。您可以通过乘以 pi (3.14159) 再除以 180 将度数转换为弧度。

如果三角形是直角三角形,则该公式有效,是的,大多数编程语言都希望将弧度而不是度数作为参数函数如 sin()cos()

关于下面评论中的论点:如果固定角度不能完全确定一个三角形。

Radians are units of angular measure, like degrees, except that while there are 360 degrees in a circle, there are 2*pi (about 6.28) radians in a circle. You can convert degrees to radians by multiplying by pi (3.14159) and dividing by 180.

The formula works if the triangle is a right triangle, and yes, most programming languages expect radians rather than degrees as arguments to functions like sin() and cos().

Regarding the argument in the comments below: if you fix angle <BAC, side AB, and side BC, you can see that there are two possible positions for point C which preserve the the length D2 for side BC. Therefore <BAC, D1, and D2 do not fully determine a triangle.

天赋异禀 2024-12-27 11:14:17

sin 函数的输入通常以弧度为单位,而不是度数。例如,在 Java 中 sin 的 >documentation 指出:

参数:
a - 角度,以弧度为单位。

首先将角度(以度为单位)乘以 pi/180,转换为弧度

The input to sin functions generally is expected in radians, not degrees. For example, in the Java documentation for sin it's stated that:

Parameters:
a - an angle, in radians.

Convert the angle in degrees to radians first, by multiplying it by pi/180

甜妞爱困 2024-12-27 11:14:17

弧度是圆的半径沿其圆周的距离。由于圆的周长是 pi 乘以半径的 2 倍,因此一个完整的圆中有 2 倍 pi 的弧度。

A radian is the distance of the radius of a circle along its circumference. Since a circle's circumference is 2 times pi times its radius, there are 2 times pi radians in one complete circle.

深空失忆 2024-12-27 11:14:17

是的,你是对的。这些函数都以弧度而不是度数作为输入。

您可以通过将度数乘以 π/180 将度数转换为弧度。

Yes, you are correct. Those functions all take their input in radians, not degrees.

You can convert degrees to radians by multiplying the degrees by π/180.

烟若柳尘 2024-12-27 11:14:17

转换为弧度:弧度=度/180*Pi

Convert to radians: Radian = degree/180*Pi

难理解 2024-12-27 11:14:17

要将度数转换为弧度,请将度数除以 180,然后乘以 pi。

In order to convert from degrees to radians, divide the number in degrees by 180 and multiply by pi.

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