用 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