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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。