Portability | GHC with TypeFamilies and more |
---|---|

Stability | unstable |

Maintainer | stephen.tetley@gmail.com |

Bounding box with no notion of 'empty'.

Empty pictures cannot be created with Wumpus. This greatly simplifies the implementation of pictures themselves and bounding boxes.

WARNING - this module is no so tightly designed, with some of the functions seeming superfluous in hindsight. It is likely to change in the future.

- data BoundingBox a = BBox {}
- type DBoundingBox = BoundingBox Double
- class Boundary a where
- boundary :: a -> BoundingBox (DUnit a)

- bbox :: Ord a => Point2 a -> Point2 a -> BoundingBox a
- obbox :: Num a => a -> a -> BoundingBox a
- union :: Ord a => BoundingBox a -> BoundingBox a -> BoundingBox a
- trace :: (Num a, Ord a) => [Point2 a] -> BoundingBox a
- corners :: BoundingBox a -> (Point2 a, Point2 a, Point2 a, Point2 a)
- withinBB :: Ord a => Point2 a -> BoundingBox a -> Bool
- boundaryWidth :: Num a => BoundingBox a -> a
- boundaryHeight :: Num a => BoundingBox a -> a
- boundaryBottomLeft :: BoundingBox a -> Point2 a
- boundaryTopRight :: BoundingBox a -> Point2 a
- boundaryTopLeft :: BoundingBox a -> Point2 a
- boundaryBottomRight :: BoundingBox a -> Point2 a
- leftPlane :: BoundingBox a -> a
- rightPlane :: BoundingBox a -> a
- lowerPlane :: BoundingBox a -> a
- upperPlane :: BoundingBox a -> a

# Types

data BoundingBox a Source

Bounding box of a picture, represented by the lower left and upper right corners.

We cannot construct empty pictures - so bounding boxes are
spared the obligation to be *empty*. BoundingBox is an instance
of the Semigroup class where `append`

is the union operation.

Eq a => Eq (BoundingBox a) | |

Show a => Show (BoundingBox a) | |

Ord a => Semigroup (BoundingBox a) | |

Pretty a => Pretty (BoundingBox a) | |

Pointwise (BoundingBox a) | |

(Num u, Ord u) => Scale (BoundingBox u) |

type DBoundingBox = BoundingBox DoubleSource

# Type class

Type class extracting the bounding box of an object - Picture, Path etc.

boundary :: a -> BoundingBox (DUnit a)Source

# Operations

bbox :: Ord a => Point2 a -> Point2 a -> BoundingBox aSource

Contruct a bounding box, vis the BBox constructor with range checking on the corner points.

`bbox`

throws an error if the width or height of the
constructed bounding box is negative.

obbox :: Num a => a -> a -> BoundingBox aSource

Create a BoundingBox with bottom left corner at the origin,
and dimensions `w`

and `h`

.

union :: Ord a => BoundingBox a -> BoundingBox a -> BoundingBox aSource

The union of two bounding boxes. This is also the `append`

of BoundingBox's `Semigroup`

instance.

trace :: (Num a, Ord a) => [Point2 a] -> BoundingBox aSource

Trace a list of points, retuning the BoundingBox that includes them.

`trace`

throws a run-time error when supplied with the empty
list.

corners :: BoundingBox a -> (Point2 a, Point2 a, Point2 a, Point2 a)Source

Generate all the corners of a bounding box, counter-clock
wise from the bottom left, i.e. `(bl, br, tr, tl)`

.

withinBB :: Ord a => Point2 a -> BoundingBox a -> BoolSource

Within test - is the supplied point within the bounding box?

boundaryWidth :: Num a => BoundingBox a -> aSource

Extract the width of a bounding box.

boundaryHeight :: Num a => BoundingBox a -> aSource

Extract the height of a bounding box.

boundaryBottomLeft :: BoundingBox a -> Point2 aSource

Extract the bottom-left corner of the bounding box.

boundaryTopRight :: BoundingBox a -> Point2 aSource

Extract the top-right corner of the bounding box.

boundaryTopLeft :: BoundingBox a -> Point2 aSource

Extract the top-left corner of the bounding box.

boundaryBottomRight :: BoundingBox a -> Point2 aSource

Extract the bottom-right corner of the bounding box.

leftPlane :: BoundingBox a -> aSource

Extract the unit of the left vertical plane.

rightPlane :: BoundingBox a -> aSource

Extract the unit of the right vertical plane.

lowerPlane :: BoundingBox a -> aSource

Extract the unit of the lower horizontal plane.

upperPlane :: BoundingBox a -> aSource

Extract the unit of the upper horizontal plane.