moonlight-triangulation: Delaunay meshes and exact planar-region algebra.

[ deprecated, geometry, library, math, mit, program ] [ Propose Tags ] [ Report a vulnerability ]
Deprecated in favor of moonlight-planar

Delaunay and constrained Delaunay triangulation as a lawful finite-set algebra, together with exact rational planar regions, labelled common refinement, intrinsic valuations, and polygonal Minkowski morphology. A mesh is a value of its site set, so union, intersection and difference return triangulations and refinement composes after them rather than replacing them. One structure-of-arrays half-edge mesh carries the constrained and unconstrained layers. Private finite-DCEL and construction kernels own trusted representations and admitted fast paths. Public dcel and build sublibraries expose their lawful immutable observations, typed queries, construction, incremental edits, constraint recovery, and refinement without duplicating those owners. Further opt-in sublibraries expose the exact scalar core, Voronoi and natural-neighbour dual, bounded concurrent join interpreter, and versioned serialization surface beside the broad main facade. On GHC 9.14, a public cell-complex component interprets admitted exact cell selections for Homology and Category and lowers exact Delaunay alpha filtrations into persistent homology; an opt-in zigzag component tracks exact topology across independently sampled, non-nested labelled depths. Failure is values: every refusal names its witness.


[Skip to Readme]

library moonlight-triangulation

library moonlight-triangulation:dual

library moonlight-triangulation:serialize

Modules

[Index]

library moonlight-triangulation:parallel

Modules

[Index]

library moonlight-triangulation:build

library moonlight-triangulation:zigzag

Modules

[Index]

library moonlight-triangulation:cell-complex

library moonlight-triangulation:dcel

library moonlight-triangulation:core

Flags

Manual Flags

NameDescriptionDefault
warnings-as-errors

Treat compiler warnings as errors in package validation.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 1.0.0.0, 1.0.1.0, 1.2.0.0, 1.2.0.1, 1.3.0.0, 1.3.0.2, 1.3.0.3, 1.4.0.1, 1.4.0.2, 1.4.0.3, 1.4.0.4, 1.4.0.5, 1.5.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.2 && <2.4), async (>=2.2 && <2.3), base (>=4.22 && <5), binary (>=0.8 && <0.9), bytestring (>=0.12 && <0.13), containers (>=0.8 && <0.9), deepseq (>=1.5 && <1.6), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), moonlight-algebra (>=0.1 && <0.2), moonlight-category (>=1.1.0.0 && <1.2), moonlight-core (>=0.1 && <0.2), moonlight-homology (>=0.1.0.3 && <0.2), moonlight-triangulation (>=1.5 && <1.6), primitive (>=0.9 && <0.10), process (>=1.6 && <1.7), tasty-bench (>=0.3 && <0.6), text (>=2.0 && <2.2), transformers (>=0.6 && <0.7), unix (>=2.8 && <2.9), vector (>=0.13 && <0.14), vector-algorithms (>=0.9 && <0.10) [details]
Tested with ghc ==9.8.4, ghc ==9.10.3, ghc ==9.12.4, ghc ==9.14.1
License MIT
Copyright (c) 2026 Blue Rose
Author Blue Rose
Maintainer rosaliafialkova@gmail.com
Uploaded by bluerose at 2026-08-31T04:55:19Z
Category Geometry, Math
Home page https://github.com/PaleRoses/moonlight
Bug tracker https://github.com/PaleRoses/moonlight/issues
Source repo head: git clone https://github.com/PaleRoses/moonlight.git(moonlight-triangulation)
this: git clone https://github.com/PaleRoses/moonlight.git(tag moonlight-triangulation-1.5.0.0)(moonlight-triangulation)
Distributions
Executables moonlight-triangulation-alpha-spade-referent, moonlight-triangulation-spade-referent, moonlight-triangulation-persistence-rose, moonlight-triangulation-category-observatory-export, moonlight-triangulation-delaunay-pictures, moonlight-triangulation-delaunay-compare, moonlight-triangulation-ffi-contract
Downloads 47 total (47 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for moonlight-triangulation-1.5.0.0

[back to package description]

moonlight-triangulation

Part of Moonlight, the sheaf-theoretic computation layer beneath Melusine and Pale Meridian.

moonlight-triangulation carries Delaunay and constrained Delaunay triangulations as a lawful finite-set algebra under canonical observation: a mesh represents its site set, a join returns a valid Delaunay representative, and the result is a triangulation again — so the operations close, compose, and fold. Operations return typed obstructions where the finite arena cannot represent a result.

Delaunay triangulation, constrained Delaunay (CDT), exact rational planar regions and labelled overlay, intrinsic valuations, polygonal Minkowski morphology, exact regular/power geometry, the Voronoi dual, natural-neighbour interpolation, Ruppert refinement, walk point location, convex hull, exact Shewchuk predicates, exact zigzag persistence across non-nested activation depths, and versioned binary serialization.

Persistence rose

Animated Moonlight persistence rose: exact Delaunay alpha filtration, persistent homology, Voronoi dual, and natural-neighbour field

Open the animation directly. · Open the static vector poster. · Read the exhibit guide.

Operations

Operation Use when Inputs Result
delaunayGeometry Coordinates own the input Vector Point Geometry-only mesh / BuildError
delaunayFromCoordinates Payloads have a separate plane Defaults, points, payloads, duplicate policy BuildResult / BuildError
insert / insertAt / insertMany An immutable mesh gains sites or payload replacements Mesh plus payloads or explicit points InsertionResult / BuildResult / BuildError
withSession Many inserts and removals should publish once Mesh, peak added-site count, composed Session Result, mesh, and BuildStats / BuildError
withScopedTriangulation Local traversal must make cross-mesh identifiers unrepresentable Mesh and rank-2 continuation Zero-cost scoped mesh and identifiers
removeVertex / locateAndRemove A resident handle or exact position must be removed Mesh plus VertexId / Point RemovalResult / optional result / BuildError
siteRelation Supports need exact classification Two meshes SiteRelation
union / unions Unconstrained supports must join Two meshes / mesh list Union mesh / BuildError
intersection / intersectionWith Shared support is required Two meshes; optional payload combiner Common-site mesh / BuildError
difference / symmetricDifference Left-only / exclusive support is required Source and mask / two meshes Result mesh / BuildError
constrainedDelaunay Segments author topology Defaults, positioned vertices, index pairs BuildResult / CdtError
addConstraintEdge(s) / removeConstraintEdge Constraints change on a resident mesh Mesh plus vertex pair(s) / edge Constraint receipt or mesh / CdtError
unionConstrained / unionConstrainedWith Arbitrary constrained meshes must join Two meshes; optional payload combiner Constrained mesh / ConstrainedUnionError
extendConstrainedWith One constrained mesh owns identity Combiner, base, extension ConstrainedExtensionResult / ConstrainedUnionError
joinSeparatedConstrained Inputs are strictly x-separated Face predicate, refinement parameters, two meshes ConstrainedSeamResult / ConstrainedUnionError
refine Quality applies globally Vertex constructor, parameters, mesh RefinementResult / BuildError
refineWithinDomain Quality applies to admitted faces Vertex constructor, parameters, face set, mesh RefinementDomainResult / BuildError
faceComponents Bounded faces must descend by label Mesh, FaceId -> label [(label, FaceComponent)]
componentBoundary One component must publish as loops Mesh, FaceComponent RegionBoundary / BoundaryObstruction
locatePoint / locatePointWithHint An admitted point needs an exact cell classification Mesh, QueryPoint, optional hint Location, optionally with LocationStats
lineIntersections A segment needs its ordered mesh crossings Mesh and admitted endpoints [Intersection]
verticesInCircle / verticesInRectangle A metric window selects resident sites Mesh and circle / rectangle Handles / typed metric error
exactClipRetainedPolygon A convex exact polygon must meet closed half-planes while retaining source lines Retained polygon and half-plane list Empty, point, segment, or polygon section plus receipt / ExactClipError
overlayLayers Layers need one exact arrangement Two PlanarLayers OverlayResult / OverlayError
overlayAll A nonempty layer family needs one tuple-labelled common refinement NonEmpty (PlanarLayer label) PlanarLayer (NonEmpty label) / OverlayError
overlayClosedUnion / overlayClosedIntersection / overlayRegularizedDifference Boolean output may retain lower cells Two label predicates, OverlayResult ExactCellSet / OverlaySelectionError
overlaySelectedRegion Selected faces must publish as polygons Label-pair predicate, OverlayResult PlanarRegion / RegionPublicationError
overlayMass / overlayConfusion Only exact selected area or the finite label-pair matrix is needed Predicate / OverlayResult ExactArea / exact mass map
layerCovers A labelled layer must cover an admitted polygonal window PlanarLayer, PolygonComponent () or LayerCoverageError carrying the exact gap
cellValuations / regionValuations Intrinsic measures are required ExactCellSet / PlanarRegion PlanarValuations / ValuationError
minkowskiSum / polygonOffset Regions must add / expand Two regions / element and region Region plus receipt / MinkowskiError
erodeBy / openWith / closeWith Regularized morphology is required Structuring element, region Region plus receipt / MinkowskiError
regularTriangulation Weighted sites need unbounded topology and exact dual geometry Nonempty PowerSite family Opaque regular topology, dispositions, segments/rays/lines, and receipt / PowerDiagramError
insertRegularSite / removeRegularSite A persistent regular value gains or loses one stable-labelled site PowerSite / label and RegularTriangulation New regular value, changed-site support, and exact disposition transitions / RegularEditError
reweightRegularSites Stable sites receive one optimizer or simulation weight update Map label PowerWeight, RegularTriangulation New regular value, changed-site support, and exact disposition transitions / RegularEditError
boundedPowerDiagram Labelled weighted sites need exact cells inside one finite convex domain ConvexPolygon, nonempty PowerSite family Total labelled dispositions plus rational-width receipt / PowerDiagramError
boundedPowerDiagramFromRegular An admitted regular value already owns the weighted-site topology ConvexPolygon, RegularTriangulation Exact bounded cells without rebuilding the lifted hull / PowerDiagramError
upperEnvelope Exact affine forms need their labelled argmax decomposition in a polygonal window PolygonComponent, Map label AffineForm PlanarLayer (Maybe label) / UpperEnvelopeError
alphaShapeContainsFace One face at one radius is enough RadiusSquared, mesh, FaceId Bool
alphaFiltration Every critical radius matters Delaunay mesh AlphaFiltration / AlphaFiltrationError
regularAlphaFiltration Weighted regular topology needs signed exact births RegularTriangulation RegularAlphaFiltration / RegularAlphaError
fromExactCellSet Exact cells need a generic complex view ExactCellSet DCELComplex
filteredAlphaComplex Alpha births must enter persistence AlphaFiltration Filtered chain complex / DCELError
activationAlphaZigzag Non-nested labelled depths need checked correspondence NonEmpty (ActivationSlice depth label) Admitted complexes, adjacent-union witnesses, and checked zigzag / ActivationZigzagError
activationZigzagIntervals / activationAlphaPersistence An admitted zigzag / labelled depth family needs its exact barcode ActivationZigzag / NonEmpty (ActivationSlice depth label) Stage-labelled exact zigzag intervals / ActivationZigzagError
canonicalize Numbering must ignore construction history Mesh with unit edge/face payloads Canonical mesh / BuildError

Interpret cell sets as incidence categories. · Compute persistent alpha topology. · Track topology across non-nested activation depths. · Compute weighted alpha persistence.

Exact power cells and affine envelopes

PowerWeight admits a finite signed additive offset through its own PowerWeightError; PowerSite admits its binary64 position once. regularTriangulation constructs the exact lifted upper hull once. It retains every admitted labelled site as its semantic value; visibility, regular faces, and weighted-dual segments, rays, full lines, or collapsed degenerate edges are sealed derived projections. Pure insertion, removal, and batch reweighting return exhaustive typed disposition transitions. Exact conflict-cavity and face-star descent update only affected topology; an internal typed refusal falls back once to the canonical batch constructor. boundedPowerDiagram then clips only regular-neighbour inequalities against the ConvexPolygon; globally hidden sites need no clip, while lower-dimensional sites use the complete HPI oracle. It retains one full-dimensional, lower-dimensional, empty, coincident-equivalent, or coincident-dominated result per label. powerDiagramPlanarLayer is only the derived full-dimensional view. When a regular value is already available, boundedPowerDiagramFromRegular reuses its normalized lifted hull.

upperEnvelope maps exact c0 + cx*x + cy*y forms into the same owner. Its planar result contains only two-dimensional winning regions, with Nothing outside the window; nonconvex windows and holes use the canonical overlay.

Edit and reweight the complete regular-site section. · Lower weighted topology into exact persistence.

Foreign bindings

The C ABI and its Python, TypeScript, and Rust consumers are documented in the foreign-bindings guide. It owns construction, ABI versioning, lifecycle, obstruction semantics, and consumer examples.

Algebraic contract

union is idempotent; commutativity and associativity hold after canonicalize. Structural Eq is resident equality; use siteRelation for support comparison.

Set-operation types

union :: JoinSemilattice annotation
      => Triangulation 'Unconstrained annotation () () ()
      -> Triangulation 'Unconstrained annotation () () ()
      -> Either BuildError (Triangulation 'Unconstrained annotation () () ())

unions :: JoinSemilattice annotation
       => [Triangulation 'Unconstrained annotation () () ()]
       -> Either BuildError (Triangulation 'Unconstrained annotation () () ())

siteRelation
      :: Triangulation leftMode leftAnnotation leftDirected leftUndirected leftFace
      -> Triangulation rightMode rightAnnotation rightDirected rightUndirected rightFace
      -> SiteRelation

intersection
      :: Triangulation 'Unconstrained () () () ()
      -> Triangulation 'Unconstrained () () () ()
      -> Either BuildError (Triangulation 'Unconstrained () () () ())

intersectionWith
      :: (leftAnnotation -> rightAnnotation -> annotation)
      -> Triangulation 'Unconstrained leftAnnotation () () ()
      -> Triangulation 'Unconstrained rightAnnotation () () ()
      -> Either BuildError (Triangulation 'Unconstrained annotation () () ())

difference
      :: Triangulation 'Unconstrained leftAnnotation () () ()
      -> Triangulation 'Unconstrained rightAnnotation () () ()
      -> Either BuildError (Triangulation 'Unconstrained leftAnnotation () () ())

symmetricDifference
      :: Triangulation 'Unconstrained annotation () () ()
      -> Triangulation 'Unconstrained annotation () () ()
      -> Either BuildError (Triangulation 'Unconstrained annotation () () ())

Zigzag composition

The activation surface composes admitted local geometry with exact global reduction through the existing typed obstruction:

activationAlphaPersistence slices =
  activationAlphaZigzag slices >>= activationZigzagIntervals

Each slice yields a canonical labelled subcomplex K_i. Adjacent sections glue through K_i -> K_i ∪ K_{i+1} <- K_{i+1}: the union is the join of labelled subcomplexes, and both legs are checked chain maps satisfying boundary . inclusion = inclusion . boundary. The glued zigzag is therefore a finite path in chain complexes; rational homology and interval decomposition produce its authoritative global barcode. Betti profiles are derived views, while any failed local, overlap, or gluing obligation remains an ActivationZigzagError.

Publication schedules and scale behavior.

Use

Use the broad default library with explicit Vector inputs. It exposes the facade and the safe leaf modules; construction and set algebra retain their typed obstruction in Either:

build-depends:
  base >= 4.19 && < 5,
  moonlight-triangulation >= 1.4 && < 1.5,
  vector >= 0.13 && < 0.14

Use withScopedTriangulation for allocation-free local incidence traversal. Use Handles.Dynamic when a handle must escape. Fixed VertexId/edge/face values are unchecked resident indices and belong only with the mesh that issued them.

SetAlgebra.hs is the smallest compile-checked workflow. The example index adds constrained interiors, alpha-boundary descent, exact overlay and valuations, and polygonal morphology.

For a smaller compile/dependency cone, depend on only the component modules you import:

build-depends:
  moonlight-triangulation:dcel >= 1.4 && < 1.5,
  moonlight-triangulation:build >= 1.4 && < 1.5

Architecture

The resident DCEL is immutable structure-of-arrays over paged copy-on-write storage; local mutation is sealed in ST. Half-edge twins are index complements. Exact predicates use bounded machine-word evaluation and fall through to aligned Integer arithmetic when required.

Consumer libraries

The Cabal manifest owns component visibility and dependencies; this is its consumer-facing projection. Use a public sublibrary directly when its smaller dependency cone matters; trusted implementation units remain private.

Dependency Imports Purpose
moonlight-triangulation Moonlight.Triangulation plus the public dcel, build, and dual modules Broad construction, observation, set algebra, CDT, refinement, alpha, Voronoi, interpolation, and exact planar surface.
moonlight-triangulation:core .Scalar, .LineSideInfo Low-level exact scalars and paged storage primitives.
moonlight-triangulation:dcel .Types, .Dcel, .Handles.*, .PointLocation, .FloodFillIterator, .IntersectionIterator, .Alpha, .Exact, .Region, .Valuation Immutable mesh vocabulary, exact geometry, scoped/owning observations, and the explicit fixed-index kernel; no construction kernel.
moonlight-triangulation:build .BulkLoad, .Session, .Removal, .Cdt, .Refinement, .SetAlgebra Construction and persistent editing over the DCEL; no dual, serialization, concurrency, or Homology dependency.
moonlight-triangulation:dual .Voronoi, .Voronoi.Handles, .Interpolation Voronoi observations and natural-neighbour interpolation.
moonlight-triangulation:parallel .Parallel Bounded concurrent union; adds async.
moonlight-triangulation:serialize .Serialization Versioned binary envelopes; adds binary, bytestring, and transformers.
moonlight-triangulation:cell-complex (GHC 9.14+) .CellComplex Cell, chain, and filtered-alpha interpretations; adds Homology.
moonlight-triangulation:zigzag (GHC 9.14+) .Zigzag Labelled activation alpha complexes, adjacent-union witnesses, and stage-labelled zigzag intervals; adds Homology and construction.

Build and validate package components locally.