Expand description
Computational geometry: primitives, intersection, distance, convex hull, triangulation, polygon operations, GJK/EPA collision detection.
Structs§
- Aabb2
- 2D axis-aligned bounding box.
- Aabb3
- 3D axis-aligned bounding box.
- Capsule
- Capsule: cylinder with hemispherical caps.
- Circle
- Circle in 2D.
- Obb3
- Oriented bounding box.
- Plane
- Plane: normal·x + d = 0. Normal should be unit length.
- Point2
- 2D point / vector.
- Point3
- 3D point / vector.
- Ray2
- 2D ray.
- Ray3
- 3D ray.
- Segment2
- 2D line segment.
- Sphere
- Sphere in 3D.
- Triangle2
- 2D triangle.
- Triangle3
- 3D triangle.
Enums§
- Halfspace
- Result of a halfspace test for AABB vs plane.
Functions§
- aabb_
aabb - AABB vs AABB overlap test.
- aabb_
plane - AABB vs plane halfspace classification.
- capsule_
capsule - Capsule vs capsule overlap.
- convex_
hull_ 2d - 2D convex hull via Jarvis march (gift wrapping).
- convex_
hull_ 3d - 3D convex hull via incremental Quickhull. Returns triangle face indices.
- convex_
polygon_ area - Area of a convex polygon.
- delaunay_
2d - Bowyer-Watson Delaunay triangulation in 2D. Returns triangle index triples.
- ear_
clipping - Ear clipping triangulation for simple (non-self-intersecting) polygons. Returns triangle indices.
- epa
- EPA (Expanding Polytope Algorithm) — finds penetration depth and normal.
- gjk
- GJK distance test — returns true if shapes overlap.
- gjk_
closest - GJK closest points between two shapes. Returns (point_on_a, point_on_b, distance) or None if overlapping.
- minkowski_
sum - Minkowski sum of two convex polygons (CCW winding assumed).
- obb_obb
- OBB vs OBB — Separating Axis Theorem.
- point_
in_ aabb - Point inside AABB.
- point_
in_ convex_ polygon - Point in convex polygon (hull assumed CCW).
- point_
in_ obb - Point inside OBB.
- point_
in_ triangle - Point in 2D triangle test.
- point_
to_ aabb - Distance from point to AABB (0 if inside).
- point_
to_ plane - Signed distance from point to plane.
- point_
to_ segment - Closest point on a 3D segment to point p (treating segment as 3D using z=0 for Point2).
- point_
to_ triangle - Distance from point to triangle in 3D.
- polygon_
area - Signed polygon area via Shoelace formula.
- polygon_
centroid - Polygon centroid.
- polygon_
is_ convex - Test if polygon is convex.
- polygon_
winding - Winding number of polygon. Positive = CCW.
- ray_
aabb - Ray vs AABB — returns t of first positive intersection or None.
- ray_
capsule - Ray vs capsule.
- ray_obb
- Ray vs oriented bounding box.
- ray_
plane - Ray vs plane.
- ray_
sphere - Ray vs sphere.
- ray_
triangle - Ray vs triangle using Möller–Trumbore algorithm. Returns (t, u, v) — barycentric coords (w = 1 - u - v).
- segment_
segment_ 2d - 2D segment-segment intersection. Returns intersection point or None.
- segment_
to_ segment - 2D segment-to-segment distance (embedding in 3D).
- sphere_
aabb - Sphere vs AABB overlap.
- sphere_
sphere - Sphere vs sphere overlap.
- sphere_
to_ aabb - Distance from sphere to AABB surface. Negative means overlap.
- sutherland_
hodgman - Sutherland-Hodgman polygon clipping.
- voronoi_
2d - Compute approximate Voronoi diagram from Delaunay triangulation dual. Returns one polygon (as point list) per input point.