📜  C#| Math.Asin()方法

📅  最后修改于: 2021-05-30 01:48:17             🧑  作者: Mango

Math.Asin()是内置的Math类方法,该方法返回其正弦值作为双值参数给出的角度。如果参数为NaN ,则结果将为NaN

句法:

public static double Asin(double num)

范围:

返回类型:返回以弧度为单位的角度Θ,其类型为System.Double 。在此,角度始终以弧度为单位,即-π/ 2≤Θ≤π/ 2。

注意:如果num的值大于1或小于-1或等于NaN,则此方法始终返回NaN作为结果。要将弧度(返回值)转换为度数,请乘以180 / Math.PI。正的返回值始终表示与x轴成逆时针方向的角度,负的返回值始终表示与x轴成逆时针的角度。

例子:

Input  : Math.Asin(2)
Output : NaN

Input  : Math.Asin(0.3584)
Output : 0.366553473829125
     
Input  : Math.Asin(0.0)
Output : 0

Input  : Math.Asin(-0.0)
Output : 0

Input  : Math.Asin(Double.PositiveInfinity)
Output : NaN

Input  : Math.Asin(Double.NegativeInfinity)
Output : NaN

程序:演示Math.Asin()方法

// C# program to demonstrate working
// of Math.Asin() method
using System;
  
class Geeks {
  
    // Main Method
    public static void Main(String[] args)
    {
        double a = Math.PI;
  
        // using Math.Asin() method
        Console.WriteLine(Math.Asin(a));
  
        // argument is greater than 1
        Console.WriteLine(Math.Asin(2));
          
        Console.WriteLine(Math.Asin(0.3584));
  
        double d = 0.0;
        double e = -0.0;
        double posi = Double.PositiveInfinity;
        double nega = Double.NegativeInfinity;
        double nan = Double.NaN;
  
        // Input positive zero
        // Output 0
        double res = Math.Asin(d);
  
        // converting to degree
        // i.e. output is 0 degree
        double rest = res * (180 / Math.PI);
        Console.WriteLine(rest);
  
        // Input negative zero
        // Output 0
        Console.WriteLine(Math.Asin(e));
  
        // input PositiveInfinity
        // Output NaN
        Console.WriteLine(Math.Asin(posi));
  
        // input NegativeInfinity
        // Output NaN
        Console.WriteLine(Math.Asin(nega));
  
        // input NaN
        // Output NaN
        Console.WriteLine(Math.Asin(nan));
    }
}
输出:
NaN
NaN
0.366553473829125
0
0
NaN
NaN
NaN

参考: https://msdn.microsoft.com/en-us/library/system.math.Asin