Graphics Reference
In-Depth Information
Multiply (10.50) by
1 to reverse the normal vector:
2 y
2 = 0
(10.51)
2. The line between (3, 1) and (2, 3):
2( x
3) + (
1)(1
y )=0
2 x
1+ y =0
2 x + y − 7 = 0
6
(10.52)
Multiply (10.52) by
1 to reverse the normal vector:
2 x
y + 7 = 0
(10.53)
3. The line between (2, 3) and (1, 1):
(
2)( x
2) + (
1)(3
y )=0
2 x +4
3+ y =0
2 x + y + 1 = 0
(10.54)
Multiply (10.54) by
1 to reverse the normal vector:
2 x
y
1=0
Thus the three line equations for the triangle are
2 y
2=0
2 x
y +7=0
2 x
y
1 = 0
(10.55)
We are only interested in the sign of the left-hand expressions:
2 y
2
2 x
y +7
2 x
y
1
(10.56)
which can be tested for any arbitrary point ( x, y ). If they are all positive, the
point is inside the triangle. If one expression is negative, the point is outside.
If one expression is zero, the point is on an edge, and if two expressions are
zero, the point is on a vertex.
Just as a quick test, consider the point (2, 2). The three expressions (10.56)
are positive, which confirms that the point is inside the triangle. The point
(3, 3) is obviously outside the triangle, which is confirmed by two positive
results and one negative. Finally, the point (2, 3), which is a vertex, gives one
positive result and two zero results.
Search WWH ::




Custom Search