Skip to content

feat: add convex polygon intersect + contained predicates - #5

Merged
Mr-tooth merged 1 commit into
mainfrom
feature/polygon-predicate
Mar 17, 2026
Merged

feat: add convex polygon intersect + contained predicates#5
Mr-tooth merged 1 commit into
mainfrom
feature/polygon-predicate

Conversation

@Mr-tooth

Copy link
Copy Markdown
Member

Changes

  • HeuclidPolygonTools: +2 new APIs
    • isConvexPolygonIntersect(polyA, polyB) — detect any overlap between two convex polygons
    • isConvexPolygonContained(polyA, polyB) — check if polyA ⊆ polyB
  • TestPolygonPredicate.cpp: 16 GTest test cases
    • 7 containment tests (inside, outside, partial, rotated, boundary)
    • 9 intersection tests (overlap, disjoint, contained, shared edge, corner, empty, rotated)

Motivation

Generic convex polygon predicates needed for:

  1. Footstep planner obstacle avoidance (foot ∩ obstacle = ∅ → !isConvexPolygonIntersect)
  2. Footstep planner terrain validation (foot ⊆ terrain → isConvexPolygonContained)
  3. Any future project needing polygon-polygon relationship tests

Test Results

[==========] Running 16 tests from 2 test suites.
[  PASSED  ] 16 tests.

Existing tests (TestConvexHull2D, TestBeizer) still pass.

Version

This will be tagged as v2.2 after merge.

Add two new geometric predicates to HeuclidPolygonTools:
- isConvexPolygonIntersect(A, B): detect any overlap between two
  convex polygons (mutual vertex + edge-midpoint containment tests)
- isConvexPolygonContained(A, B): check if all vertices of A are
  inside B (used for terrain footstep placement validation)

16 GTest test cases covering:
- Small/large rectangle containment (inside, outside, partial)
- Vertex on boundary, rotated polygons (diamond shapes)
- Overlapping, disjoint, shared edge, corner touching
- Empty polygon edge cases

These are generic convex polygon operations — not tied to any
specific robotics application — making them reusable for footstep
planning, collision detection, and spatial queries.

Part of the obstacle avoidance + stair climbing demo work.
@Mr-tooth
Mr-tooth merged commit 6401907 into main Mar 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant