在 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
Find sine in Java
提问by relyt
Can anyone give me a quick tip?
谁能给我一个快速提示?
For example....how would I find the sine of 90 degrees?
例如......我将如何找到 90 度的正弦值?
采纳答案by Darin Dimitrov
回答by Michael Borgwardt
Look at the java.lang.Math
class.
看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 PI
constant.
它sin(double)
在其他数学函数中有一个方法。它以弧度为单位获取角度,因此您必须从度数进行转换。为此(和其他目的),Math 也有PI
常数。
回答by Lucas
use
用
Math.sin(Math.toRadians(90))
回答by Grzegorz Oledzki
A few tips for you:
给你一些提示:
- Math#sin() function, which takes angle in radians,
- radian = pi / 180 degrees
- Math#sin() 函数,以弧度表示角度,
- 弧度 = 圆周率 / 180 度
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))