Export (0) Print
Expand All

Complex.FromPolarCoordinates Method

Creates a complex number from a point's polar coordinates.

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

public static Complex FromPolarCoordinates(
	double magnitude,
	double phase
)

Parameters

magnitude
Type: System.Double

The magnitude, which is the distance from the origin (the intersection of the x-axis and the y-axis) to the number.

phase
Type: System.Double

The phase, which is the angle from the line to the horizontal axis, measured in radians.

Return Value

Type: System.Numerics.Complex
A complex number.

The FromPolarCoordinates method instantiates a complex number based on its polar coordinates.

Because there are multiple representations of a point on a complex plane, the return value of the FromPolarCoordinates method is normalized. The magnitude is normalized to a positive number, and the phase is normalized to a value in the range of -PI to PI. As a result, the values of the Phase and Magnitude properties of the resulting complex number may not equal the original values of the magnitude and phase parameters.

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

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.

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

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft