The hgeometry package

[Tags:bsd3, library]

HGeometry provides some basic geometry types, and geometric algorithms and data structures for them. The main two focusses are: (1) Strong type safety, and (2) implementations of geometric algorithms and data structures with good asymptotic running time guarantees.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.1.0, 0.1.1.1, 0.4.0.0, 0.5.0.0
Dependencies base (>=4.7 && <5), bifunctors (>=5), bytestring (>=0.10), containers (>=0.5.5), data-clist (>=0.0.7.2), directory, fixed-vector (>=0.6.4.0), Frames (>=0.1.0.0), hexpat (>=0.20.9), lens (>=4.2), linear (>=1.10), mtl, optparse-applicative, parsec (>=3), random, semigroupoids (>=5), semigroups (>=0.15), singletons (>=1.0 && <2.0), template-haskell, text (>=1.1.1.0), time, vector (>=0.10), vinyl (==0.5.*) [details]
License BSD3
Author Frank Staals
Maintainer frank@fstaals.net
Stability Unknown
Category Geometry
Home page https://fstaals.net/software/hgeometry
Source repository head: git clone https://github.com/noinia/hgeometry
Uploaded Sat Jun 11 10:07:51 UTC 2016 by FrankStaals
Distributions NixOS:0.5.0.0
Downloads 770 total (21 in the last 30 days)
Votes
0 []
Status Docs pending
Build status unknown [no reports yet]

Modules

  • Algorithms
    • Geometry
      • ConvexHull
        • Algorithms.Geometry.ConvexHull.DivideAndConqueror
        • Algorithms.Geometry.ConvexHull.GrahamScan
        • Algorithms.Geometry.ConvexHull.Types
      • DelaunayTriangulation
        • Algorithms.Geometry.DelaunayTriangulation.DivideAndConqueror
        • Algorithms.Geometry.DelaunayTriangulation.Naive
        • Algorithms.Geometry.DelaunayTriangulation.Types
      • EuclideanMST
        • Algorithms.Geometry.EuclideanMST.EuclideanMST
      • PolyLineSimplification
        • Algorithms.Geometry.PolyLineSimplification.DouglasPeucker
      • SmallestEnclosingBall
        • Algorithms.Geometry.SmallestEnclosingBall.Naive
        • Algorithms.Geometry.SmallestEnclosingBall.RandomizedIncrementalConstruction
        • Algorithms.Geometry.SmallestEnclosingBall.Types
    • Graph
      • Algorithms.Graph.DFS
      • Algorithms.Graph.MST
    • Algorithms.Util
  • Control
    • Monad
      • State
        • Control.Monad.State.Persistent
  • Data
    • Data.BinaryTree
    • CircularList
      • Data.CircularList.Util
    • Data.CircularSeq
    • Data.Ext
    • Data.Geometry
      • Data.Geometry.Ball
      • Data.Geometry.Boundary
      • Data.Geometry.Box
        • Data.Geometry.Box.Internal
      • Data.Geometry.Duality
      • Data.Geometry.HalfLine
      • Data.Geometry.Interval
      • Data.Geometry.Ipe
        • Data.Geometry.Ipe.Attributes
        • Data.Geometry.Ipe.FromIpe
        • Data.Geometry.Ipe.IpeOut
        • Data.Geometry.Ipe.Literal
        • Data.Geometry.Ipe.PathParser
        • Data.Geometry.Ipe.Reader
        • Data.Geometry.Ipe.Types
        • Data.Geometry.Ipe.Writer
      • Data.Geometry.Line
        • Data.Geometry.Line.Internal
      • Data.Geometry.LineSegment
      • Data.Geometry.Point
      • Data.Geometry.PolyLine
      • Data.Geometry.Polygon
        • Data.Geometry.Polygon.Convex
      • Data.Geometry.Properties
      • Data.Geometry.Slab
      • Data.Geometry.SubLine
      • Data.Geometry.Transformation
      • Data.Geometry.Triangle
      • Data.Geometry.Vector
        • Data.Geometry.Vector.VectorFixed
    • Data.Permutation
    • Data.PlanarGraph
    • Data.PlaneGraph
    • Data.Range
    • Data.Seq2
    • Sequence
      • Data.Sequence.Util
    • Data.UnBounded
  • System
    • Random
      • System.Random.Shuffle

Flags

NameDescriptionDefaultType
examplesBuild demonstration programsDisabledManual

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

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for hgeometry

Readme for hgeometry-0.5.0.0

HGeometry

Build Status Hackage

HGeometry provides some basic geometry types, and geometric algorithms and data structures for them. The main two focusses are: (1) Strong type safety, and (2) implementations of geometric algorithms and data structures with good asymptotic running time guarantees. Design choices showing these aspects are for example:

  • we provide a data type Point d r parameterized by a type-level natural number d, representing d-dimensional points (in all cases our type parameter r represents the (numeric) type for the (real)-numbers):
newtype Point (d :: Nat) (r :: *) = Point { toVec :: Vector d r }
  • the vertices of a PolyLine d p r are stored in a Data.Seq2 which enforces that a polyline is a proper polyline, and thus has at least two vertices.

Please note that aspect (2), implementing good algorithms, is much work in progress. HGeometry currently has only very basic types, and implements only a few algorithms:

  • two (optimal) $O(n \log n)$ time algorithms for convex hull in $\mathbb{R}^2$: the typical Graham scan, and a divide and conqueror algorithm,
  • an $O(n)$ expected time algorithm for smallest enclosing disk in $\mathbb{R}^$2,
  • the well-known Douglas Peucker polyline line simplification algorithm,
  • an $O(n \log n)$ time algorithm for computing the Delaunay triangulation (using divide and conqueror).
  • an $O(n \log n)$ time algorithm for computing the Euclidean Minimum Spanning Tree (EMST), based on computing the Delaunay Triangulation.

A Note on the Ext (:+) data type

In many applications we do not just have geometric data, e.g. Point d rs or Polygon rs, but instead, these types have some additional properties, like a color, size, thickness, elevation, or whatever. Hence, we would like that our library provides functions that also allow us to work with ColoredPolygon rs etc. The typical Haskell approach would be to construct type-classes such as PolygonLike and define functions that work with any type that is PolygonLike. However, geometric algorithms are often hard enough by themselves, and thus we would like all the help that the type-system/compiler can give us. Hence, we choose to work with concrete types.

To still allow for some extensibility our types will use the Ext (:+) type. For example, our Polygon data type, has an extra type parameter p that allows the vertices of the polygon to cary some extra information of type p (for example a color, a size, or whatever).

data Polygon (t :: PolygonType) p r where
  SimplePolygon :: C.CList (Point 2 r :+ p)                         -> Polygon Simple p r
  MultiPolygon  :: C.CList (Point 2 r :+ p) -> [Polygon Simple p r] -> Polygon Multi  p r
  ```

In all places this extra data is accessable by the (:+) type in Data.Ext, which
is essentially just a pair.

Reading and Writing Ipe files
-----------------------------

Apart from geometric types, HGeometry provides some interface for reading and
writing Ipe (http://ipe.otfried.org). However, this is all very work in
progress. Hence, the API is experimental and may change at any time!