When perform the same edge test point
larger than zero) then the point is in front of the plane. As soon as this happens for any edge we know the point is not contained inside the polygon and we can exit.
Figure 12.23 demonstrates testing to see if
|
---|
|
---|
|
---|
|
---|
|
---|
Most often in 3D graphics we are dealing with triangles and not with N-gons. The point in polygon test can be optimized somewhat when being used specifically for “Point in Triangle” tests because we can unwind the loop and lose a bit of overhead. The following snippet of code shows how we might write a function called PointInTriangle whose code could also be substituted into the function shown above to create a RayIntersectTriangle method.