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.
Test Coverage
This is the summary of the current test coverage. More on test coverage.
| Metric | Count | Notes |
|---|---|---|
| Public methods (C++) | ~513 | Excl. ctors/dtors/operators. geompp::maths/geompp::transformations (templated/free-function, header-only) tracked separately, see test_coverage_report.md |
| C++ methods tested | ~493/513 | ~96% (1204 TEST cases, 1202 run, 2 disabled — incl. 37+17 for geompp::maths +6 for its own detail::, 30 for geompp::transformations, +40 direct detail::/detail::view:: tests) |
| Python methods tested | 458/474 | ~97% (903 pytest cases — incl. 27+6 for geompp.maths, 24+9 for geompp.transformations, +4 for distance_to(Point) on Polygon2D/3D/Triangle2D/3D) |
| C# methods tested | 518/581 | ~89% (1003 harness tests — incl. 24+6 for GeomPP.Maths, 23+9 for GeomPP.Transformations, +6 for DistanceTo(Point) on Polygon2D/3D/Triangle2D/3D, +2 for Triangle2D-Triangle2D intersection parity) |
| Stubs (not yet impl.) | 2 | TriangulationParams::Strategy::MonotonePolygon/Delaunay — intentional, 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
What it provides
Serialization
All primitives support:
- WKT (Well-Known Text) —
to_wkt()/from_wkt()for standard text interchange - Binary file I/O —
to_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.
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
Planeclass or the fasterView2D(one of the 3 world planes XY/YZ/ZX, or a custom plane). - Interpolation / Location —
lerp(p0, p1, t)retrieves a point at parametertbetween two points (not clamped);interpolate(t)does the same along a segment or polyline; the opposite operation finds the parametertfor 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-intersection —
Polygon2D.is_simple()and the free functionshas_intersections(segments)(Shamos–Hoey, boolean) /find_intersections(segments)(Bentley–Ottmann, every crossing point). - Convex hull —
convex_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 operations —
Polyline.reduce()(decimation) andPolyline.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 operations —
intersection(),union(),difference(),xor()between two polygons (map-overlay method), or the free functionclip(clipper_loop, subject_loop)for raw point loops without constructing aPolygonfirst. - Point cloud operations —
principal_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 |
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geompp-0.17.0.tar.gz.
File metadata
- Download URL: geompp-0.17.0.tar.gz
- Upload date:
- Size: 93.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffd98367a23a69db17e5d8b56532de262c2001f927aa3edb3542a377945c8397
|
|
| MD5 |
e9b4639f2ec186d838a78409186fc799
|
|
| BLAKE2b-256 |
834982f5d39230f71a93c09ee3dbe850c19a6f0890af1d538fee9803d11948b9
|
File details
Details for the file geompp-0.17.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: geompp-0.17.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 5.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad37cee381d5f25c518a36686e63bc147b2d5cf1cfc6f0fce5bbac490bd3bd6c
|
|
| MD5 |
96969826a7551297b28af7c1fbdfb9ff
|
|
| BLAKE2b-256 |
e09116289b54f2b420f9db569734f1302c131d3e1174da4ff44c27313e22d9e6
|
File details
Details for the file geompp-0.17.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.17.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 9.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28c9101e5b21e85f29286fb4ca5204ced285d14089f22538c42b0041e7f1b5bd
|
|
| MD5 |
596e690e2ffbe5b05a6bdbe83140766c
|
|
| BLAKE2b-256 |
75f04f50f5a74ed90e5e75f8262f6bfec971a76b955bfd95943dcec8c65c8744
|
File details
Details for the file geompp-0.17.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: geompp-0.17.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 4.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2ad1cb0a1bc174d3897434de01016073402ef7b053fafe75664b3fb4f7f39a6
|
|
| MD5 |
bb52a9a4917b06c29a699bd177734576
|
|
| BLAKE2b-256 |
04c7dfe0a3e97a08990ef1bd818e48cb357fd2b79ac002deab3e386a737b0305
|
File details
Details for the file geompp-0.17.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.17.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 7.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcff0e6b868f731d87ea1b58631b63461966095b71e1148583c6d41f63227efa
|
|
| MD5 |
bf4d8afc8ecb337534676655028ec78f
|
|
| BLAKE2b-256 |
ef8d5d333f3ae0a20e763a25f53fc43ea23b8b7dd59be252c035032191e6baaf
|
File details
Details for the file geompp-0.17.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: geompp-0.17.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 4.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a105e0d108a0cd8a9da8e9d10fba16a47436544f51ba8123110c65add323d27e
|
|
| MD5 |
2926bdb06f85d813e4379f867b3e8369
|
|
| BLAKE2b-256 |
9e0fb2eaedaf0f8a1c2a6af644ecb46460b6daad33d44e055d0dc243984c66b8
|
File details
Details for the file geompp-0.17.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.17.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ac9838dc44319f1b80a5eb8cb84839f4a5ab6e13fd5b1bfcead5d4c4b8d4676
|
|
| MD5 |
226fd4f7a5aa0d5684ca1342959dc736
|
|
| BLAKE2b-256 |
c8009e383a6bee2ff4eb599f1dce3e1d0d28e7520ca0ed38ffe6e1b388246418
|
File details
Details for the file geompp-0.17.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: geompp-0.17.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 3.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20cababea436b60f5e7f6c9b7c212f549132e43f9da75854622e5990267c4259
|
|
| MD5 |
62f055d9fd3117df5de56c456928ff7c
|
|
| BLAKE2b-256 |
bcffb58fb7d6268caf730e5d0ca9dc4d95560f08cd964deeb9b2f465a3e34579
|
File details
Details for the file geompp-0.17.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.17.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
927271569adf2390aa320ecb87accd94fd007ff8abb888c3a5843035fde2ba28
|
|
| MD5 |
7da80bf21c6b0ba99bcaffe64779d686
|
|
| BLAKE2b-256 |
c27b931144be5404bd0e460a1ac6bea49a787b18c044490cbdc5dff46375197c
|
File details
Details for the file geompp-0.17.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: geompp-0.17.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 2.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
720cc328071a5207e96b9e356e0f13427b39d18c7f9966f06f10e8b0db9a2f2f
|
|
| MD5 |
7a436e593f27920f38cdeb4cfac072e6
|
|
| BLAKE2b-256 |
c676878836ca3b0e37bc506dc26f78364a01f2fe6f113e8a2cf683dc4e562993
|
File details
Details for the file geompp-0.17.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.17.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff6a2f730e46ec7596f291ceacf3008b669dda8c448f316211edf03ae96998b6
|
|
| MD5 |
c2497a317f71643b658bca6d11d67f3d
|
|
| BLAKE2b-256 |
82f60012fcb21cb07a2d90632d247d1ccd8dfd0323f241f195ae7ddbf7d119d6
|
File details
Details for the file geompp-0.17.0-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: geompp-0.17.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
880a554c197ee7d7245a1f354bc8fbc88926701ab725695b372f2d42b7ddd591
|
|
| MD5 |
0b4af99386b655985ae1f1f44e673ebc
|
|
| BLAKE2b-256 |
045a571cc9a8da6ae0dd159a5266517dec2e8872409503276ad4eae6806f8f7f
|
File details
Details for the file geompp-0.17.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.17.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.8, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f04141d013473ff088e8aadbbab062385a7f1aa51525a2556f37e34a6f2adacf
|
|
| MD5 |
eaf65dba7fc4a40721ff945cdd69cdd7
|
|
| BLAKE2b-256 |
3541465f4bdc803d45120bd8a6c4c834af33d5637b48098dc62d9ed8c1e125af
|