Working with Polar Coordinates - C++ Data Type

C++ examples for Data Type:complex

Description

Working with Polar Coordinates

Demo Code

#include <complex>
#include <iostream>

using namespace std;

int main()  {//from www . j  a v  a2s  . c o  m
  double rho = 3.0; // magnitude
  double theta = 3.141592 / 2; // angle
  complex<double> coord = polar(rho, theta);
  cout << "rho = " << abs(coord) << ", theta = " << arg(coord) << endl;
  coord += polar(4.0, 0.0);
  cout << "rho = " << abs(coord) << ", theta = " << arg(coord) << endl;
}

Result


Related Tutorials