Python bindings for geompp — a C++ 2D/3D geometry library
Project description
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[IntersectionEvent2D] — every crossing point with the ids of all segments through it |
IntersectionEvent2D
hits = geompp.find_intersections(segments)
for ev in hits:
print(ev.point) # Point2D — the crossing location
print(ev.segment_id1) # int — index of first segment
print(ev.segment_id2) # int — index of second segment
print(ev.segment_ids) # list[int] — all segment indices (≥ 2; more when 3+ meet at one point)
Project details
Release history Release notifications | RSS feed
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.9.0.tar.gz.
File metadata
- Download URL: geompp-0.9.0.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce09570ae349d10b66b7de57a590d641c40c2904c21ffa51e77211daa23809f2
|
|
| MD5 |
a77df24db3b6953400b08e3646c08ec9
|
|
| BLAKE2b-256 |
c38c3901998af7d0fd68c3b92ffdc0eaf0667d4eb9e2eef6d20fd1f7d8e0f4ed
|
File details
Details for the file geompp-0.9.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: geompp-0.9.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a9c220de8e97490eb78aa095ce109c8db88985d90616becf4788311a15e172e
|
|
| MD5 |
0ca3e029c1bd8a6a46399c234f39360c
|
|
| BLAKE2b-256 |
bf5fef62100ccc4781b2059c7c06a31040339f96f5e9a0e8b25a5b03b8fc222a
|
File details
Details for the file geompp-0.9.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.9.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.9 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/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bbf59ff062a63f8a1ed4b5d14491005b1f56786851663e1e140183ca3e0709d
|
|
| MD5 |
26a54125d3d3011a380153036a86252c
|
|
| BLAKE2b-256 |
9c49d728256f0b4281b108925f8780e22191099aaa972b1b76b8ac134c3d626d
|
File details
Details for the file geompp-0.9.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: geompp-0.9.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70262b959ea95de240c7b31b26efd505013a63f6eb98ea7696fab915faa5e80e
|
|
| MD5 |
b2ef646c552265185e3efe8c4311b1ce
|
|
| BLAKE2b-256 |
466a24d03121902bfed80621ac809d89cef91cadcaf136bb2281a612c1cf4164
|
File details
Details for the file geompp-0.9.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.9.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.7 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/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bba22f4d1654eed8731acd742788a24157275353ed44703531719c29294f4db6
|
|
| MD5 |
f0388b329951e3d6dbe4f0383084ebab
|
|
| BLAKE2b-256 |
4dfc2b9426d3fc142428b3bb4ef2b3346dc051f52941f11453edfff0fa7222e8
|
File details
Details for the file geompp-0.9.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: geompp-0.9.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 2.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acd996d5e7b41eeb44684a8c6c4fd9fde738f43e5da75834e91eda55b5841dab
|
|
| MD5 |
f874cf3453b9ebfd582d0baab19ae9a9
|
|
| BLAKE2b-256 |
20c0cc0556703d76e6df3b7f3bc1003888413175ba6831da6c3480412d14f617
|
File details
Details for the file geompp-0.9.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.9.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 3.5 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/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa8cf82a5886d2b8398f4449d3a5ab0ffcbb3ce92546f4896ce0e6b0421501ef
|
|
| MD5 |
ecc9457d051c31a45c0e0112b7aafd8e
|
|
| BLAKE2b-256 |
c2b9ff9134b1cecd733438d8998a3b6572368b306cddd00401eac0431fb148d8
|
File details
Details for the file geompp-0.9.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: geompp-0.9.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92896d62fe31d297037d5d8bc0a717452bd1c39da95941aea26f77a4b99baf88
|
|
| MD5 |
8f8858c8ae606f29b7490264f63227aa
|
|
| BLAKE2b-256 |
76173e70a7290fa03da5fe82b8f3e0ffcb66f916d9f65681bfaf4d0041e39fb5
|
File details
Details for the file geompp-0.9.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.9.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.4 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/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
177a68afeccc42c0c0ba6f17084c5d9d7832e3338a4191ea32d2617ce479952a
|
|
| MD5 |
ddd6cc6441e62364f71319a9f47a4b94
|
|
| BLAKE2b-256 |
abccb586656c58980ed42b6941bd1db197ca7bc5aea7965ca63aefcb7eeb77da
|
File details
Details for the file geompp-0.9.0-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: geompp-0.9.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ebea313fa77668d4bf4c84f8c319ce8177076fd005668e54a6a722bb2bfbb05
|
|
| MD5 |
f608db95954c901eaef0163c1d5a2b04
|
|
| BLAKE2b-256 |
2e5b6314b3dcffec791a239b2e07ca363b173e959c1557976deb203d9114aca8
|
File details
Details for the file geompp-0.9.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: geompp-0.9.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.2 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/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f557f1cb238a9fdb984b61eee327d01f9abec5cdd373f0e23676e4831439a5de
|
|
| MD5 |
30ab6f54bf00f4f256ff039473a34134
|
|
| BLAKE2b-256 |
52b2d8dc9805d057047a053c681925d9de36e32da162222e53fec811d3ef9c8f
|