Rectangle<->Frustum Intersection test?

Started by
4 comments, last by lordikon 12 years, 9 months ago
I'm basically just trying to check if a flat quad rectangle lies within the view frustum or not. The rectangle is not axis-aligned, it can have any scale or transform (position, rotation). The current frustum information I have is just the 6 planes that make up the frustum, although if I truly need I could probably calculate the 8 corners of the frustum.

I searched all over google and most of the results seem to be plane checks rather than rectangles.

EDIT: I think I might have it. Let me know if this sounds like it would work:

Check each point on the rectangle against the frustum. If any point is in the frustum then it's in view. If no points are within the frustum check if any edge of the rectangle intersects any of the frustum planes. If any edges intersect a frustum plane then it's in view.

I think this will work, and I already have the algorithms for checking points against the frustum, so I should be able to use that algorithm and the fact that all the points are outside of the frustum to handle either case.
Advertisement
If the rectangle is bigger than the frustum, you'll have problems as not only will no points be inside, but no lines will pass through since it's larger in all respects. If the rectangle-line check fails, try checking the frustum's lines for intersection with the rectangle.
If you only check for those factors you will completely miss any quad that is larger than the frustum. A common way is to test if all points are on the same side of a single frustum plane. You will get false positives in some cases, but that's usually better than the other way around. If you want perfect results, you will probably end up checking for intersection in both ways. Don't just see if the polygon points/edges intersect the frustum, but also if the frustum edges intersect the polygon.

Edit: I really need to stop taking so much time when writing answers.
f@dzhttp://festini.device-zero.de
There would have to be a huge speed bonus in calculation and not much speed increase in culling (if that's what this is for) to use your first method. That's a lot of false positives :lol: In fact, wouldn't there always be a plane in the frustum with the points on the same side?
There would have to be a huge speed bonus in calculation and not much speed increase in culling (if that's what this is for) to use your first method. That's a lot of false positives :lol:

There would have to be a huge speed bonus in calculation and not much speed increase in culling (if that's what this is for) to use your first method. That's a lot of false positives :lol: In fact, wouldn't there always be a plane in the frustum with the points on the same side?


You're right. Replace "same side" of a plane with "outside" of a single plane, ie. all points are left/right/above/below/behind/beyond the frustum.
f@dzhttp://festini.device-zero.de
Good stuff guys, thanks. I do believe that checking if all four points of the rectangle are on the outside of any of the planes then that will mean it's not colliding. Thanks!

This topic is closed to new replies.

Advertisement