Search code examples
matlabgeometrycomputational-geometryperspectivecamera

Checking if a Plane intersects a Pyramid


I have a camera frustum modeled by a pyramid. I have all the vertices, edges, and planes for this pyramid.

I then have a room with 6 walls modeled with planes. For these planes, I have the normal vector, center position, Length, and Width.

I am trying to figure out a way to check if the plane intersects the pyramid. Computational complexity matters to me for this problem, so I have tried some various things to narrow down the number of possible planes:

  1. if distance from camera to plane is larger than camera's range, then ignore;
  2. for each of the four vectors that point away from the pinhole of the camera, if the dot product of the vector with the plane's normal vector < 0, then I know that the camera is pointing at least a little bit in the direction of the plane (e.g. a -1 would mean the camera is pointing directly at the wall, a value of 0 would be perpendicular to the wall, a value of 1 would be that the camera is pointing directly away from the wall in the normal direction).

Does anyone have any suggestions on how to check if a plane is within the frustrum?

Thanks


Solution

  • Let the implicit equation of the plane be Ax+By+Cz+d=0.

    When you plug the coordinates of the five vertices of the pyramid into that equation, the plane intersects the pyramid if not all signs are the same.