In computational geometry, the intersection of a polyhedron with a line is the problem of computing the intersection of a convex polyhedron and a ray in Euclidean space. This problem has important applications in computer graphics, optimization, and even in some Monte Carlo methods.
Statement of the problem
In general, a convex polyhedron is defined as the intersection of a finite number of halfspaces. That is, a convex polyhedron is the set of solutions of a system of inequations of the form

The formal statement of our problem is to find the intersection of the set
with the line defined by
, where
and
.
General solution
To this end, we would like to find
such that
, which is equivalent to finding a
such that
![{\displaystyle [Av]_{i}t\leq [b-Ac]_{i}}](/media/api/rest_v1/media/math/render/svg/bc361d448bbf6c373cdec6ed82d5f85f77ad398f)
for
.
Thus, we can bound
as follows:
![{\displaystyle t\leq {\frac {[b-Ac]_{i}}{[Av]_{i}}}\;\;\;{\rm {if}}\;[Av]_{i}>0}](/media/api/rest_v1/media/math/render/svg/7c8ce4044e60cfdc5e3f56501bed4d0e4d5c93e3)
![{\displaystyle t\geq {\frac {[b-Ac]_{i}}{[Av]_{i}}}\;\;\;{\rm {if}}\;[Av]_{i}<0}](/media/api/rest_v1/media/math/render/svg/1145c78e7263b43fdb16ce0923a232fd6f615e38)
![{\displaystyle t{\rm {\;unbounded}}\;\;\;{\rm {if}}\;[Av]_{i}=0,[b-Ac]_{i}>0}](/media/api/rest_v1/media/math/render/svg/a11436d57ebdd0f2981e1fc48d3d79d02c3636cd)
![{\displaystyle t{\rm {\;infeasible}}\;\;\;{\rm {if}}\;[Av]_{i}=0,[b-Ac]_{i}<0}](/media/api/rest_v1/media/math/render/svg/e092a045919c044c01833c84c342ba3744b0a81b)
The last two lines follow from the cases when the direction vector
is parallel to the halfplane defined by the
row of
:
. In the second to last case, the point
is on the inside of the halfspace; in the last case, the point
is on the outside of the halfspace, and so
will always be infeasible.
As such, we can find
as all points in the region (so long as we do not have the fourth case from above)
![{\displaystyle \left[\max _{i:[Av]_{i}\leq 0}{\frac {[b-Ac]_{i}}{[Av]_{i}}},\min _{i:[Av]_{i}\geq 0}{\frac {[b-Ac]_{i}}{[Av]_{i}}}\right],}](/media/api/rest_v1/media/math/render/svg/e28cab65b42a3ba862c64b89a1bb97bef6fe641f)
which will be empty if there is no intersection.
External links