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.1.tar.gz (82.4 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.1-cp313-cp313-win_amd64.whl (5.4 MB view details)

Uploaded CPython 3.13Windows x86-64

geompp-0.16.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

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

geompp-0.16.1-cp312-cp312-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.12Windows x86-64

geompp-0.16.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.0 MB view details)

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

geompp-0.16.1-cp311-cp311-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.11Windows x86-64

geompp-0.16.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.6 MB view details)

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

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

Uploaded CPython 3.10Windows x86-64

geompp-0.16.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.2 MB view details)

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

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

Uploaded CPython 3.9Windows x86-64

geompp-0.16.1-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.1-cp38-cp38-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.8Windows x86-64

geompp-0.16.1-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.1.tar.gz.

File metadata

  • Download URL: geompp-0.16.1.tar.gz
  • Upload date:
  • Size: 82.4 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.1.tar.gz
Algorithm Hash digest
SHA256 0982e096acabc962da08b40ac11a99b8d5a067c9203785964fb169204d5402f0
MD5 7de42245d6540a1f7c500fb819e18b6a
BLAKE2b-256 2a7b6c32dd997f655e6261e764c02f1424ee8ebb6861d11fb11f7477d4e6aa6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.16.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 5.4 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b5163376a103e036031117c421577a7441a1b4ee4282080767602306b6866e42
MD5 7f7ed79778a2466fe7d690ea16e00567
BLAKE2b-256 fff632d7cb03c2c57e3283ee2f5196cab0bed3e8893c2d24a34626f2890e96f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.16.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 534cc0ccdc95871c7c0e71341dfad3f2d45c1b215f69b911ab7f1c9eed78d57d
MD5 98ff551ff72ec4226b02bb37683f88c2
BLAKE2b-256 985ee4cce8bf972431c2a59b6c373b4dc0758323555063d7cb58a088388887bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.16.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.6 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3dfdd5ef50b50063d6a6d8f0775eb0b354cd54f38ea0cc553eaac47bffffee91
MD5 305d02bfecf4a23efcff77533062a174
BLAKE2b-256 4542ae26e82254eff1c3d1474b9de987c2619e1dd04b3ff6e8f3b8d746ffcbeb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.16.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8ee5bbf9226bd625343a18691d8b6c7b446ff5790d828dcded305c05eccdbed
MD5 6df3728765aed1c2177af0de0414aa89
BLAKE2b-256 68c3b7d1dd485087bde04a12a9527f80cf4cfff9ec51b73e9748679fef354ee0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.16.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.8 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 96bbb11fc9f4895f28b7c6463c3389885b95fa822e83a3f7a41bad0983c671f4
MD5 4ed6848917b80508f17bda5f5e8fb016
BLAKE2b-256 1b934bfa6e2ea4ae7d0657e1e0802ed8d3fe91976cb9dd31336c02b85af95fa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.16.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6727191681b8c6f47e2c0740b23e5d2b66632b904d86d1f6158757ec60796996
MD5 29240398cf64bb40c1e5a573fd68e188
BLAKE2b-256 844e23d2c69320555eb71b390025c3eecec72976c3d94f39ff263952609c6eb2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.16.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e3d0a276d57a1d10911046c59eb35b11a8df13531cd6fb2aa8f42e70199d5d2a
MD5 359ca8501987fa6ff0b4843aea75fac3
BLAKE2b-256 21620f691cdd4e1e85f94d86d78babf959d068dc034bee7ffe1353037253d463

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.16.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d0493d68afba08cecd054998107d13112da230ad3b31b9642c6460a2d12bc90
MD5 864d477f52d65a898f71c864dc69cabc
BLAKE2b-256 eddd6b59b6f074eccc5c6377ed99fe0d226787963f0a94fa316d1fe2129ecf56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.16.1-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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 546ad70ec5f7a41bd47c5acf6b79342aa366b228b655059f2e7d2f18ce866b67
MD5 a7da1aa7c51c822801b897602c5f9f1a
BLAKE2b-256 030ce9ff8745227b00d5c729ebd108015610c117949be1bf3cf1b4fdb5f01818

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.16.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b4ae4ad9b1c547e088c7f9b13f43275286fe77e5d82bc2fbf56179400ee0932
MD5 2e8076d341600cccaa3609f6b66e16e8
BLAKE2b-256 b69bfe1b3033567044820fe3f2d3438d4770a80b6995d518648e804ac519a7c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.16.1-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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b8261862c50f1203df211c7870b1fe2c1b4c4f3fe491c28b500de797ebfc750f
MD5 ce83df415e8a52b8bc7d82065c3a6bd9
BLAKE2b-256 e3ed7ac75e84507e791563919ec16fd8b9edac6ac0182ca33b0c236152ca57c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.16.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 095073961fea3da48618098c17d9923911d7bdf9bfeea27f7425f76829ef7dd4
MD5 b2caa6a725ce45305a096263b806b39f
BLAKE2b-256 dc9535eb09c9e5c9e9a768197b62adaffdf73e36f96e3f5fdb33c1a1382133ff

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