Skip to main content

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

Project description

← back

geompp

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

Changelog — full release notes for every version.

Install

pip install geompp

Pre-built wheels are available for:

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

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.

Quick start

import geompp as g

# Points & vectors
p = g.Point2D(1.0, 2.0)
v = g.Vector2D(3.0, 0.0)
q = p + v                       # Point2D(4, 2)
diff = q - p                    # Vector2D(3, 0)

# Lines and intersection
l1 = g.Line2D.make(g.Point2D(0,0), g.Point2D(1,0))
l2 = g.Line2D.make(g.Point2D(0.5,-1), g.Point2D(0.5,1))
hit = l1.intersection(l2)       # Point2D(0.5, 0) or None

# 3D
p3 = g.Point3D(1, 2, 3)
plane = g.Plane.xy()
proj = plane.project_onto(p3)   # Point3D(1, 2, 0)

# Plane intersections (Line / Ray / Segment / Plane / Triangle)
ray = g.Ray3D.make(g.Point3D(5, 3, 4), g.Vector3D(0, 0, -1))
hit = plane.intersection(ray)              # Point3D(5, 3, 0)
axis_y = plane.intersection(g.Plane.yz())  # Line3D along the Y-axis

# Parallel / coplanar tests
plane.is_parallel(ray)                     # False (ray crosses the plane)
plane.is_coplanar(g.Line3D.make(g.Point3D(0,0,0), g.Vector3D(1, 1, 0)))  # True

# Implicit Vector → Point construction
p_from_v = g.Point3D(g.Vector3D(1, 2, 3))  # = Point3D(1, 2, 3)

# Triangle3D intersection with Line / Ray / Segment / Plane / Triangle
tri = g.Triangle3D.make(g.Point3D(0,0,0), g.Point3D(4,0,0), g.Point3D(0,4,0))
hit_line  = tri.intersection(
    g.Line3D.make(g.Point3D(1, 1, -1), g.Point3D(1, 1, 1)))                # Point3D(1, 1, 0)
hit_ray   = tri.intersection(
    g.Ray3D.make(g.Point3D(1, 1, 4), g.Vector3D(0, 0, -1)))                # Point3D(1, 1, 0)
hit_seg   = tri.intersection(
    g.LineSegment3D.make(g.Point3D(1, 1, -2), g.Point3D(1, 1, 3)))         # Point3D(1, 1, 0)
y1        = g.Plane.from_origin_and_normal(g.Point3D(0,1,0), g.Vector3D(0,1,0))
hit_plane = tri.intersection(y1)                                            # LineSegment3D (0,1,0)→(3,1,0)
other     = g.Triangle3D.make(g.Point3D(1,1,-1), g.Point3D(1,1,1), g.Point3D(3,1,0))
hit_tri   = tri.intersection(other)                                         # LineSegment3D (1,1,0)→(3,1,0)

# Precision
g.set_decimal_precision(g.DP_SIX)

# File parser
parser = g.WktParser.open("geometry.lsv")
while parser.has_next():
    item = parser.next()
    if item is not None:
        print(g.WktParser.to_wkt(item))

Checking coplanarity, orientation, and closest world plane

import geompp as g

pts_flat = [g.Point3D(0,0,0), g.Point3D(1,0,0), g.Point3D(0,1,0), g.Point3D(1,1,0)]
pts_3d   = [g.Point3D(0,0,0), g.Point3D(1,0,0), g.Point3D(0,1,0), g.Point3D(0,0,1)]

print(g.are_coplanar(pts_flat))  # True  — all on the XY plane
print(g.are_coplanar(pts_3d))    # False — spans 3D space

# Find which world axis plane is closest to the point cloud
plane = g.closest_world_plane_to(pts_flat)
print(plane.normal)              # Vector3D(0, 0, 1)  → XY plane

# Check / require CCW winding
ring = [g.Point3D(0,0,0), g.Point3D(1,0,0), g.Point3D(1,1,0), g.Point3D(0,1,0)]
print(g.are_ccw(ring))           # True
print(g.are_cw(ring))            # False

# Polygon3D requires CCW outer ring and CW holes
outer = [g.Point3D(0,0,0), g.Point3D(4,0,0), g.Point3D(4,4,0), g.Point3D(0,4,0)]
hole  = [g.Point3D(1,3,0), g.Point3D(3,3,0), g.Point3D(3,1,0), g.Point3D(1,1,0)]
poly  = g.Polygon3D.make(outer, [hole])
print(poly.size())               # 4

Classes

2D 3D
Point2D Point3D
Vector2D Vector3D
Line2D Line3D
Ray2D Ray3D
LineSegment2D LineSegment3D
Polyline2D Polyline3D
Triangle2D Triangle3D
Polygon2D Polygon3D
BBox2D BBox3D
GeometryCollection2D GeometryCollection3D
Plane

Free functions

Function Description
are_collinear(p1, p2, p3) Three points on the same line
are_coplanar(points) List of Point3D on the same plane
closest_world_plane_to(points) XY / YZ / ZX plane nearest to the point cloud
are_ccw(points[, ref_plane]) Counter-clockwise winding (2D or 3D)
are_cw(points[, ref_plane]) Clockwise winding (2D or 3D)
remove_collinear(points) Drop collinear intermediate points
remove_duplicates(points) Drop duplicate points
average(points) Arithmetic mean
linear_combination(points, weights) Weighted sum
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)

Convex hull

import geompp as g

g.set_decimal_precision(g.DP_THREE)

# An asymmetric 5-pointed star: 5 outer tips + 5 inner concave vertices.
# The convex hull should be exactly the 5 outer tips.
star = [
    # outer tips
    g.Point2D( 0,  5), g.Point2D( 4,  2),
    g.Point2D( 3, -3), g.Point2D(-2, -4), g.Point2D(-3,  1),
    # inner concave vertices (will be excluded from the hull)
    g.Point2D( 2,  1), g.Point2D( 2, -1),
    g.Point2D( 0, -1), g.Point2D(-1, -1), g.Point2D(-1,  2),
]

hull = g.convex_hull(star)
print(f"hull has {len(hull)} vertices:")
for p in hull:
    print(" ", p.to_wkt())
# hull has 5 vertices:
#   POINT (3 -3)
#   POINT (4 2)
#   POINT (0 5)
#   POINT (-3 1)
#   POINT (-2 -4)

Convex hull of a polygon

Polygon2D and Polygon3D expose a convex_hull() method:

import geompp as g

# 3D star polygon (10 vertices, coplanar, CCW)
star = g.Polygon3D.make([
    g.Point3D( 0,  5, 0), g.Point3D( 2,  1, 0),
    g.Point3D( 4,  2, 0), g.Point3D( 2, -1, 0),
    g.Point3D( 3, -3, 0), g.Point3D( 0, -1, 0),
    g.Point3D(-2, -4, 0), g.Point3D(-1, -1, 0),
    g.Point3D(-3,  1, 0), g.Point3D(-1,  2, 0),
])

hull = star.convex_hull()   # Polygon3D with 5 vertices
print(f"hull has {hull.size()} vertices")
# hull has 5 vertices

Convex hull of a simple polyline

Polyline2D.convex_hull() uses Melkman's O(n) algorithm. The polyline must be simple — call is_simple() first.

import geompp as g

# Simple concave path: outer corners with an inner dip at (2,1)
path = g.Polyline2D.make([
    g.Point2D(0, 0), g.Point2D(4, 0), g.Point2D(4, 4),
    g.Point2D(2, 1), g.Point2D(0, 4),
])

if path.is_simple():
    hull = path.convex_hull()   # Polygon2D with 4 vertices
    print(f"hull has {hull.size()} vertices")
# hull has 4 vertices

Project details


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.10.1.tar.gz (36.3 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.10.1-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

geompp-0.10.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.9 MB view details)

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

geompp-0.10.1-cp311-cp311-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.11Windows x86-64

geompp-0.10.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.7 MB view details)

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

geompp-0.10.1-cp310-cp310-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.10Windows x86-64

geompp-0.10.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.6 MB view details)

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

geompp-0.10.1-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9Windows x86-64

geompp-0.10.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.4 MB view details)

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

geompp-0.10.1-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8Windows x86-64

geompp-0.10.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.2 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.10.1.tar.gz.

File metadata

  • Download URL: geompp-0.10.1.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geompp-0.10.1.tar.gz
Algorithm Hash digest
SHA256 0128c2ed4bab60e0516b8872204aec7aab5cd494dff9442d9e65f3270daa1843
MD5 83ecd199e38e1e3c6e0450ce51134fcb
BLAKE2b-256 ab15ae70ef55e867732c8d069399a2f744b3d991d1b0f5015fdb59dac46f814e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.10.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geompp-0.10.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ba0cea36df92227205c11b13b35e136ad9c906776cebf92b663abe63d0681326
MD5 7124e9a8ed8193d6a0b5b9ee4d8f9b24
BLAKE2b-256 6e8d3418c806409879b157f4fb91e854ece9b82a86f200bf00d534d830233751

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.10.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05e2bc826ae5cc4b26f5b755132c67ec82a98d2fbe63083e14a08497d70c7ecd
MD5 2f40123d0693290be80bc1242274c5cc
BLAKE2b-256 b7f3894fcdecdfd0243890712d59578ac18a529344ab20b4d9f5bc364ebdaf2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.10.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geompp-0.10.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 44b184306b7bf081cdae4522bed926aa0dd9c5d61a6c340de51236ef6f072dad
MD5 8b7302fdfbad303932b76269879e3679
BLAKE2b-256 cda0331bd8ed9eec4afe4d5520d5de7fb8dab5766453ed7abf89634ad4a94868

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.10.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 20aad888ba4ea3a438bd1aa91bcb33698bbe7a4d82ab2c46e6608c1566fb5e33
MD5 aa91779f4ff0413095eb481edd9fb3c8
BLAKE2b-256 82ea28d8a4fd3b3d767e594356fecbf5a3cab78a0389bb9e33ae01031afcaaf6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.10.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geompp-0.10.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 586cef9596d6338257bb40da0e53f4936795e8d0a4cabd06782e70f3946e1452
MD5 e73b4a23d36d52db337102f3e2021abc
BLAKE2b-256 23660dae47524c5c9d0095258ae346fc7226855ebccb82c21ec49afa28aad000

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.10.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 34136037f94d8857d5d2b63ef49a40c732951059a861f85917fdaf73f30355ce
MD5 33cab685762e64284513b4db9b4c9916
BLAKE2b-256 fea3ecf02316d82eea7b141216f3e07811c730731967a5afc07ff3cf214da3d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.10.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geompp-0.10.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 70f676e7893d712cd845d0b94ff135b21d348ab5d6eb7c40df2e7bf82ca21df3
MD5 d068bedfdfb373693392c700d0128563
BLAKE2b-256 87cd3aa129c6ab3c8567de0c1c3fc4e60af54cfde90597f56face2b35f86a662

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.10.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5d7787915095dd56a166f28b7c09ded6e1a3b47338ce063b3f3042afb945c2be
MD5 50c9c8d117c6f14ada35c97dcd96ced3
BLAKE2b-256 6d370e6ec47380bd1d018b3436fa76350c04fc93f3fc01c9cf5b8b258d5a968d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.10.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geompp-0.10.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 de161328d3cfadf587d26e478c4a9a63906c4a4d1e733e2af131755034bbf0de
MD5 71f43c9c8a5705ffdd94b14c367f6260
BLAKE2b-256 6580d63b6be3ce75234835a0f36da56c948c275f01e6b81bf350ebcefeee652b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.10.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 36c8cd481ed075c3add389514d8fae8fe6067768d79e181e854d1fe0bc58b382
MD5 f2f99adba6a3650d762c125d63577710
BLAKE2b-256 8ce34a1f01873fec9a27cc24a48b8ea1ec211710e35b6d7ab060b62775db7921

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 Pingdom Monitoring Sentry Error logging StatusPage Status page