tilings-0.1: substitution tilings

Portability portable unstable claudiusmaximus@goto10.org

Data.Tiling.Class

Description

Substitution tiling API.

Synopsis

Documentation

class Tiling t whereSource

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

root :: tSource

The largest tile to start from.

children :: t -> [t]Source

The smaller children of a tile.

parent :: t -> Maybe tSource

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
```

Instances

 Tiling Quad Substitution tiling for square tiles.

tileDefault :: Tiling t => t -> Rectangle -> Int -> [t]Source

Default implementation for `tile`.

data Rectangle Source

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 FieldsnorthEdge :: !Rational southEdge :: !Rational eastEdge :: !Rational westEdge :: !Rational

Instances

 Eq Rectangle Data Rectangle Ord Rectangle Read Rectangle Show Rectangle Typeable Rectangle

Arguments

 :: Rational x0 -> Rational x1 -> Rational y0 -> Rational y1 -> Rectangle rectangle

Create a valid rectangle, sorting the edges to meet the invariant.

Check if a rectangle is inside another rectangle. The comparison is not strict, so that a rectangle is inside itself.

Check if a rectangle is disjoint from another rectangle. The comparison is strict, so that neighbouring rectangles that share an edge will not be outside each other.

Check if a rectangle overlaps with another rectangle. The comparison is not strict, so that neighbouring rectangles that share an edge will overlap each other.