Reputation: 63
I'm trying to figure out an approach for checking whether or not axis aligned bounding boxes (AABBs) intersect with a pyramidal beam. Is there a known algorithm for this? Does anyone have an idea how this may be approached?
The pyramidal beams I'm talking about are essentially rays with increasing thickness - they can be thought of as infinite pyramidal volumes being shot into a 3D scene. Below is a 2D schematic of what I want to achieve.
Beams are defined by the following data:
I use the unit-width and -height approach instead of angles, because angles run into floating point rounding errors when the beams become narrow enough. The width or height of a beam at a certain distance from the origin can be calculated with the formulas:
width = unit_width * distance
height = unit_height * distance
AABBs are defined by either:
or:
I'll pick the representation that is more beneficial to the intersection algorithm. All I need is a boolean value signalling whether or not the beam intersects a specific AABB - no intersection points are necessary. Can anyone share some insights into how this may be approached efficiently?
Upvotes: 0
Views: 55
Reputation: 41454
Both of your objects are convex polyhedra (your "pyramidal beam" is an unbounded convex polyhedron) so a separating-axis test will work. Basically, you see whether the beam is entirely above one of the AABB's face planes, whether the AABB is entirely above one of the beam's face planes, or whether the cross product of an edge direction from each (note that the AABB has only three distinct edge directions) yields an axis where the projections of the two shapes onto the axis are disjoint. If none of these tests yields an axis of separation, the two shapes intersect.
That's 6+4+3*4=22 axes to check. If it were a lot more, you'd want to use something like GJK to reduce the number of tests, but I don't think it's worthwhile here.
Upvotes: 0