Math.Atan()是一个内置的Math类方法,该方法返回以正切值作为双值参数给出的角度。如果参数为NaN,则结果将为NaN。
用法:
public static double Atan(double num)
参数:
- num:它是表示切线的数字,并且此参数的类型为System.Double。
返回类型:返回以弧度为单位的角度Θ,其类型为System.Double。在此,角度始终以弧度为单位,即-π/2≤Θ≤π/2。
例子:
Input : Math.Atan(1) Output : 0.785398163397448 Input : Math.Atan(0.0) Output : 0 Input : Math.Atan(-0.0) Output : 0 Input : Math.Atan(Double.PositiveInfinity) Output : 1.5707963267949 Input : Math.Atan(Double.NegativeInfinity) Output : -1.5707963267949
程序:为了说明Math.Atan()方法
// C# program to demonstrate working
// of Math.Atan() method
using System;
class Geeks {
// Main Method
public static void Main(String []args)
{
double a = Math.PI;
// using Math.Atan() method
Console.WriteLine(Math.Atan(a));
double d = 0.0;
double e = -0.0;
double posi = Double.PositiveInfinity;
double nega = Double.NegativeInfinity;
double nan = Double.NaN;
Console.WriteLine(Math.Atan(1));
// Input positive zero
// Output positive zero
Console.WriteLine(Math.Atan(d));
// Input negative zero
// Output positive zero
Console.WriteLine(Math.Atan(e));
// input PositiveInfinity
// Output 1.5707963267949
Console.WriteLine(Math.Atan(posi));
// input NegativeInfinity
// Output -1.5707963267949
Console.WriteLine(Math.Atan(nega));
// input NaN
// Output NaN
Console.WriteLine(Math.Atan(nan));
}
}
输出:
1.26262725567891 0.785398163397448 0 0 1.5707963267949 -1.5707963267949 NaN
参考:https://msdn.microsoft.com/en-us/library/system.math.atan
相关用法
- C# DateTimeOffset.Add()用法及代码示例
- C# String.Contains()用法及代码示例
- C# Math.Sin()用法及代码示例
- C# Math.Cos()用法及代码示例
- C# Dictionary.Add()用法及代码示例
- C# Math.Tan()用法及代码示例
- C# Math.Abs()方法用法及代码示例
- C# Math.Exp()用法及代码示例
- C# Math.Abs()函数用法及代码示例
注:本文由纯净天空筛选整理自Mithun Kumar大神的英文原创作品 C# | Math.Atan() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。