Math Question... Box on Plane penetration

Ok I got a quick question that someone might have a good idea how to resolve.

I have a box of known (and unequal) dimensions and a non centralized origin that can be rotated in any orientation. Then a plane with a known normal. When placing the box’s origin on the plane and keeping the boxes original orientation how can I determine the amount that the box extends behind the planes surface.

My first thoughts were to take all 8 corner points and project them onto the plane to get distances then do a dot product of the difference between those two points to the planes normal to determine if its in front or behind. But there might be a better way!

Answer this time from :slight_smile:

The method you described using vector projection and dot product is indeed a valid way to determine how much the box extends behind the plane. However, I can suggest another approach using the concept of a separating axis.

  1. Separating Axis Theorem: This theorem states that two convex shapes do not overlap if and only if there exists an axis (a line) onto which the two shapes’ projections do not overlap.

  2. Finding the Separating Axis: In your case, you can use the plane’s normal as the separating axis.

  3. Projecting the Box onto the Axis: Project the box’s vertices onto the separating axis (the plane’s normal) to obtain the intervals of the box’s projection on that axis.

  4. Calculating the Overlap Between the Projections: If the intervals of the box’s projection do not overlap with the plane (the plane’s projection is a single point), then there’s no intersection between the box and the plane. If they do overlap, the box intersects the plane.

  5. Measuring the Box’s Extension Behind the Plane: To find the amount the box extends behind the plane, subtract the projection of the box’s origin onto the separating axis from the closest point of the box’s projection interval that lies behind the plane’s projection.

This approach can be more efficient, as it requires projecting the vertices only once onto the plane’s normal and then comparing the projections rather than performing multiple dot product calculations.

Perfect that is pretty much what I was picturing! Spooky that came from AI.