Skip to main content

GeomPP

A modern C++20 geometry library for 2D and 3D spatial computation — fast, mathematically correct, thoroughly tested, and usable from C++, C# (.Net 8/9/10 or .Net Framework 4.8), and Python 3.

You may be a CAD or a Game developer using C#.Net, and you use APIs native to the platform you develop into. These native APIs are easy to get in, but may contain bugs that have not been fixed, or simply lack some functionalities. You may be a Data Scientist using Python on a GIS project, and having to import 3+ libraries, and covert from data-structure to data-structure to use it. You may be a C++ developer who wants to import a more lightweight library than those which already exist, and possibly more user friendly.

This library was born a few years ago to solve all these problems. It was recently augmented with the aim of using the most modern algorithms to solve a variety of geometrical problems.

The sources of these algorithms are to be found in several textbooks, such as

  • Practical Geometry Algorithms (Danniel Sunday)
  • Computational Geometry in C (Joseph O'Rourke)
  • Computational Geometry (Mark de Berg, Marc van Kreveld, Mark Overmars, Otfried Schwarzkopf)

Finally, the help of AI was used to validate algorithms (bug-free, guarantee the desired big-O), bind into other languages than C++, add edge cases to achieve a high test coverage, and build documentation.

Python Bindings

Python bindings for geompp — a C++ 2D/3D geometry library.

Changelog — full release notes for every version.

Install

pip install geompp

Platform note

Pre-built wheels are available for:

Platform Python versions
Linux x86_64 3.8 · 3.9 · 3.10 · 3.11 · 3.12 · 3.13 · 3.14
Windows x64 3.8 · 3.9 · 3.10 · 3.11 · 3.12 · 3.13 · 3.14

If your platform or Python version is not in the table above, pip will compile from source — you will need CMake ≥ 3.15 and a C++20-capable compiler.

Classes

Where not explicitely specified, both 2D and 3D variants are available for all core types:

Primitive Description
Point A coordinate in space
Vector Direction and magnitude
Line An infinite line through two points
Ray A semi-infinite line from an origin in one direction
LineSegment A finite segment between two endpoints
Polyline A connected chain of segments
Triangle Three non-collinear points forming a closed face
Polygon A closed polygon defined by an ordered list of vertices
BBox Axis-aligned bounding box
BBall Minimum bounding sphere (Ritter's algorithm)
BRect2D Minimum oriented bounding rectangle (rotating calipers)
BPrism3D Minimum oriented bounding prism (PCA + rotating calipers)
Plane A flat surface in 3D defined by a point and a normal
View2D A class that converts a 3D point into 2D quicker than plane
Mesh A set of adjacent triangles that together make up a detailed 2D or 3D shape (a surface or a solid)
ConnectedMesh This one keeps track of the neighbors of each triangle, so that going from a facet to its 0-3 neighbors is very quick
PolyMesh Not just triangles, also polygons are allowed, in order to save on the number of vertices on the same planar regions of the surface

Algorithm overview

Each class supports a consistent set of spatial operations where applicable:

  • Containment — does a shape contain a given point?
  • Intersection — do two shapes strike through each other, and what is the resulting geometry? Also available as the free function find_intersections() on a free set of segments. The meaning of this operation changes from 2D to 3D — check the class docs.
  • Overlap — do two shapes have a portion in common, and what is the resulting geometry? Meaning changes from 2D to 3D.
  • Touch — do two shapes have a point in common, and which is it? Meaning changes from 2D to 3D.
  • Distance — closest distance from a point to a shape.
  • Plane operations — projection of a point from 3D to 2D, and re-projection from 2D to 3D, via the Plane class or the faster View2D (one of the 3 world planes XY/YZ/ZX, or a custom plane).
  • Interpolation / Locationlerp(p0, p1, t) retrieves a point at parameter t between two points (not clamped); interpolate(t) does the same along a segment or polyline; the opposite operation finds the parameter t for a point already on a shape.
  • Area / Perimeter / Centroid — geometric properties for closed shapes.
  • Signed area — encodes orientation (clockwise vs. counter-clockwise in 2D, surface normal direction in 3D).
  • Simplicity / self-intersectionPolygon2D.is_simple() and the free functions has_intersections(segments) (Shamos–Hoey, boolean) / find_intersections(segments) (Bentley–Ottmann, every crossing point).
  • Convex hullconvex_hull(points) — Andrew's monotone chain, returns hull vertices in CCW order.
  • Bounding containers — tight-fitting containers around point clouds: axis-aligned bounding box, bounding ball, minimal oriented rectangle, convex hull.
  • Polyline operationsPolyline.reduce() (decimation) and Polyline.expand() (Bezier corner smoothing), or the underlying free functions (dist_decimation()/rdp_decimation()/vw_decimation(), bezier_smoothing_2(), polyline_expansion()) for a plain point list.
  • Polygon boolean operationsintersection(), union(), difference(), xor() between two polygons (map-overlay method), or the free function clip(clipper_loop, subject_loop) for raw point loops without constructing a Polygon first.
  • Point cloud operationsprincipal_axes() (PCA) finds the empirical 3 directive axes of a list of points in space.
  • Triangulation — decomposition of a polygon into n-triangles, using several possible algorithms such as the Ear Clip, a Best Fit Ear Clip, Monotone Polygon or Constrained Delaunay.

Return values are None on no-intersection, and sometimes a Point/list[LineSegment]/list[Polygon] depending on what the operation produced — check each method's docstring for the exact shape.

Free functions

Function Description
are_collinear(p1, p2, p3) Three points on the same line
remove_consecutive_duplicates(points) Drop consecutive duplicate points
remove_duplicates(points) Drop duplicate points
remove_collinear(points) Drop collinear intermediate points
linear_combination(points, weights) Weighted sum
average(points) Arithmetic mean
lerp(p0, p1, t) Linear interpolation between two points — P0 + t*(P1-P0), not clamped
centroid(points[, plane]) Centroid of a polygon (3D: plane auto-detected if omitted)
signed_area(points[, plane]) Signed area of a polygon; positive = CCW, negative = CW
are_ccw(points[, ref_plane]) Counter-clockwise winding (2D or 3D)
are_cw(points[, ref_plane]) Clockwise winding (2D or 3D)
are_coplanar(points) List of Point3D on the same plane
closest_world_plane_to(points) XY / YZ / ZX plane nearest to the point cloud
has_intersections(segments) Shamos–Hoey: True if any two segments in list[LineSegment2D] cross
find_intersections(segments) Bentley–Ottmann: returns list[Point2D] — every crossing point, sorted left-to-right
convex_hull(points) Andrew's monotone chain: convex hull of a list[Point2D], returned in CCW order
convex_hull(points, normal=None) Convex hull of a coplanar list[Point3D]; optional Vector3D normal (auto-detected if omitted)
clip(clipper_loop, subject_loop) Set intersection of two point loops — list[Point2D] natively, list[Point3D] if coplanar (same map-overlay engine as Polygon.intersection())
dist_decimation(points, threshold) O(n) radial-distance point decimation
rdp_decimation(points, threshold) Ramer–Douglas–Peucker point decimation
vw_decimation(points, threshold) Visvalingam–Whyatt point decimation
bezier_smoothing_2(p0, p1, p2, smoothness, min_distance|num_segments, min_segment_length=...) Rounds one polyline corner with a quadratic Bezier arc
polyline_expansion(points, settings) Rounds every inner corner of a point list and works with either fixed number of segmens or fixed min segment length (the engine behind Polyline.expand())
principal_axes(points) PCA on a list[Point3D]: returns CoordinateFrame (.x primary, .y secondary, .z best-fit normal)
principal_normal(points) Best-fit plane normal of a list[Point3D] (PCA eigenvector with smallest eigenvalue)
principal_direction(points) Dominant direction of a list[Point3D] (PCA eigenvector with largest eigenvalue)
find_extreme_points(polygon, line) The two polygon vertices least/greatest projected along a line's direction
distance_to(polygon, line) Distance from a polygon to a line (zero if they intersect)
tangents_to(polygon, point_or_polygon) PolygonTangents2D/PolygonTangents3D (.left/.right) — tangent segments to a point, or common outer tangents to another polygon
triangulate(polygons, settings) Returns a set of adjacent triangles replacing the surface of 1+ polygons (the engine behind Polygon::Triangulate() and PolyMesh::Triangulate()), and with a robust input validation

Serialization

All primitives support:

  • WKT (Well-Known Text) — to_wkt() / from_wkt() for standard text interchange
  • Binary file I/Oto_file() / from_file() for compact storage

Precision

Floating-point comparisons use a thread-local DECIMAL_PRECISION constant via AlmostEquals() methods, making the library robust against rounding errors while remaining configurable per thread.

Test Coverage

This is the summary of the current test coverage. More on test coverage.

Metric Count Notes
Public methods (C++) ~491 Excl. ctors/dtors/operators
C++ methods tested ~469/491 ~95% (909 TEST cases, 907 run, 2 disabled)
Python methods tested 423/443 ~95% (742 pytest cases)
C# methods tested 482/549 ~88% (846 harness tests)
Stubs (not yet impl.) 0 Previously 10 — all now implemented (see test_coverage_report.md)

How to use it

You can look at the test suite to see detailed usage.

A quick list of code examples per topic is provided here.

👉 Visual Documentation and Code Examples on Github

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geompp-0.16.2.tar.gz (82.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

geompp-0.16.2-cp313-cp313-win_amd64.whl (5.3 MB view details)

Uploaded CPython 3.13Windows x86-64

geompp-0.16.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

geompp-0.16.2-cp312-cp312-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.12Windows x86-64

geompp-0.16.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

geompp-0.16.2-cp311-cp311-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.11Windows x86-64

geompp-0.16.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

geompp-0.16.2-cp310-cp310-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.10Windows x86-64

geompp-0.16.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

geompp-0.16.2-cp39-cp39-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.9Windows x86-64

geompp-0.16.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

geompp-0.16.2-cp38-cp38-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.8Windows x86-64

geompp-0.16.2-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file geompp-0.16.2.tar.gz.

File metadata

  • Download URL: geompp-0.16.2.tar.gz
  • Upload date:
  • Size: 82.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for geompp-0.16.2.tar.gz
Algorithm Hash digest
SHA256 b6914b88d6e40d5dbd07ea1cfcbd7630365da260b39fd33361c8af6d020a6299
MD5 5c0facb7cc26c79b8ebb53b744f08f14
BLAKE2b-256 8fc74b97b480819a9b3c4c6edd89701de378433482261f4a6944f189846b2a26

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: geompp-0.16.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 5.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for geompp-0.16.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 aa3dc893ebe53f05caaaa7172c28589d2e68731166acdc61baaca081c9462579
MD5 71e42f1fe53759feed2aa968ba3e85d9
BLAKE2b-256 f1fa19e323ec8659cfe79cde9c14b8bc4b7b5804cdff0423fec6b2fc4037f03d

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geompp-0.16.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1a24b9301c236e265c513a9744df1693eb78dc60a051adcb2e3057ebca7e8aee
MD5 0d46715048b8a3f02fc5df1dd8200c2a
BLAKE2b-256 b59bcec6bf906bfa0a59e835950c95426018223fbfdc630da44cf65fa80040b8

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: geompp-0.16.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for geompp-0.16.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f65e4d57de30cf9d1088d49a4ccbc4142a1e406d3b6f77ee2c64b5eb01c379e5
MD5 0db19226f7bba4ec2720f1762351002d
BLAKE2b-256 840d89adbd2bc717cb836f14ab84acfd515010512d0d140c1120a76fb893ab79

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geompp-0.16.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a5ef14cde6b7017fa5c0a396de11426b419dde293e0cd7597a1390be531997ae
MD5 16a258be2bb0de406f1d181350e0bd16
BLAKE2b-256 23431824da64654deaee7027e0143c3373fdd89b56b78533944238432318f618

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: geompp-0.16.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for geompp-0.16.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2183405519c487b179d9fbc1a6d2ac631709e3dbbb9190e64d49aacdb34f0eb1
MD5 e8afa739fa05da86c206567bffc2f88f
BLAKE2b-256 c8c9e357ef3e75a1c5384269cd310b20bf916464e5832dc4b267b0a3a04af975

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geompp-0.16.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d37e9433ddad2e3edc2da6367d70bf3c5064537b8db32a6f5b600e8a7cae2d85
MD5 b995e3e20daf4136c3412f9f8ecd5479
BLAKE2b-256 5372af1d5d39a763a20d3130cfddc28cc144eeb26e3d9b7af2188aae7daeb40b

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: geompp-0.16.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for geompp-0.16.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 abf6a1aaa4d4a89f5c8378ba42b5e757c8ca9455b225f376239bfe9ef3e4ce9d
MD5 ae7a8461e70bddd787e3ad896d142ac5
BLAKE2b-256 402d4c84e5097588de852e7a377544e220eb918930366ac35727d461a790f2fe

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geompp-0.16.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 039f7bee7e8360378781ee79320183f8d5c461204256605c9958dc802e8aaa7a
MD5 38598ccc63ff64c248aba4d27c0db264
BLAKE2b-256 de5adbe547f49e5e7f667f0bcd31e6a1e7c4aea706028d6615d96ff9519fe096

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: geompp-0.16.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for geompp-0.16.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2aabb9d583a74ac292517489168663a6dfc2ce14d4fce4d8d13a13361c734f3c
MD5 a0d101ea16f7193bb2ce73293fbbd11b
BLAKE2b-256 edcaf69ffd6df16bf109d113cedaaeff685f76b496404bbe561e846166c5616d

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geompp-0.16.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f25086b9140c41dfc82a6228c3061123a97a7cd64caf656c72538af073851e4
MD5 5088d997ad23313ade87e025e00d0ee7
BLAKE2b-256 48cfd9954293f0e22df397c887df30d133ad16430b128116a251696aa9e8774d

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: geompp-0.16.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for geompp-0.16.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f241c0522811ad352a4738a4ef14a50f478a0c8b91e507357737ad6a6cd7d18d
MD5 fb508d5ba2e0016d5318223923f6e0eb
BLAKE2b-256 3484d4155af388ce0f62babf334c1855779a0e0687c6002292d85b356719b35c

See more details on using hashes here.

File details

Details for the file geompp-0.16.2-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geompp-0.16.2-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 491dd56b05b5ab551e075fd63c4c18801085713e8506c25c841f9616d567cdf5
MD5 f937c02ec6adac4a2d2e0585bf49dc6f
BLAKE2b-256 9275ad2a85733bcf1bff65f90d6f846a8fd4233d4334bff90b78789b5dd8370e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page