Intersection of a polyhedron with a line
From Wikipedia, the free encyclopedia
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 an system of inequations of the form
There are many problems in which it is useful to find the intersection of a ray and a convex polyhedron; for example, in computer graphics, optimization, and even in some Monte Carlo methods. The formal statement of our problem is to find the intersection of the set with the line defined by c + tv, where and .
To this end, we would like to find t such that , which is equivalent to finding a t such that
for .
Thus, we can bound t as follows:
The last two lines follow from the cases when the direction vector v is parallel to the halfplane defined by the ith row of A: . In the second to last case, the point c is on the inside of the halfspace; in the last case, the point c is on the outside of the halfspace, and so t will always be infeasible.
As such, we can find t as all points in the region (so long as we do not have the fourth case from above)
which will be empty if there is no intersection.