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.

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/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.

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.
  • Linear algebra (geompp.maths) — a small fixed-size linear algebra submodule, independent of the geometry classes above: Vector2/Vector3/Vector4, Matrix2/Matrix3/Matrix4, and the solve_gauss() / solve_cramer() system solvers for Ax = b.
  • Affine transformations (geompp.transformations) — translate(), rotate(), scale(), shear(), reflect() (fast, single-point, no matrix needed), and the general transform(primitive, matrix) for every primitive from Point2D/Point3D to PolyMesh2D/PolyMesh3D. Use TransformBuilder2D/TransformBuilder3D to fluently chain several transforms (e.g. .translate(...).rotate(...).scale(...)) into a single Matrix3/Matrix4, then apply it once with .build()/transform().

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
maths.solve_gauss(a, b) Solve Ax = b via Gaussian elimination
maths.solve_cramer(a, b) Solve Ax = b via Cramer's rule; raises ValueError if a is singular
transformations.translate(primitive, offset) Translate a primitive by a vector
transformations.rotate(primitive, angle_rad[, axis]) Rotate about the origin — 3D takes an axis
transformations.scale(primitive, factor | sx, sy[, sz]) Uniform or non-uniform scale about the origin
transformations.shear(primitive, ...) Shear along one axis by a multiple of another
transformations.reflect(primitive, normal) Reflect about a line/plane through the origin with the given normal
transformations.transform(primitive, matrix) Apply an arbitrary Matrix3/Matrix4 (homogeneous) to any primitive from Point to PolyMesh

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.17.3.tar.gz (94.8 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.17.3-cp313-cp313-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.13Windows x86-64

geompp-0.17.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (9.3 MB view details)

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

geompp-0.17.3-cp312-cp312-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.12Windows x86-64

geompp-0.17.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

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

geompp-0.17.3-cp311-cp311-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.11Windows x86-64

geompp-0.17.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.2 MB view details)

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

geompp-0.17.3-cp310-cp310-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.10Windows x86-64

geompp-0.17.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.6 MB view details)

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

geompp-0.17.3-cp39-cp39-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.9Windows x86-64

geompp-0.17.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.1 MB view details)

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

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

Uploaded CPython 3.8Windows x86-64

geompp-0.17.3-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.6 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.17.3.tar.gz.

File metadata

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

File hashes

Hashes for geompp-0.17.3.tar.gz
Algorithm Hash digest
SHA256 4f1cb16776dc709311d7cc5eb5b642660ada7ee2701e69f49a6c6d066bd9a3d8
MD5 1d9fcf6cb478f9d876560a6476921bbb
BLAKE2b-256 a042bcab75ebba31f5390846018c9d525c282155cb0f836c6e939d60a75a5726

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.17.3-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

Hashes for geompp-0.17.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 26783533fb02ba99e122cafe2fa2c5ae8d34699132f6e2d78756b871095f30d1
MD5 5dcc244b61dc944e1d1fcfdd75ba6fbe
BLAKE2b-256 34bade958e44156c0b1cc84e46568c80c9b6750d6a3e233624da115d2ee850ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.17.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 979d7be24a93dceaa6d48f0e49ff8f04d1b6f5d33322c8d7a728fa65552d0481
MD5 a39cadcc28c7c9a15a1df612f7cb330e
BLAKE2b-256 aeeb642281e29663e8b351b1e5bb6c581a44c96882658a884807213d63b321ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.17.3-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

Hashes for geompp-0.17.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3d7a09f3e99bcad9ec3a81f60baa0973373e2e4e8973586213f32354a9f2394e
MD5 6901e986a854e18437bb17dcfdc0ce22
BLAKE2b-256 c60cb54f53796f2ecd3b26f64c88c684669bf69063b652574380d204bac3ffb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.17.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aa48801e80ed21ad4ab438c908a5ed9c7f68b9c01d9c5748b20870af94d13605
MD5 e724b583d7365d5aff8758f09d1f7c68
BLAKE2b-256 1f4df342a9553704a907403fb04321a8d2acac9d27cb9801a8f667e69d7b3fa9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.17.3-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

Hashes for geompp-0.17.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8130c09d254e327f4958904f781108edc03927aba2907bb7c5eb1139d7d9c16e
MD5 85d79a97751475314ead35a0620170c4
BLAKE2b-256 d55d3f4552dd61f819de76011680b0cefc02f277b97b3ad2b87487a450544f41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.17.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5bec38418bd57437c412e4bc061d1c03197c004b98fcb6dd1b4a2ad689b3b39a
MD5 6464013a336e11757b6771146deb8f8c
BLAKE2b-256 6229689e91d5c8732b1d032af4f0d971f542cdeb55a438c1f003a478d6b94ad6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.17.3-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

Hashes for geompp-0.17.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 72c394ff291e5fc0dbcfe9eef7a4b9b5058ee3a5eb4fe1147b61428e8d756c0e
MD5 ba484bea04966c4a07c7f832dc88f434
BLAKE2b-256 db85b5076c1536d569746b7d63a8f9d6744a7b2e17461ae4ab488f063522fed7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.17.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f048632384bdbc1caaa07a2346e0b424e27bbee28a9a0db8d45e4d3fae45d6b8
MD5 4d7f3ee2cc8c514820681a1c74afde6b
BLAKE2b-256 4fb35b2ff831f8a6143ef4bcd37f3f6ea399e5851ed531bc0548c209ee2284d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.17.3-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

Hashes for geompp-0.17.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 55e728733435a0349480c2c6a60eacc647fbff663bbb175c72fdf83a09dc03d0
MD5 3c998b25ce7da308039a81fff7b21e03
BLAKE2b-256 3bd5a981934012e7aeebfb0efe506beaf2742bb87223cbdfebcb17dbb109309f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.17.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 94cae5405086bd7a25fd9c16eaab6d866a55176cee415d2a67cdac39422f75b5
MD5 c554d3d1df9b16dec40fc39c658d56f0
BLAKE2b-256 9a3315d7d262ebb449cf0bd118961a433c846fce076d3c56586a4ef66bc34c35

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.17.3-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.17.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 556cf65c2002ccae4b3fc363a4ff364711d513be2129b2c3a3ae588542e28911
MD5 c665b24a13a4cbd6c93449abd42ba0e3
BLAKE2b-256 5376c079ee2e27f5c2a0c3e1d2f9b7f90e9801ad1edc57dd90a65f194129544e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.17.3-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5573822e6c56852bc9a2053266362503602bde03a38743db0a6ebd23a326376e
MD5 6aefb5c11985e29ae80f52275fe744f7
BLAKE2b-256 836a40c6ce4f1a19b5b2f3bcc4602b4658c1a8e9d838f983149a1526a3d98a20

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