Conditions for which axis aligned cuboid and capsule intersect

246 Views Asked by At

Say I have a cuboid in $\mathbb R^3$ space whose axes are aligned with the axes of the coordinates system (also called an axis aligned bounding box). The cuboid is defined by it's minimum coordinate $A$ (the vertex with the lowest values in all coordinates) and it's maximum coordinate $B$. And a capsule defined by a segment with end points $a$ and $b$, and radius $r$.

The two shapes intersect if the capsule's defining segment intersects the cuboid. However if the segment and the cuboid do not intersect, what is the condition for which the two shapes can still intersect?

1

There are 1 best solutions below

5
On

Hint:

You can reason in terms of Minkowski sums.

If you dilate the cube with a sphere of radius $r$ and at the same time erode the capsule, you transform the problem to the intersection of a rounded cube with a line segment. The rounded cube can be described as the union of three orthogonal prisms, twelve cylinders and eight spheres.

You can process the intersection of the segment and these shapes independently. First consider the intersections of the line of support of the segment. The intersection with the prisms amounts to intersections with planes. Intersection with a sphere depends on the distance of the line to the center of the sphere and intersection with the cylinders depends on the shortest distance to the axis.

If the distance criteria pass, you still need to compute the intersection points with the surfaces and check if they belong to the useful patches. As all surfaces are at most quadrics, you'll have to solve quadratic equations.