3
\$\begingroup\$

I have a given infinite camera frustum defined by four planes, each defined by a normal (left, right, bottom, top). From those planes we can also easily get the camera position and the view direction. Further, I have an infinite cone specified by its apex, a direction vector, and the inner angle. I need to check whether those two intersect.

enter image description here

(Geogebra. The image and Geogebra playground use an infinite cone in both directions, but this question is about a cone only in one direction!)

There are some trivial special cases. The apex being inside the frustum, or the camera being inside the cone, are both easy to test for and result in the answer true. Also, if the view direction and cone direction are sufficiently aligned, they will also necessarily intersect at some point, even if camera pos and apex are far apart. Else, if the apex is "behind" the camera (dot(apex - camera_pos, view_dir) < 0) and if the cone points in a completely different direction (dot(view_dir, cone_dir) < 0), then there is no intersection.

But I can't come up with a general solution. It's tricky because an intersection between both does not imply any of this:

  • Any of the four plane-intersection-lines intersect the cone.
  • The axis of the cone intersects the frustum.
  • The cone and view dir pointing in roughly the same direction.

Simply checking whether the cone intersects any individual plane is also not sufficient as that would have many false positives.

I tried the approach of intersecting the cone with one plane first, finding the intersection point that's closest to ... something, such that I can simply test that intersection point against all other planes. But that hasn't lead anywhere yet.

I also got another idea: I think there are only three intersection cases: (a) cone axis intersects frustum, or (b) any frustum edge intersects the cone, or (c) the angle between cone axis and any frustum plane is smaller than the cone's inner angle. Is that correct?

I also appreciate useful approximations in answers!

\$\endgroup\$
2
  • \$\begingroup\$ My math skills aren't strong enough to know the matrix math for this but I suspect there is a transformation matrix that exists to turn either the cone or the frustum into something with parallel boundaries (either rectangular prism or a cylinder, it is a non-affine transform) so that you can test if the other shape ever enters that region. Since one of these shapes would have a constant cross-section in that new space it makes the test a little easier to work out? \$\endgroup\$
    – Romen
    Oct 2 at 21:29
  • \$\begingroup\$ The frustum could also be bounded by a cone too, so then you could first check if two infinite cones intersect and if they don't you know the frustum doesn't either. \$\endgroup\$
    – Romen
    Oct 2 at 21:34

0

You must log in to answer this question.

Browse other questions tagged .