在 Java 中查找正弦

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2349367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 06:26:24  来源:igfitidea点击:

Find sine in Java

javamath

提问by relyt

Can anyone give me a quick tip?

谁能给我一个快速提示?

For example....how would I find the sine of 90 degrees?

例如......我将如何找到 90 度的正弦值?

采纳答案by Darin Dimitrov

You could use the Math.sinfunction where the argument is given in radians. Example:

您可以使用Math.sin函数,其中参数以弧度给出。例子:

double result = Math.sin(Math.PI / 2.0);

回答by Michael Borgwardt

Look at the java.lang.Mathclass.

java.lang.Math班级。

回答by polygenelubricants

http://java.sun.com/j2se/1.6.0/docs/api/java/lang/Math.html

http://java.sun.com/j2se/1.6.0/docs/api/java/lang/Math.html

It has a sin(double)method among other mathematical functions. It takes the angle in radian, so you'd have to do the conversion from degree. For that purpose (and others), Math also has the PIconstant.

sin(double)在其他数学函数中有一个方法。它以弧度为单位获取角度,因此您必须从度数进行转换。为此(和其他目的),Math 也有PI常数。

回答by Lucas

use

Math.sin(Math.toRadians(90))

回答by Grzegorz Oledzki

A few tips for you:

给你一些提示:

What if you combine these two tips?

如果将这两个技巧结合起来会怎样?

回答by wcm

The sin function in java.lang.Math expects a parameter expressed in radians.

java.lang.Math 中的 sin 函数需要一个以弧度表示的参数。

I think you should use Math.sin(Math.toRadians(90))

我认为你应该使用 Math.sin(Math.toRadians(90))