PenroseKiteDart-1.0.0: Library to explore Penrose's Kite and Dart Tilings.
Copyright(c) Chris Reade 2021
LicenseBSD-style
Maintainerchrisreade@mac.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tgraphs

Description

This is the main module for Tgraph operations which collects and exports the other Tgraph modules. It exports makeTgraph for constructing checked Tgraphs and excludes data constructor Tgraph. The module also defines several functions for producing overlaid diagrams for Tgraphs (including smart drawing) and experimental combinations such as boundaryECovering, boundaryVCovering, empire1, empire2, superForce, boundaryLoopsG. It also defines experimental TrackedTgraphs (used for tracking subsets of faces of a Tgraph).

Synopsis

Documentation

Making valid Tgraphs (with a check for no touching vertices).

makeTgraph :: [TileFace] -> Tgraph Source #

makeTgraph performs a no touching vertex check as well as using tryTgraphProps for other required properties. It produces an error if either check fails. Note that the other Tgraph properties are checked first, to ensure that calculation of vertex locations can be done for a touching vertex check.

tryMakeTgraph :: [TileFace] -> Try Tgraph Source #

tryMakeTgraph performs the same checks for Tgraph properties as tryTgraphProps but in addition it also checks that there are no touching vertices (distinct labels for the same vertex) using Tgraph.Convert.touchingVertices (which calculates vertex locations). It produces Left ... if either check fails and Right g otherwise where g is the Tgraph. Note that the other Tgraph properties are checked first, to ensure that calculation of vertex locations can be done.

tryCorrectTouchingVs :: [TileFace] -> Try Tgraph Source #

tryCorrectTouchingVs fcs finds touching vertices by calculating locations for vertices in the faces fcs, then renumbers to remove touching vertices (renumbers higher to lower numbers), then checks for Tgraph properties of the resulting faces to produce a Tgraph. NB fcs needs to be tile-connected before the renumbering and the renumbering need not be 1-1 (hence Relabelling is not used)

Smart drawing of Tgraphs

smart :: Renderable (Path V2 Double) b => (VPatch -> Diagram2D b) -> Tgraph -> Diagram2D b Source #

smart dr g - uses VPatch drawing function dr after converting g to a VPatch It will add boundary joins regardless of the drawing function. Examples:

smart draw g

smart (labelled draw) g

smart (labelSize normal draw) g

When a specific Backend B is in scope, smart :: (VPatch -> Diagram B) -> Tgraph -> Diagram B

boundaryJoinFaces :: Tgraph -> [TileFace] Source #

select the halftile faces of a Tgraph with a join edge on the boundary. Useful for drawing join edges only on the boundary.

drawJoinsFor :: Renderable (Path V2 Double) b => [TileFace] -> VPatch -> Diagram2D b Source #

given a list of faces and a VPatch with suitable locations, draw just the dashed joins for those faces.

When a specific Backend B is in scope, drawJoinsFor:: [TileFace] -> VPatch -> Diagram B

smartdraw :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

same as draw except adding dashed lines on boundary join edges.

When a specific Backend B is in scope, smartdraw :: Tgraph -> Diagram B

restrictSmart :: Renderable (Path V2 Double) b => Tgraph -> (VPatch -> Diagram2D b) -> VPatch -> Diagram2D b Source #

restrictSmart g dr vp - assumes vp has locations for vertices in g. It uses the VPatch drawing function dr to draw g and adds dashed boundary joins. This can be used instead of smart when an appropriate vp is already available.

When a specific Backend B is in scope, restrictSmart:: Tgraph -> (VPatch -> Diagram B) -> VPatch -> Diagram B

smartRotateBefore :: Renderable (Path V2 Double) b => (VPatch -> Diagram2D b) -> Angle Double -> Tgraph -> Diagram2D b Source #

smartRotateBefore vfun a g - a tricky combination of smart with rotateBefore. Uses vfun to produce a Diagram after converting g to a rotated VPatch but also adds the dashed boundary join edges of g.

Example: smartRotateBefore (labelled draw) angle g

When a specific Backend B is in scope, smartRotateBefore:: (VPatch -> Diagram B) -> Angle Double -> Tgraph -> Diagram B

smartAlignBefore :: Renderable (Path V2 Double) b => (VPatch -> Diagram2D b) -> (Vertex, Vertex) -> Tgraph -> Diagram2D b Source #

smartAlignBefore vfun (a,b) g - a tricky combination of smart with alignBefore. Uses vfun to produce a Diagram after converting g to n aligned VPatch but also adds the dashed boundary join edges of g.

Example: smartAlignBefore (labelled draw) (a,b) g

When a specific Backend B is in scope, smartAlignBefore:: (VPatch -> Diagram B) -> (Vertex,Vertex) -> Tgraph -> Diagram B

Overlaid drawing tools for Tgraphs

drawPCompose :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

applies partCompose to a Tgraph g, then draws the composed graph with the remainder faces (in lime). (Relies on the vertices of the composition and remainder being subsets of the vertices of g.)

When a specific Backend B is in scope, drawPCompose :: Tgraph -> Diagram B

drawForce :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

drawForce g is a diagram showing the argument g in red overlayed on force g It adds dashed join edges on the boundary of g

When a specific Backend B is in scope, drawForce:: Tgraph -> Diagram B

drawSuperForce :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

drawSuperForce g is a diagram showing the argument g in red overlayed on force g in black overlaid on superForce g in blue. It adds dashed join edges on the boundary of g.

When a specific Backend B is in scope, drawSuperForce:: Tgraph -> Diagram B

drawWithMax :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

drawWithMax g - draws g and overlays the maximal composition of force g in red. This relies on g and all compositions of force g having vertices in force g.

When a specific Backend B is in scope, drawWithMax :: Tgraph -> Diagram B

addBoundaryAfter :: Renderable (Path V2 Double) b => (VPatch -> Diagram2D b) -> Tgraph -> Diagram2D b Source #

displaying the boundary of a Tgraph in lime (overlaid on the Tgraph drawn with f).

When a specific Backend B is in scope, addBoundaryAfter :: (VPatch -> Diagram B) -> Tgraph -> Diagram B

drawCommonFaces :: Renderable (Path V2 Double) b => (Tgraph, Dedge) -> (Tgraph, Dedge) -> Diagram2D b Source #

drawCommonFaces (g1,e1) (g2,e2) uses commonFaces (g1,e1) (g2,e2) to find the common faces and emphasizes them on the background g1.

When a specific Backend B is in scope, drawCommonFaces:: (Tgraph,Dedge) -> (Tgraph,Dedge) -> Diagram B

emphasizeFaces :: Renderable (Path V2 Double) b => [TileFace] -> Tgraph -> Diagram2D b Source #

emphasizeFaces fcs g emphasizes the given faces (that are in g) overlaid on the background g.

When a specific Backend B is in scope, emphasizeFaces:: [TileFace] -> Tgraph -> Diagram B

Combining force, compose, decompose

composeK :: Tgraph -> Tgraph Source #

An unsound version of composition which defaults to kites when there are choices (unknowns). This is unsound in that it can create an incorrect Tgraph from a correct Tgraph.

compForce :: Tgraph -> Tgraph Source #

compForce does a force then compose. It omits the check for connected, and no crossing boundaries because the argument is forced first. This relies on a proof that composition does not need to be checked for a forced Tgraph. It may raise an error if the initial force fails with an incorrect Tgraph.

allCompForce :: Tgraph -> [Tgraph] Source #

allCompForce g produces a list of the non-null iterated forced compositions of g. It will raise an error if the initial force fails with an incorrect Tgraph. The list will be [] if g is the emptyTgraph. The list will be [force g] if the first composition of force g is the emptyTgraph but g is not the emptyTgraph. The definition relies on (1) a proof that the composition of a forced Tgraph is forced and (2) a proof that composition does not need to be checked for a forced Tgraph.

maxCompForce :: Tgraph -> Tgraph Source #

maxCompForce g produces the maximally composed (non-null) Tgraph starting from force g, provided g is not the emptyTgraph and just the emptyTgraph otherwise. It will raise an error if the initial force fails with an incorrect Tgraph.

forceDecomp :: Tgraph -> Tgraph Source #

force after a decomposition

allForceDecomps :: Tgraph -> [Tgraph] Source #

allForceDecomps g - produces an infinite list of forced decompositions of g

Emplace Choices

emplaceChoices :: Tgraph -> [Tgraph] Source #

emplaceChoices forces then maximally composes. At this top level it produces a list of forced choices for the unknowns. It then repeatedly forceDecomps back to the starting level to return a list of Tgraphs. This version relies on compForce theorem and related theorems

Boundary Covering and Empires

forcedBoundaryECovering :: Tgraph -> [Tgraph] Source #

forcedBoundaryECovering g - produces a list of all boundary covers of force g, each of which extends force g to cover the entire boundary directed edges in (force g). (So the boundary of force g is entirely internal edges in each cover). The covers include all possible ways faces can be added on the boundary that are correct. The common faces of the covers constitute the empire (level 1) of g. This will raise an error if the initial force fails with a stuck graph.

forcedBoundaryVCovering :: Tgraph -> [Tgraph] Source #

forcedBoundaryVCovering g - produces a list of all boundary covers of force g as with forcedBoundaryECovering g but covering all boundary vertices rather than just boundary edges.

boundaryECovering :: BoundaryState -> [BoundaryState] Source #

boundaryECovering bd - produces a list of all possible covers of the boundary directed edges in bd. [bd should be a boundary state resulting from forcing]. A cover is a forced extension (of bd) such that the original boundary directed edges of bd are all internal edges. Extensions are made by repeatedly adding a face to any edge on the original boundary that is still on the boundary and forcing, repeating this until the orignal boundary is all internal edges. The resulting covers account for all possible ways the boundary can be extended. This can raise an error if bd is a boundary state of an unforced Tgraph. It will raise an error if both choices on a boundary edge fail when forced (using atLeastOne).

boundaryEdgeSet :: BoundaryState -> Set Dedge Source #

Make a set of the directed boundary edges of a BoundaryState

commonBdry :: Set Dedge -> BoundaryState -> Set Dedge Source #

commonBdry des b - returns those directed edges in des that are boundary directed edges of bd

boundaryVCovering :: BoundaryState -> [BoundaryState] Source #

boundaryVCovering bd - similar to boundaryECovering, but produces a list of all possible covers of the boundary vertices in bd (rather than just boundary edges). [bd should be a boundary state resulting from forcing]. This can raise an error if bd is a boundary state of an unforced Tgraph.

boundaryVertexSet :: BoundaryState -> VertexSet Source #

returns the set of boundary vertices of a BoundaryState

internalVertexSet :: BoundaryState -> VertexSet Source #

returns the set of internal vertices of a BoundaryState

tryDartAndKiteForced :: Forcible a => Dedge -> a -> [Try a] Source #

tryDartAndKiteForced de b - returns the list of (2) results after adding a dart (respectively kite) to edge de a forcible b and then tries forcing. Each of the result is a Try.

tryDartAndKite :: Forcible a => Dedge -> a -> [Try a] Source #

tryDartAndKite de b - returns the list of (2) results after adding a dart (respectively kite) to edge de of a Forcible b. Each of the result is a Try.

drawFBCovering :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

test function to draw a column of the list of graphs resulting from forcedBoundaryVCovering g.

When a specific Backend B is in scope, drawFBCovering:: Tgraph -> Diagram B

empire1 :: Tgraph -> TrackedTgraph Source #

empire1 g - produces a TrackedTgraph representing the level 1 empire of g. The tgraph of the result is the first boundary vertex cover of force g, and the tracked list of the result has the common faces of all the boundary vertex covers (of force g) at the head, followed by the original faces of g.

empire2 :: Tgraph -> TrackedTgraph Source #

empire2 g - produces a TrackedTgraph representing the level 2 empire of g. NB since very large graphs can be generated with boundary vertex covers, we use boundary edge covers only. That is, after finding all boundary edge covers of force g, boundary edge covers are then found for each boundary edge cover to form a list of doubly-extended boundary edge covers. The tgraph of the result is the first (doubly-extended) boundary edge cover (of force g), and the tracked list of the result has the common faces of all the (doubly-extended) boundary edge covers at the head, followed by the original faces of g.

empire2Plus :: Tgraph -> TrackedTgraph Source #

empire2Plus g - produces a TrackedTgraph representing an extended level 2 empire of g similar to empire2, but using boundaryVCovering insrtead of boundaryECovering.

drawEmpire :: Renderable (Path V2 Double) b => TrackedTgraph -> Diagram2D b Source #

drawEmpire e - produces a diagram for an empire e represented as a TrackedTgraph as calcultaed by e.g. empire1 or empire2 or empire2Plus. The diagram draws the underlying Tgraph, with the first tracked faces - the starting Tgraph shown red, and emphasising the second tracked faces - the common faces.

When a specific Backend B is in scope, drawEmpire:: TrackedTgraph -> Diagram B

showEmpire1 :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

showEmpire1 g - produces a diagram emphasising the common faces of all boundary covers of force g. This is drawn over one of the possible boundary covers and the faces of g are shown in red.

When a specific Backend B is in scope, showEmpire1:: Tgraph -> Diagram B

showEmpire2 :: Renderable (Path V2 Double) b => Tgraph -> Diagram2D b Source #

showEmpire2 g - produces a diagram emphasising the common faces of a doubly-extended boundary cover of force g. This is drawn over one of the possible doubly-extended boundary covers and the faces of g are shown in red.

When a specific Backend B is in scope, showEmpire2:: Tgraph -> Diagram B

Super Force with boundary edge covers

superForce :: Forcible a => a -> a Source #

superForce g - after forcing g this looks for single choice boundary edges. That is a boundary edge for which only a dart or only a kite addition occurs in all boundary edge covers. If there is at least one such edge, it makes the choice for the first such edge and recurses, otherwise it returns the forced result. This will raise an error if force encounters a stuck (incorrect) tiling or if both forced extensions fail for some boundary edge. Otherwise, the result has exactly two correct possible extensions for each boundary edge.

trySuperForce :: Forcible a => a -> Try a Source #

trySuperForce g - this looks for single choice edges after trying to force g. If there is at least one, it makes that choice and recurses. It returns a Left s if force fails or if both choices fail for some edge (where s is a failure report). Otherwise Right g' is returned where g' is the super forced g.

singleChoiceEdges :: BoundaryState -> [(Dedge, HalfTileLabel)] Source #

singleChoiceEdges bd - if bd is a boundary state of a forced Tgraph this finds those boundary edges of bd which have a single choice (i.e. the other choice is incorrect), by inspecting boundary edge covers of bd. The result is a list of pairs of (edge,label) where edge is a boundary edge with a single choice and label indicates the choice as the common face label.

Boundary loops

boundaryLoopsG :: Tgraph -> [[Vertex]] Source #

Returns a list of (looping) vertex trails for the boundary of a Tgraph. There will usually be a single trail, but more than one indicates the presence of boundaries round holes. Each trail starts with the lowest numbered vertex in that trail, and ends with the same vertex. The trails will have disjoint sets of vertices because of the no-crossing-boundaries condition of Tgraphs.

boundaryLoops :: BoundaryState -> [[Vertex]] Source #

Returns a list of (looping) vertex trails for a BoundaryState. There will usually be a single trail, but more than one indicates the presence of boundaries round holes. Each trail starts with the lowest numbered vertex in that trail, and ends with the same vertex. The trails will have disjoint sets of vertices because of the no-crossing-boundaries condition of Tgraphs (and hence BoundaryStates).

findLoops :: [Dedge] -> [[Vertex]] Source #

When applied to a boundary edge list this returns a list of (looping) vertex trails. I.e. if we follow the boundary edges of a Tgraph recording vertices visited as a list returning to the starting vertex we get a looping trail. There will usually be a single trail, but more than one indicates the presence of boundaries round holes. Each trail starts with the lowest numbered vertex in that trail, and ends with the same vertex.

pathFromBoundaryLoops :: VertexLocMap -> [[Vertex]] -> Path V2 Double Source #

Given a suitable vertex to location map and boundary loops (represented as a list of lists of vertices), this will return a (Diagrams) Path for the boundary. It will raise an error if any vertex listed is not a map key. (The resulting path can be filled when converted to a diagram.)

TrackedTgraphs

data TrackedTgraph Source #

TrackedTgraph - introduced to allow tracking of subsets of faces in both force and decompose operations. Mainly used for drawing purposes but also for empires. A TrackedTgraph has a main Tgraph (tgraph) and a list of subsets (sublists) of faces (tracked). The list allows for tracking different subsets of faces at the same time.

Constructors

TrackedTgraph 

Fields

newTrackedTgraph :: Tgraph -> TrackedTgraph Source #

newTrackedTgraph g creates a TrackedTgraph from a Tgraph g with an empty tracked list

makeTrackedTgraph :: Tgraph -> [[TileFace]] -> TrackedTgraph Source #

makeTrackedTgraph g trackedlist creates a TrackedTgraph from a Tgraph g from trackedlist where each list in trackedlist is a subset of the faces of g. Any faces not in g are ignored.

trackFaces :: TrackedTgraph -> TrackedTgraph Source #

trackFaces ttg - pushes the maingraph tilefaces onto the stack of tracked subsets of ttg

unionTwoTracked :: TrackedTgraph -> TrackedTgraph Source #

unionTwoTracked ttg - combines the top two lists of tracked tilefaces replacing them with the list union.

Forcing and Decomposing TrackedTgraphs

addHalfDartTracked :: Dedge -> TrackedTgraph -> TrackedTgraph Source #

addHalfDartTracked ttg e - add a half dart to the tgraph of ttg on the given edge e, and push the new singleton face list onto the tracked list.

addHalfKiteTracked :: Dedge -> TrackedTgraph -> TrackedTgraph Source #

addHalfKiteTracked ttg e - add a half kite to the tgraph of ttg on the given edge e, and push the new singleton face list onto the tracked list.

decomposeTracked :: TrackedTgraph -> TrackedTgraph Source #

decompose a TrackedTgraph - applies decomposition to all tracked subsets as well as the full Tgraph. Tracked subsets get the same numbering of new vertices as the main Tgraph.

Drawing TrackedTgraphs

drawTrackedTgraph :: [VPatch -> Diagram2D b] -> TrackedTgraph -> Diagram2D b Source #

To draw a TrackedTgraph, we use a list of functions each turning a VPatch into a diagram. The first function is applied to a VPatch for untracked faces. Subsequent functions are applied to VPatches for the respective tracked subsets. Each diagram is beneath later ones in the list, with the diagram for the untracked VPatch at the bottom. The VPatches are all restrictions of a single VPatch for the Tgraph, so consistent. (Any extra draw functions are applied to the VPatch for the main tgraph and the results placed atop.)

When a specific Backend B is in scope, drawTrackedTgraph:: [VPatch -> Diagram B] -> TrackedTgraph -> Diagram B

drawTrackedTgraphRotated :: [VPatch -> Diagram2D b] -> Angle Double -> TrackedTgraph -> Diagram2D b Source #

To draw a TrackedTgraph rotated. Same as drawTrackedTgraph but with additional angle argument for the rotation. This is useful when labels are being drawn. The angle argument is used to rotate the common vertex location map before drawing (to ensure labels are not rotated).

When a specific Backend B is in scope, drawTrackedTgraphRotated:: [VPatch -> Diagram B] -> Angle Double -> TrackedTgraph -> Diagram B

drawTrackedTgraphAligned :: [VPatch -> Diagram2D b] -> (Vertex, Vertex) -> TrackedTgraph -> Diagram2D b Source #

To draw a TrackedTgraph aligned. Same as drawTrackedTgraph but with additional vertex pair argument for the (x-axis) aligment. This is useful for when labels are being drawn. The vertex pair argument is used to align the common vertex location map before drawing (to ensure labels are not rotated). This will raise an error if either of the pair of vertices is not a vertex of (the tgraph of) the TrackedTgraph

When a specific Backend B is in scope, drawTrackedTgraphAligned:: [VPatch -> Diagram B] -> (Vertex,Vertex) -> TrackedTgraph -> Diagram B