Portability | portable |
---|---|
Stability | unstable |
Maintainer | claudiusmaximus@goto10.org |
Data.Tiling.Class
Description
Substitution tiling API.
- class Tiling t where
- tileDefault :: Tiling t => t -> Rectangle -> Int -> [t]
- data Rectangle = Rectangle {}
- rectangle :: Rational -> Rational -> Rational -> Rational -> Rectangle
- insideR :: Rectangle -> Rectangle -> Bool
- outsideR :: Rectangle -> Rectangle -> Bool
- overlapsR :: Rectangle -> Rectangle -> Bool
Documentation
Substitution tilings. Instances must obey the following laws:
parent root == Nothing all (== Just t) . map parent . children $ t t `inside` exterior t t `encloses` interior t interior t `insideR` exterior t t `inside` r ==> t `overlaps` r t `encloses` r ==> t `overlaps` r t `overlaps` r ==> not (t `outside` r) t `encloses` r && n >= 0 ==> not $ any (`outside` r) (tile t r n)
Minimal complete definition: all except tile
.
Methods
The largest tile to start from.
The smaller children of a tile.
The unique parent of a tile.
exterior :: t -> RectangleSource
A rectangle that completely encloses the tile.
interior :: t -> RectangleSource
A rectangle that is completely enclosed by the tile.
inside :: t -> Rectangle -> BoolSource
Test if a rectangle completely encloses the tile.
encloses :: t -> Rectangle -> BoolSource
Test if a rectangle is completely enclosed by the tile.
outside :: t -> Rectangle -> BoolSource
Test if a rectangle is completely disjoint from the tile.
overlaps :: t -> Rectangle -> BoolSource
Test if a rectangle has any overlap with the tile.
tile :: t -> Rectangle -> Int -> [t]Source
Generate a tiling that completely fills the given rectangle.
Preconditions:
t `encloses` r n >= 0
An axis-aligned rectangle with Rational
coordinates.
Invariant:
westEdge r <= eastEdge r && southEdge r <= northEdge r
For substitution tilings that contain irrational lengths and/or scale
factors, the intention is that the implementations of exterior
and interior
provide reasonably tight bounds, within a percent
or two, say, while the data type maintains full precision internally
(perhaps using algebraic field extensions over Rational
).
Constructors
Rectangle | |
Create a valid rectangle, sorting the edges to meet the invariant.
insideR :: Rectangle -> Rectangle -> BoolSource
Check if a rectangle is inside another rectangle. The comparison is not strict, so that a rectangle is inside itself.