polar - C complex.h

C examples for complex.h:polar

type

function template

From


<complex>
<complex.h>

Prototype

template<class T> 
complex<T> polar (const T& rho, const T& theta = 0);

Description

Complex from polar components

Returns a complex object in cartesian format for the complex number defined by its polar components rho and theta, where rho is the magnitude (modulus) and theta is the phase angle.

real = rho * cos(theta);
imag = rho * sin(theta);

Parameters

Parameter Description
rho Magnitude (modulus) of the complex number.
theta Phase angle (angular component) of the complex number.

Return value

The complex cartesian equivalent to the polar format formed by rho and theta.

Demo Code


#include <iostream> // std::cout
#include <complex> // std::complex, std::polar

int main ()/*from www.j a  v  a2  s.  com*/
{
  std::cout << "The complex whose magnitude is " << 2.0;
  std::cout << " and phase angle is " << 0.5;
  std::cout << " is " << std::polar (2.0, 0.5) << '\n';

  return 0;
}

Related Tutorials