Bounding box operations
Your BoundingBox
or MutableBoundingBox
interface should support the following queries and transformations:
- Query the width of the box.
- Query the height of the box.
- Query the centroid of the box.
- Compute the area of the box.
- Determine whether the box contains a given
Point
. For this operation, the box should be considered open; that is, it does not contain points on its boundary.
- Shift the box by a specified x, y coordinate displacement.
- Construct the intersection of this box and another bounding box.
Optional functionality
If you have time, add methods to your interface to perform the following operations as well (and implement them in your class):
- Query the corner points of the box. This should return an array of points, and the corners should be enumerated counter-clockwise starting with the lower-left corner.
- Determine whether the box completely contains another bounding box.
- Scale the box by a specified factor (uniformly in x and y) while preserving the box’s centroid.
It is possible that, by providing these functions, other functionality can be implemented more easily in terms of them.