如何使用 C# 轉換弧度中的三角函式角?


要換算弧度中的三角函式角,乘以 Math.PI/180。這會轉換度到弧度。

以下是程式碼:

例子

using System;

class Program {
   static void Main() {
      Console.WriteLine(Math.Cos(45));

      double res = Math.Cos(Math.PI * 45 / 180.0);
      Console.WriteLine(res);

   }
}

在上面,我們使用下面這個公式換算:

Math.PI * angle / 180.0

更新時間:2020 年 6 月 21 日

3K+ 瀏覽量

開啟你的 職業生涯

完成課程獲取認證

開始
廣告
© . All rights reserved.