C#|数学。Acos()方法

数学Acos() 是一个内置的数学类方法,它返回余弦作为双值参数给出的角度。如果论点是正确的 ,那么结果将是 .

null

语法:

public static double Acos(double num)

参数:

号码: 它是表示余弦的数字,该参数的类型为 系统双重的 .一定是 大于或等于-1 但是 小于或等于1 .

返回类型: 返回角度Θ,以弧度为单位,其类型为 系统双重的 .这里的角度总是以弧度为单位,因此0≤ Θ ≤ π.

注: 如果num的值大于1或小于-1或等于 ,则此方法始终返回 结果呢。将弧度(返回值)转换为度 乘以180/数学。圆周率 .

例如:

Input  : Math.Acos(2)
Output : NaN

Input  : Math.Acos(0.3584)
Output : 1.20424285296577
     
Input  : Math.Acos(0.0)
Output : 1.5707963267949

Input  : Math.Acos(-0.0)
Output : 1.5707963267949

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

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

节目: 来说明数学。Acos()方法

// C# program to demonstrate working
// of Math.Acos() method
using System;
class Geeks {
// Main Method
public static void Main(String[] args)
{
double a = Math.PI;
// using Math.Acos() method
Console.WriteLine(Math.Acos(a));
// argument is greater than 1
Console.WriteLine(Math.Acos(2));
Console.WriteLine(Math.Acos(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 1.5707963267949
double res = Math.Acos(d);
// converting to degree
// i.e output will be 90 degree
double rest = res * (180 / Math.PI);
Console.WriteLine(rest);
// Input negative zero
// Output 1.5707963267949
Console.WriteLine(Math.Acos(e));
// input PositiveInfinity
// Output NaN
Console.WriteLine(Math.Acos(posi));
// input NegativeInfinity
// Output NaN
Console.WriteLine(Math.Acos(nega));
// input NaN
// Output NaN
Console.WriteLine(Math.Acos(nan));
}
}


输出:

NaN
NaN
1.20424285296577
90
1.5707963267949
NaN
NaN
NaN

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

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享