Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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++:
- return the distance from the point to the origin
- return the angle the point makes with the positive x-axis (Hint: the atan2() function is good at finding this - see the docs, here: http://www.gnu.org/software/libc/manual/html_node/Inverse-Trig-Functions.html.)
- 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)
- rotate the point through a certain angle about the origin
- 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). ]
- A printxy() functions, which prints the point's x and y coordinates nicely on screen.
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started