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

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.8.0.tar.gz (32.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.8.0-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

geompp-0.8.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.7 MB view details)

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

geompp-0.8.0-cp311-cp311-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.11Windows x86-64

geompp-0.8.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

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

geompp-0.8.0-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

geompp-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.4 MB view details)

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

geompp-0.8.0-cp39-cp39-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9Windows x86-64

geompp-0.8.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.3 MB view details)

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

geompp-0.8.0-cp38-cp38-win_amd64.whl (790.8 kB view details)

Uploaded CPython 3.8Windows x86-64

geompp-0.8.0-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.8.0.tar.gz.

File metadata

  • Download URL: geompp-0.8.0.tar.gz
  • Upload date:
  • Size: 32.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.8.0.tar.gz
Algorithm Hash digest
SHA256 c574d4e85af0ca3f7063757f54c729070e965c32b5a8a609a136e6d391d8f29a
MD5 8ac4e2e4208998c99600f9f357a542c2
BLAKE2b-256 83553f5386d3b6e1188879b10b6f5586bb6d2d8b90c8ee83b217d37a37287897

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.8.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.9 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.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a2d6b5d02a38346ff49fc606a5162da0b3eecf4f2e1077fcdec3886d27d50425
MD5 f5b1d6861b10038b48fafcdf3e5c2eaa
BLAKE2b-256 3b48c46d3962300b5aaa5da8e0c8a851743ea48fee3a95aae50196bc1f3c40f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.8.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90eb1cab4313fc0b1b4054998759d442b330d1345dd37623ea703df7c042830b
MD5 39aae52abd2566197264a72c7592ba4b
BLAKE2b-256 dbb0444b8157952f0e0792a185ada8fa4731885df36f5448ee47817408df9e0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.8.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.4 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.8.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e8a57a147fb84378b00625968dfab81c7058d6cdca06d6bb767d473690af8e71
MD5 0c9ba366253e57f26e05ad04177a382e
BLAKE2b-256 e10d04ec894c592c75a02e2b8cc350fa95ddccc79f17eb091d6aa1dc9c2b429f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.8.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 391065f1b1affc1988ae9852d59e40ddef67b928a70f06eb510356c0d5b874c2
MD5 c82d799db3c6d9dfb6fd07c02b685f06
BLAKE2b-256 dac35db199c721245cb13d8fa787a2068f82e19f5c01ed961b9f42731355eb28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.8.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.9 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.8.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 112517fa94ac3ce7127d9ec119c96014cffbba63979775efc4709a9643333c9d
MD5 0a6ca7ab70b107586f407033691dd700
BLAKE2b-256 3362c033d2d981bffa4781b9b8218edd48241bf936dc1ba9176d0679c8696630

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 01c0641cc8baa564c34c9902824888440cb9093e165d2ef901c4d2d68966f1a4
MD5 6fcad5858d24a2eec56319f22569f5aa
BLAKE2b-256 c108b267ca6cc9a1174147919b75da16fc845dec551aac9707374e897d6cb321

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.8.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.4 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.8.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a0ddfd5d268dcb663d6b8d662a4d777764daa673f8e3d8ddf7fd8599a26e3b17
MD5 61fc30f465daccf37129fa98975e15ad
BLAKE2b-256 a7736ee32e044ad517180afb0a398283e4f0696893cc7dc36934a7a6bf09b886

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.8.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a78d8aad432d0e99675731c2ad9d9aa44f26c719d7a7a3a38baad0cc1846808f
MD5 864d72a6ba319d4986424a0ba47c4b65
BLAKE2b-256 08d851bc2ad6feb32fef5464242d32f567ef16a6ba03540ec6ce6c0f4c9cbef9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geompp-0.8.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 790.8 kB
  • 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.8.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b26a6a116ea345c06015357fd9c8a39e96f4549d13fcd1004c36339804058177
MD5 27c8e09d5f4592fd8c6587500f3e7aee
BLAKE2b-256 cd2f1379f849ba5aabbdf2905c58bca523c96aaac9af0f8d569205ebd06b775e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geompp-0.8.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6984fa614af985da62ef87fb923ad179a46b658488110d18f2a22643e4c5748f
MD5 f56817c48c11e1d664ed75ac97b3532c
BLAKE2b-256 e4fd5cf75ea465adea1ada32bf441fca3ddd05d5d69fce95700b288aa4f7f164

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