All Projects → noinia → Hgeometry

noinia / Hgeometry

Licence: other
HGeometry

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Hgeometry

Cavaliercontours
2D polyline library for offsetting, combining, etc.
Stars: ✭ 135 (+37.76%)
Mutual labels:  geometry, computational-geometry
polliwog
2D and 3D computational geometry library
Stars: ✭ 22 (-77.55%)
Mutual labels:  geometry, computational-geometry
Cgal
The public CGAL repository, see the README below
Stars: ✭ 2,825 (+2782.65%)
Mutual labels:  geometry, computational-geometry
SplashGeom
Open-source C++ library for geometry and linear algebra
Stars: ✭ 22 (-77.55%)
Mutual labels:  geometry, computational-geometry
Geometry
Boost.Geometry - Generic Geometry Library | Requires C++14 since Boost 1.75
Stars: ✭ 282 (+187.76%)
Mutual labels:  geometry, computational-geometry
Wagyu
A general library for geometry operations of union, intersections, difference, and xor
Stars: ✭ 116 (+18.37%)
Mutual labels:  geometry, computational-geometry
topo
A Geometry library for Elixir that calculates spatial relationships between two geometries
Stars: ✭ 125 (+27.55%)
Mutual labels:  geometry, computational-geometry
Lazysets.jl
A Julia package for calculus with convex sets
Stars: ✭ 107 (+9.18%)
Mutual labels:  geometry, computational-geometry
PGS
Processing Geometry Suite
Stars: ✭ 39 (-60.2%)
Mutual labels:  geometry, computational-geometry
MidcurveNN
Computation of Midcurve of Thin Polygons using Neural Networks
Stars: ✭ 19 (-80.61%)
Mutual labels:  geometry, computational-geometry
polygon-splitter
A small (<10kb minified) javascript library for splitting polygons by a polyline.
Stars: ✭ 20 (-79.59%)
Mutual labels:  geometry, computational-geometry
Aabb Tree
A d-dimensional aabb-tree implementation for MATLAB.
Stars: ✭ 5 (-94.9%)
Mutual labels:  geometry, computational-geometry
Nurbs Python
Object-oriented pure Python B-Spline and NURBS library
Stars: ✭ 295 (+201.02%)
Mutual labels:  geometry, computational-geometry
Euclid
Exact Computation Geometry Framework Based on 'CGAL'
Stars: ✭ 52 (-46.94%)
Mutual labels:  geometry, computational-geometry
Maker.js
📐⚙ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+1109.18%)
Mutual labels:  geometry
Supercluster
A very fast geospatial point clustering library for browsers and Node.
Stars: ✭ 1,246 (+1171.43%)
Mutual labels:  computational-geometry
Leaflet.path.drag
Drag functionality for Leaflet vector layers
Stars: ✭ 72 (-26.53%)
Mutual labels:  geometry
Vos backend
vangav open source - backend; a backend generator (generates more than 90% of the code needed for big scale backend services)
Stars: ✭ 71 (-27.55%)
Mutual labels:  geometry
Trimesh
Python library for loading and using triangular meshes.
Stars: ✭ 1,303 (+1229.59%)
Mutual labels:  geometry
Complete street rule
The Complete Street Rule for ArcGIS CityEngine is a scenario oriented design tool intended to enable users to quickly create procedurally generated multimodal streets.
Stars: ✭ 81 (-17.35%)
Mutual labels:  geometry

HGeometry

GitHub Workflow Status Hackage API docs coverage

HGeometry is a library for computing with geometric objects in Haskell. It defines basic geometric types and primitives, and it implements some geometric data structures and algorithms. The main two focusses are:

    1. Strong type safety, and
    1. implementations of geometric algorithms and data structures that have 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.LSeq which enforces that a polyline is a proper polyline, and thus has at least two vertices.

Please note that aspect two, implementing good algorithms, is much work in progress. Only a few algorithms have been implemented, some of which could use some improvements.

HGeometry Packages

HGeometry is split into a few smaller packages. In particular:

  • hgeometry : defines the actual geometric data types, data structures, and algorithms,

  • hgeometry-combinatorial : defines the non-geometric (i.e. combinatorial) data types, data structures, and algorithms.

  • hgeometry-ipe : defines functions for working with ipe files.

  • hgeometry-svg : defines functions for working with svg files.

  • hgeometry-web : defines functions for building an interactive viewer using miso.

  • hgeometry-interactive : defines functions for building an interactive viewer using reflex-sdl2.

In addition there are hgeometry-examples and hgeometry-showcase packages that define some example applications, and a hgometry-test package that contains all testcases. The latter is to work around a bug in cabal.

Available Geometric Algorithms

Apart from some basic geometric primitives such as intersecting line segments, testing if a point lies in a polygon etc, HGeometry implements some more advanced geometric algorithms. In particuar, the following algorithms are currently available:

  • two O(n log n) time algorithms for convex hull in ℝ²: the typical Graham scan, and a divide and conquer algorithm,
  • an O(n) expected time algorithm for smallest enclosing disk in ℝ²,
  • the well-known Douglas Peucker polyline line simplification algorithm,
  • an O(n log n) time algorithm for computing the Delaunay triangulation (using divide and conquer),
  • an O(n log n) time algorithm for computing the Euclidean Minimum Spanning Tree (EMST), based on computing the Delaunay Triangulation,
  • an O(log n) time algorithm to find extremal points and tangents on/to a convex polygon,
  • an optimal O(n+m) time algorithm to compute the Minkowski sum of two convex polygons,
  • an O(1/εᵈn log n) time algorithm for constructing a Well-Separated pair decomposition,
  • the classic (optimal) O(n log n) time divide and conquer algorithm to compute the closest pair among a set of n points in ℝ²,
  • an O(nm) time algorithm to compute the discrete Fréchet distance of two sequences of points (curves) of length n and m, respectively.
  • an O(n) time single-source shortest path algorithm on triangulated polygons.
  • an O(n log n) time algorithm for generating random convex polygons.
  • an O(n) time algorithm for finding the convex hull of a simple polygon.

Available Geometric Data Structures

HGeometry also contains an implementation of some geometric data structures. In particular,

  • A one dimensional Segment Tree. The base tree is static.
  • A one dimensional Interval Tree. The base tree is static.
  • A KD-Tree. The base tree is static.
  • An O(n log n) size planar point location data structure supporting O(log n) queries.

There is also support for working with planar subdivisions. As a result, [hgeometry-combinatorial] also includes a data structure for working with planar graphs. In particular, it has an EdgeOracle data structure, that can be built in O(n) time that can test if the planar graph contains an edge in constant time.

Avoiding Floating-point issues

All geometry types are parameterized by a numerical type r. It is well known that Floating-point arithmetic and Geometric algorithms don't go well together; i.e. because of floating point errors one may get completely wrong results. Hence, I strongly advise against using Double or Float for these types. In several algorithms it is sufficient if the type r is Fractional. Hence, you can use an exact number type such as Data.RealNumber.Rational or Data.Ratio.Rational.

Working with additional data

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, as defined in the hgeometry-combinatorial package. For example, our LineSegment data type, has an extra type parameter p that allows the vertices of the line segment to carry some extra information of type p (for example a color, a size, or whatever). Polylines, Polylygons, Boxes, etc have similar such parameters.

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].