Graphics Reference
In-Depth Information
Thetriple( r , s , t ) are barycentric coordinates and locate points relative to
A , B and C , rather than an origin. For example, the barycentric coordinates
of A , B and C are (1, 0, 0), (0, 1, 0) and (0, 0, 1) respectively.
All of the above formulae work equally well in three dimensions, so let's
investigate how barycentric coordinates can locate points inside a 3D trian-
gle. However, before we start, let's clarify what we mean by inside atri-
angle. Fortunately, barycentric coordinates can distinguish points within the
triangle's three sides; points coincident with the sides; and points outside
the triangle's boundary. The range and value of the barycentric coordinates
provide the mechanism for detecting these three conditions.
Figure 11.14 illustrates a scenario with the points P 1 ( x 1 ,y 1 ,z 1 ) ,P 2 ( x 2 ,y 2 ,z 2 )
and P 3 ( x 3 ,y 3 ,z 3 ). Using barycentric coordinates we can state that any point
P 0 ( x 0 ,y 0 ,z 0 ) inside or on the edge of triangle ∆ P 1 P 2 P 3 is defined by
x 0 = rx 1 + sx 2 + tx 3
y 0 = ry 1 + sy 2 + ty 3
z 0 = rz 1 + sz 2 + tz 3
where r + s + t =1and0 ≤ r, s, t ≤ 1
If the triangle's vertices are P 1 (0 , 2 , 0) ,P 2 (0 , 0 , 4) and P 3 (3 , 1 , 2) then we
can choose different values of r , s and t to locate P 0 inside the triangle.
However, I would also like to confirm that P 0 lies on the plane containing the
three points. To do this we require the plane equation for the three points,
which can be derived as follows.
Given P 1 ( x 1 ,y 1 ,z 1 ) ,P 2 ( x 2 ,y 2 ,z 2 )and P 3 ( x 3 ,y 3 ,z 3 ), and the target plane
equation ax + by + cz + d =0
then
1
y 1
z 1
a =
1
y 2
z 2
1
y 3
z 3
Y
P 3
P 0
P 4
P 2
Z
X
Fig. 11.14. A 3D triangle.
Search WWH ::




Custom Search