开发者

3D Box Circle intersection

I've got a circle defined by a center (x,y,z), a radius and an orientation vector that specifies which way the circle is facing. I need to test whether such a circle intersects with an axis-aligned bounding box. To clarify, by intersects, I mean if any points within the area described by the circle are within the bounding box, then that constitutes an "intersection."

This is not for a game and I'd rather not approximate the circle in some way. It should be OK though开发者_开发技巧 to treat the circle as cylinder with a very small height if that makes this any more tractable.

thanks.

Nick


Your circle center point and your vector define a plane; intersect your plane with your box (specifically 6 planes that make up your box); that will give you a set of line segments. Using the point-line nearest point algorithm, determine the nearest point on each line segments to your center point; if the square of the distance (use the square distance for distance comparison, it's faster and just as accurate) between that point and your circle center point is less than the square of your radius, your box intersects with your circle.

Note: this process is generic; use of axis-aligned bounding boxes makes everything even easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜