共用方式為


Complex.FromPolarCoordinates(Double, Double) 方法

定義

從點極座標建立複數。

public:
 static System::Numerics::Complex FromPolarCoordinates(double magnitude, double phase);
public static System.Numerics.Complex FromPolarCoordinates (double magnitude, double phase);
static member FromPolarCoordinates : double * double -> System.Numerics.Complex
Public Shared Function FromPolarCoordinates (magnitude As Double, phase As Double) As Complex

參數

magnitude
Double

大小,這是與數位之間的距離(X 軸和 Y 軸的交集)。

phase
Double

階段,這是從線條到水平軸的角度,以弧度測量。

傳回

複數。

範例

下列範例會使用 FromPolarCoordinates 方法來根據其極座標具現化複數,然後顯示其 MagnitudePhase 屬性的值。

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex c1 = Complex.FromPolarCoordinates(10, 45 * Math.PI / 180);
      Console.WriteLine("{0}:", c1);
      Console.WriteLine("   Magnitude: {0}", Complex.Abs(c1));
      Console.WriteLine("   Phase:     {0} radians", c1.Phase);
      Console.WriteLine("   Phase      {0} degrees", c1.Phase * 180/Math.PI);
      Console.WriteLine("   Atan(b/a): {0}", Math.Atan(c1.Imaginary/c1.Real));
   }
}
// The example displays the following output:
//       (7.07106781186548, 7.07106781186547):
//          Magnitude: 10
//          Phase:     0.785398163397448 radians
//          Phase      45 degrees
//          Atan(b/a): 0.785398163397448
open System
open System.Numerics

let c1 = Complex.FromPolarCoordinates(10., 45. * Math.PI / 180.)
printfn $"{c1}:"
printfn $"   Magnitude: {Complex.Abs(c1)}"
printfn $"   Phase:     {c1.Phase} radians"
printfn $"   Phase      {c1.Phase * 180. / Math.PI} degrees"
printfn $"   Atan(b/a): {Math.Atan(c1.Imaginary / c1.Real)}"
// The example displays the following output:
//       (7.07106781186548, 7.07106781186547):
//          Magnitude: 10
//          Phase:     0.785398163397448 radians
//          Phase      45 degrees
//          Atan(b/a): 0.785398163397448
Imports System.Numerics

Module Example
   Public Sub Main()
      Dim c1 As Complex = Complex.FromPolarCoordinates(10, 45 * Math.Pi / 180)
      Console.WriteLine("{0}:", c1)
      Console.WriteLine("   Magnitude: {0}", Complex.Abs(c1))
      Console.WriteLine("   Phase:     {0} radians", c1.Phase)
      Console.WriteLine("   Phase      {0} degrees", c1.Phase * 180/Math.Pi)
      Console.WriteLine("   Atan(b/a): {0}", Math.Atan(c1.Imaginary/c1.Real))
   End Sub
End Module
' The example displays the following output:
'       (7.07106781186548, 7.07106781186547):
'          Magnitude: 10
'          Phase:     0.785398163397448 radians
'          Phase      45 degrees
'          Atan(b/a): 0.785398163397448

備註

FromPolarCoordinates 方法會根據其極座標具現化複數。

由於複雜平面上有多個點表示法,因此 FromPolarCoordinates 方法的傳回值會正規化。 大小會正規化為正數,而階段會正規化為 -PI 範圍中的值,以 PI。 因此,所產生複數之 PhaseMagnitude 屬性的值可能不等於 magnitudephase 參數的原始值。

若要將 phase 參數的值從度轉換成弧度,請將它乘以 $\frac{\pi}{180}$。

適用於

另請參閱