Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ program Create the point class as shown in the text with a. data members are the one listed in the text book plus the

c++ program

Create the "point" class as shown in the text with

a. data members are the one listed in the text book plus the new ones below

Methods in the text: shift, rotate90, rotations_needed, distance, middle

b. Default "constructor" with two arguments for x and y coordinates

c. Add the 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) = (xx, yy) (multiply) where m > 1 makes larger, m 0.0 to 1.0 makes smaller

Rotation: ( d) = ( x cos d y sin d, x sin d+ y cos d) whered is 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 test the above implementation of points class and that will convince me your points class is correct. Test all methods in the Points class and show results.

Also, set up a box with 4 points: (2,2) (2,5) (4,5) (4,2)

1. Print out the points for the box.

2. Print out the points for the box after Translating it x=2 and y=1 distance.

3. Continuing with new set of box points, print out the box after scaling x by 2 and y by 0.5

4. Original box pts: print out the box after rotating the box by 30 degrees then print again after rotation another 60 degrees. (Note: degrees may need to be converted to radians?)

5. Original box pts: print out the box after shearing in the x direction 1.5

6. Original box pts: print out the box after shearing in the y direction 1.7

Print out and label each of the outputs above.

For each output of each box, also draw a picture of the new box (nice accurate boxes)

Now we will add to Point class additional methods and code to test each method completely.

a. Write a method to see if two points are equal. ==

b. Write a method to see if two points are not equal. !=

c. Write a method to add two points ( add the xs and add the ys to get a new point) use + operator. Print two points and results.

d. Write a method to subtract the one point from another. Use - operator. Print results

e. Write a method to output a point with the following format ex. ( 5, 6 ) <<

f. Write a method to determine if one point is further distance from the origin (00) then a second point. Use the > operator for this method. Returns T/F value. Print two points and results.

g. Write a method (less than) for < to check if one pt closer to the origin than the second. Print two points and results.

h. Write a method (greater than or equal) for >= to check if one pt further from the origin than the second. Print two points and results.

Write code to test all methods above, label each test, test each Boolean method for both true and for false results. Show the values being tested and the results of each tested method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. What are the components of IT infrastructure?

Answered: 1 week ago