Question: Design and write a Point class, simulating a 2-dimensional point. The Point class needs to implement the following as member functions in c++: return the

Design and write a Point class, simulating a 2-dimensional point. The Point class needs to implement the following as member functions in c++:

  1. return the distance from the point to the origin
  2. return the angle the point makes with the positive x-axis
  3. Translate the point in 2D space: to move a Point with coordinates (x,y) by an amount ( dx, dy ), so that the new coordinates are (x+dx, y+dy)
  4. rotate the point through a certain angle about the origin
  5. rotate the point through a certain angle about another point [ Hint: to rotate your point (x,y) about a point (x0, y0) try translating the point by an amount (-x0,-y0), then rotating it about the origin, then translating it back by an amount (+x0,+y0). ]
  6. A printxy() functions, which prints the point's x and y coordinates nicely on screen.
  7. A printpolar() functions, which prints the point's polar coordinates (r and theta) nicely on screen.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!