How to calculate polar coordinates in c++

[ad_1]

how to calculate polar coordinates in c++
#include 
#include 		// For 'atan()' which is the inverse fuction of 'tan' in C++,
						// and for 'M_PI' which is the real number 'pi'.
void radius();		// Calculate the radius.
void theeta();		// Calculate the angle associated to the couple (x,y) in degree.

void main() {

	int x, y;
	cout << "Enter the x coordinate: " << flush;
	cin >> x;

	cout << "enter the y coordinate: " << flush;
	cin >> y;

    radius();
    theeta();
}

void radius() {
	float r;
	r = sqrt(x*x + y*y);
	cout << "Radius = " << r << endl;
}

void theeta() {
	float theta, angle;
	theta = atan(y/x);		// 'theta' is the angle associated to the couple (x, y) in radian.
	angle = theta*(180/M_PI);		// The conversion of 'theta' from radian to degree.
	cout << "Theta = " << angle << endl;
}

[ad_2]

Please follow and like us:
Content Protection by DMCA.com