MathF.Atan2(Single,Single)方法用于返回切线为两个指定数字的商的角度。本质上,它返回一个角度θ(以弧度为单位),该角度的值介于-π和π之间。这是正x轴和点(x,y)之间的逆时针角度。
用法: public static float Atan2 (float y, float x);
参数:
y:类型System.Single的点的y坐标。
x:点System.Single的x坐标。
返回值:此方法返回System.Single类型的角度Θ。
注意:角度θ(以弧度为单位),使-π≤θ≤π,且tan(θ)= value1 /value2,其中(value1,value2)是笛卡尔平面中的点。返回值有两个条件:
- 当点位于笛卡尔平面中时
- 当点位于象限的边界上时
示例1:
// C# program to demonstrate the
// MathF.Atan2(Single, Single) Method
using System;
class Geeks {
// Main method
public static void Main()
{
// using MathF.Atan2(Single, Single) Method
// and converting result into degree
Console.Write(MathF.Atan2(10f, 10f) * (180 / MathF.PI));
}
}
输出:
45
示例2:
// C# program to demonstrate the
// MathF.Atan2(Single, Single) Method
using System;
class Geeks {
// Main method
public static void Main()
{
// using MathF.Atan2(Single, Single) Method
// and converting result into degree
Console.Write(MathF.Atan2(0f, -7f) * (180 / MathF.PI));
}
}
输出:
180
相关用法
- C# MathF.Exp()用法及代码示例
- C# MathF.Cos()用法及代码示例
- C# MathF.Tan()用法及代码示例
- C# MathF.Abs()用法及代码示例
- C# MathF.Min()用法及代码示例
- C# MathF.Sin()用法及代码示例
- C# MathF.Pow()用法及代码示例
- C# MathF.Log()用法及代码示例
- C# MathF.Max()用法及代码示例
- C# MathF.Cbrt()用法及代码示例
- C# Char.GetTypeCode()用法及代码示例
- C# Char.GetHashCode()用法及代码示例
- C# MathF.Atan()用法及代码示例
- C# BitArray.RightShift()用法及代码示例
- C# BitArray.LeftShift()用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 MathF.Atan2() Method in C# with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。