当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java Math.asin()用法及代码示例


java.lang.Math.asin() 用于计算角度的三角反正弦。反正弦也称为正弦的逆。此方法返回 -Î/2 和 Î/2 之间的值。

用法

public static double asin(double a)

参数

a = the value whose arc sine is to be returned.

返回

It returns the arc sine of the argument.
  • 如果参数为正数或负数,此方法将返回反正弦值。
  • 如果参数为 NaN 或超出范围 -1 和 1,则此方法将返回 NaN。
  • 如果参数为零,此方法将返回与参数相同符号的零。

例子1

public class AsinExample1
{
    public static void main(String[] args) 
    {
        double a = 1.0;
        System.out.println(Math.asin(a));
    }
}

输出:

1.5707963267948966

例子2

public class AsinExample2
{
    public static void main(String[] args) 
    {
        double a = -1.0;
        System.out.println(Math.asin(a));
    }
}

输出:

-1.5707963267948966

例子3

public class AsinExample3
{
    public static void main(String[] args) 
    {
        double a = 1.820;
        // value of a is greater than 1 so Output is NaN
        System.out.println(Math.asin(a));
    }
}

输出:

NaN

示例 4

public class AsinExample4
{
    public static void main(String[] args) 
    {
        double a = Math.PI;
        // return NaN because Math.PI value is 3.414 that is greater than 1
        System.out.println(Math.asin(a));
    }
}

输出:

NaN

例 5

public class AsinExample5
{
    public static void main(String[] args) 
    {
        double a = Math.PI;
        double b = Math.toRadians(a);
        System.out.println(Math.asin(b));
    }
}

输出:

0.054858647341251204






相关用法


注:本文由纯净天空筛选整理自 Java Math.asin() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。