ToPolar

AnalysisLibErrType ToPolar (double xReal, double xImg, double *magnitude, double *phase);

Purpose

Converts the rectangular coordinates (xReal, xImg) to polar coordinates (magnitude, phase). ToPolar obtains the polar coordinates using the following formulas:

The phase value is in the range [– : ].

Example

/* Convert the rectangular coordinates to polar coordinates. */
double x, y, mag, phase;
x = 1.5;
y = -2.5;
ToPolar (x, y, &mag, &phase);

Parameters

Input
Name Type Description
xReal double-precision Real part of the complex number that represents the rectangular coordinate.

Default Value: 0.0.
xImg double-precision Imaginary part of the complex number that represents the rectangular coordinate.

Default Value: 0.0.
Output
Name Type Description
magnitude double-precision Magnitude of the resulting polar coordinate.
phase double-precision Phase, in radians, of the resulting polar coordinate.

phase value is in the range [– : ].

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.