用 Java 获取某个角度的反正弦
为了获取 Java 中给定值的反正弦,我们使用 java.lang.Math.acos() 方法。acos() 方法接受需要计算其角度的双值。返回角度的范围介于 0 到 pi。如果参数为 NaN 或大于 1 或小于 -1,则结果为 NaN。
声明 − java.lang.Math.acos() 方法声明如下 −
public static double acos(double a)
此处,a 是计算其反正弦的值。
我们来看一个在 Java 中获取给定值反正弦的程序。
示例
import java.lang.Math;
public class Example {
public static void main(String[] args) {
// get two double numbers in degrees
double x = Math.sqrt(3)/2;
double y = 0.5;
// computing and displaying the arc cosine of these doubles
System.out.println("Arc cosine of " + x + " = " + Math.acos(x));
System.out.println("Arc cosine of " + y + " = " + Math.acos(y));
}
}输出
Arc cosine of 0.8660254037844386 = 0.5235987755982989 Arc cosine of 0.5 = 1.0471975511965979
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP