Compartir a través de


Complex.Phase Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the phase of a complex number.

Namespace:  System.Numerics
Assembly:  System.Numerics (in System.Numerics.dll)

Syntax

'Declaration
Public ReadOnly Property Phase As Double
public double Phase { get; }

Property Value

Type: System.Double
The phase of a complex number, in radians.

Remarks

For a complex number a + bi, the phase is computed as Math.Atan2(b, a).

You can identify a complex number by its Cartesian coordinates on the complex plane or by its polar coordinates. The phase (argument) of a complex number is the angle to the real axis of a line drawn from the point of origin (the intersection of the x-axis and the y-axis) to the point represented by the complex number. The magnitude (represented by the Magnitude property) is the distance from the point of origin to the point that is represented by the complex number.

You can instantiate a complex number based on its polar coordinates instead of its Cartesian coordinates by calling the FromPolarCoordinates method.

To convert the phase from radians to degrees, multiply it by 180/Math.PI.

Examples

The following example uses the FromPolarCoordinates method to instantiate a complex number based on its polar coordinates, and then displays the value of its Magnitude and Phase properties.

Imports System.Numerics

Module Example
   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim c1 As Complex = Complex.FromPolarCoordinates(10, 45 * Math.Pi / 180)
      outputBlock.Text += String.Format("{0}:", c1) & vbCrLf
      outputBlock.Text += String.Format("   Magnitude: {0}", Complex.Abs(c1)) & vbCrLf
      outputBlock.Text += String.Format("   Phase:     {0} radians", c1.Phase) & vbCrLf
      outputBlock.Text += String.Format("   Phase      {0} degrees", c1.Phase * 180 / Math.Pi) & vbCrLf
      outputBlock.Text += String.Format("   Atan(b/a): {0}", Math.Atan(c1.Imaginary / c1.Real)) & vbCrLf
   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
using System;
using System.Numerics;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      Complex c1 = Complex.FromPolarCoordinates(10, 45 * Math.PI / 180);
      outputBlock.Text += String.Format("{0}:", c1) + "\n";
      outputBlock.Text += String.Format("   Magnitude: {0}", Complex.Abs(c1)) + "\n";
      outputBlock.Text += String.Format("   Phase:     {0} radians", c1.Phase) + "\n";
      outputBlock.Text += String.Format("   Phase      {0} degrees", c1.Phase * 180 / Math.PI) + "\n";
      outputBlock.Text += String.Format("   Atan(b/a): {0}", Math.Atan(c1.Imaginary / c1.Real)) + "\n";
   }
}
// The example displays the following output:
//       (7.07106781186548, 7.07106781186547):
//          Magnitude: 10
//          Phase:     0.785398163397448 radians
//          Phase      45 degrees
//          Atan(b/a): 0.785398163397448

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.