Classes for generically handling bounding boxes, and things that possess bounding boxes.
- class HasSpace b => BoundingBox b where
- bound_corners :: Point b -> Point b -> b
- bound_points :: [Point b] -> b
- min_point :: b -> Point b
- max_point :: b -> Point b
- within_bounds :: Point b -> b -> Bool
- union :: b -> b -> b
- isect :: b -> b -> Maybe b
- class HasSpace x => HasBBox x where
- get_bbox :: (BoundingBox b, Point b ~ Point x) => x -> b
Documentation
class HasSpace b => BoundingBox b whereSource
Class for dealing with bounding boxes.
bound_corners :: Point b -> Point b -> bSource
Given two corner points, construct a bounding box containing them both. (You can use any two points, given in any order, provided that they are from opposite corners.)
bound_points :: [Point b] -> bSource
Given a list of points, construct a bounding box containing them all. (Throws an exception if the list is empty.)
min_point :: b -> Point bSource
Return a point containing the minimum values for all coordinates.
max_point :: b -> Point bSource
Return a point containing the maximum values for all coordinates.
within_bounds :: Point b -> b -> BoolSource
Test whether a given point lies within a given bounding box.
Take the union of two bounding boxes. The result is a new bounding box that contains every point that the original pair of boxes contained, and probably some extra space as well.
isect :: b -> b -> Maybe bSource
Take the intersection of two bounding boxes. If the boxes do not overlap, return Nothing
. Otherwise return a bounding box containing only the points common to both original bounding boxes.