(Solved) : C Program Create Point Class Shown Text Data Members One Listed Text Book Plus New Ones M Q43931848 . . .
c++ program
Create the “point” class as shown in the text with
a. datamembers are the one listed in the text book plus the new onesbelow
Methodsin thetext: shift, rotate90, rotations_needed, distance, middle
b. Default “constructor” with two arguments for xand y coordinates
c. Addthe following methods:
Translation: (x,y)translated to (x’,y’) by adding x’ to x and y’ to y value
(x’,y’)= (x+x’, y+y’) where x’ & y’ are int + or – or 0 values
Scaling: (x’,y’) = (x’x, y’y) (multiply) where m > 1 makeslarger,
m0.0 to 1.0 makes smaller
Rotation:( d) = ( x cos d– y sin d, x sin d+ y cos d)
wheredis the degrees to rotate.
Shearing:(x’, y’) = (x+x’, y) to shear in the x direction
(x,y’+y) to shear in the y direction
Write a main program that will testthe above implementation of ‘points’ class and that will convinceme your points class is correct. Test all methods in thePoints class and show results.
Also, set up a box with 4points: (2,2)(2,5) (4,5) (4,2)
1. Print out the points for thebox.
2. Print out the points for the boxafter Translating it x’=2 and y’=1 distance.
3. Continuing with new set of boxpoints,
printout the box after scaling x by 2 and y by 0.5
4. Original box pts: print out the boxafter rotating the box by 30 degrees then
printagain after rotation another 60 degrees.
(Note:degrees may need to be converted to radians?)
5. Original box pts: print out the boxafter
shearingin the x direction 1.5
6. Original box pts:
printout the box after shearing in the y direction 1.7
Print out and label each of theoutputs above.
For each output of each box, also drawa picture of the new box (nice accurate boxes)
Now we will add to ‘Point’ class additional methods and code totest each method completely.
a. Writea method to see if two points are equal. ‘==’
b. Writea method to see if two points are not equal. ‘!=’
c. Writea method to add two points ( add the x’s and add the y’s to get anew point) use ‘+’ operator. Print two points andresults.
d. Writea method to subtract the one point from another. Use ‘-‘operator. Print results
e. Writea method to output a point with the following format –ex. ( 5, 6 ) ‘<<’
f. Writea method to determine if one point is further distance from theorigin (00) then a second point. Use the ‘>’ operatorfor this method. Returns T/F value. Print twopoints and results.
g. Writea method (less than) for ‘<’ to check if one pt closer to theorigin than the second. Print two points andresults.
h. Writea method (greater than or equal) for ‘>=’ to check if one ptfurther from the origin than the second. Print twopoints and results.
Write code to test all methods above, label each test, test eachBoolean method for both ‘true’ and for ‘false’results. Show the values being tested and the results ofeach tested method.
Expert Answer
Answer to c++ program Create the “point” class as shown in the text with a. data members are the one listed in the text book plus …
OR