The relative orientation criterion tests a point against each directed side of a triangle. A 2D cross product gives a signed area: consistent signs place the point on the same side of all three edges, while a differing sign places it outside. section 9.3.3
To test a point:
- Form the three edge vectors from the triangle’s ordered vertices. section 9.3.3
- Compute the signed cross product between each edge and the vector to the point. section 9.3.3
- Accept the point when all three results have the required consistent sign for the vertex orientation. section 9.3.3
Efficient point-in-triangle test
For clockwise vertices, compare each cross-product expression with zero and require all three to be positive. The implementation uses subtractions and multiplications only; division by two is unnecessary because only relative areas matter. section 9.3.3
Figure 9.17 If points of the triangle are clockwise-oriented, the point that lies inside the triangle must lie on the right side of all the triangle’s side vectors. If this check fails for any of the side vectors—in the figure on the right, that’s for the (x3 - x2, x3 - y2) side—the point is lying outside.
The figure shows why an interior point lies on the same side of every directed edge and identifies the failing edge for an exterior point. section 9.3.3
