3D box circle intersection

I have a circle defined by the center (x, y, z), the radius and the orientation vector, which determines which circle it is drawn with. I need to check if such a circle intersects with an axis-aligned bounding box. To clarify, by intersections, I mean, if any points within the region described by the circle are in the bounding box, then this means "intersection".

This is not for the game, and I would prefer in no way to bring the circle closer. This should be good, although considering the circle as a cylinder with a very small height, if that makes it more convenient.

thanks.

Nick

+4
source share
1 answer

Your center point of the circle and your vector define the plane; cross your plane with the field (in particular, 6 planes that make up your box); which will give you a set of line segments. Using the algorithm of the nearest point of a dotted line, determine the nearest point on each segment of the line to your center point; if the square of the distance (use the square distance to compare the distance, it is faster and exactly the same) between this point and the point of your circle is less than the square of your radius, your box intersects with your circle.

Note: this process is general; Using axis-aligned bounding boxes makes it even easier.

+1
source

All Articles