(Geometry: find the bounding rectangle) A bounding rectangle is the minimum rectangle that encloses a set of points in a two-dimensional plane, as shown in Figure 12.16. Write a method that returns a bounding rectangle for a set of points in a two-dimensional plane, as follows:
def getRectangle(points):
You defined the Rectangle2D class in Exercise 8.19. Write a test program that prompts the user to enter the points as x1 y1 x2 y2 x3 y3 ... in one line, and displays the bounding rectangle’s center, width, and height. Here is a sample run:
Enter the points: 1.0 2.5 3 4 5 6 7 8 9 10
The bounding rectangle is centered at (5.0, 6.25) with width 8.0 and height 7.5
FIGURE 12.16 Points are enclosed inside a rectangle.
Sorry the answer is not available at the moment…
If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.
Spread the 'tradition of sharing'.