complex - STL C++

polar()

Declaration

complex<X> polar(const X& kxrR, const X& kqrTheta = 0);

Description

This is the friend function polar() for complex numbers. It returns the complex number corresponding to the polar coordinates given by kxrR and kqrTheta. The formula for the complex number z = x + iy, for real numbers x and y is

z = x + iy = r*cos(theta) + ir*sin(theta).

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

	// Find the complex number corresponding to (1, pi/6)
	complex<double> qZ;
	qZ = polar(1.0, 3.14159/6.0);
	cout << "Complex Number : "<< qZ << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

polar() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.