Graphics Reference
In-Depth Information
Y
P 3
P 1
P 2
X
P 3
Fig. 10.24. The top triangle has anti-clockwise vertices, and the bottom triangle
clockwise vertices.
whereas the area of the bottom triangle with clockwise vertices is
A = 1
2 [1(2
0) + 3(0
2) + 2(2
2)] =
2
So the technique is sensitive to vertex direction. We can exploit this sensitivity
to test if a point is inside or outside a triangle.
Consider the scenario shown in Figure 10.25, where the point P t is inside
the triangle ( P 1 ,P 2 ,P 3 ).
If the area of triangle ( P 1 ,P 2 ,P t ) is positive, P t must be to the left of the
line ( P 1 ,P 2 ).
If the area of triangle ( P 2 ,P 3 ,P t ) is positive, P t must be to the left of the
line ( P 2 ,P 3 ).
If the area of triangle ( P 3 ,P 1 ,P t ) is positive, P t must be to the left of the
line ( P 3 ,P 1 ).
If all the above tests are positive, P t is inside the triangle. Furthermore, if one
area is zero and the other areas are positive, the point is on the boundary,
and if two areas are zero and the other positive, the point is on a vertex.
Let's now investigate how the Hessian normal form provides a similar
function.
10.4.2 Hessian Normal Form
We can determine whether a point is inside, touching or outside a triangle
by representing the triangle's edges in the Hessian normal form, and testing
which partition the point is located in. If we arrange that the normal vectors
are pointing towards the inside of the triangle, any point inside the triangle
 
Search WWH ::




Custom Search