Skip to content

feat: Convex Polytope Obstacles#90

Open
zkingston wants to merge 10 commits intoKavrakiLab:mainfrom
CoMMALab:polytopes
Open

feat: Convex Polytope Obstacles#90
zkingston wants to merge 10 commits intoKavrakiLab:mainfrom
CoMMALab:polytopes

Conversation

@zkingston
Copy link
Collaborator

Adds basic polytope obstacle avoidance with OBB broadphase and then checking separation with halfspaces (no GJK yet...). Adds a CPM dependency on cddlib to compute convex hulls and convert between vertex/halfspace representations.

2026-02-12.12-09-36.mov

@zkingston zkingston requested a review from claytonwramsey March 9, 2026 20:43
Copy link
Member

@claytonwramsey claytonwramsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly confused on how the collision-checking kernel works but everything else looks OK

auto dist = dot_3(p.nx[i], p.ny[i], p.nz[i], cx, cy, cz) - p.d[i] - r;
max_dist = max_dist.max(dist);

if (max_dist.test_zero())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why this test_zero is here -- it seems unlikely for a sphere to be perfectly tangent to the plane?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above - checking if all distances from planes is above zero.

for (auto i = 0U; i < p.num_planes; ++i)
{
// dist = n.C - d - r (positive = separated)
auto dist = dot_3(p.nx[i], p.ny[i], p.nz[i], cx, cy, cz) - p.d[i] - r;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, this means that we compute max_dist as the maximum projected distance to any surface plane of the polytope. I think that would yield incorrect results when the nearest point on the polytope to the sphere is a vertex, rather than on one of the planes.

I think the correct algorithm would be to iteratively project the center $c^{(i)}$ onto successive half-spaces, yielding new center $c^{(i + 1)}$, then terminate as soon as $|c^{(0)} - c^{(i)}| &gt; r$.

Did I miss something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a completely correct approach would be something iterative as you describe, but I didn't have the time to think about how to do this properly in SIMD. Instead I did a conservative approach which does "fail" near the vertices as you say. I'm checking for the separation of the sphere with any of the halfspaces defining the polytope, if the sphere is separated by any of them (i.e., the distance is positive) we aren't in collision with the polytope. This is also what the test_zero check is for, it's the poorly named "check if first bit is zero" function to see if all spheres have a maximum distance that is positive.

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.

2 participants