Pretty much as the question asks. Answers preferably in pseudo code and referenced. The correct answer should value speed over simplicity.
See Intersections of Rays, Segments, Planes and Triangles in 3D. You can find ways to triangulate polygons.
If you really need ray/polygon intersection, it's on 16.9 of Real-Time Rendering (13.8 for 2nd ed).
We first compute the intersection between the ray and [the plane of the ploygon]
pie_p
, which is easily done by replacingx
by the ray.
n_p DOT (o + td) + d_p = 0 <=> t = (-d_p - n_p DOT o) / (n_p DOT d)
If the denominator
|n_p DOT d| < epsilon
, whereepsilon
is very small number, then the ray is considered parallel to the polygon plane and no intersection occurs. Otherwise, the intersection point,p
, of the ray and the polygon plane is computed:p = o + td
. Thereafter, the problem of deciding whetherp
is inside the polygon is reduced from three to two dimentions...
See the book for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With