Create a class Polar that represents the points on the plain as polar coordinates (radius and angle). Create an overloaded +operator for addition of two Polar quantities. “Adding” two points on the plain can be accomplished by adding their X coordinates and then adding their Y coordinates. This gives the X and Y coordinates of the “answer.” Thus you’ll need to convert two sets of polar coordinates to rectangular coordinates, add them, then convert the resulting rectangular representation back to polar.
Answers
Answered by
1
Use the following main function to test the class Polar:
int main()
{
Polar p1(10.0, 0.0); //line to the right
Polar p2(10.0, 1.570796325); //line straight up
Polar p3; //uninitialized Polar
p3 = p1 + p2; //add two Polars
cout << "\np1="; p1.display(); //display all Polars
cout << "\np2="; p2.display();
cout << "\np3="; p3.display();
cout << endl;
return 0;
}
Output
p1=(10, 0)
p2=(10, 1.5708)
p3=(14.1421, 0.785398)
Expert Answer
#include <iostream> #include <math.h> using namespace std; class Polar{ private: double radius, angles; public: Polar(){ radius = 0; angles = 0; }
view the full answer
Similar questions