Graphics Reference
In-Depth Information
Y
C
y
C
t
= 1
V
y
V
A
y
A
r
= 1
s
= 1
y
B
B
x
A
x
V
x
C
x
B
X
Fig. 11.13.
The position of
V
moves between
A
,
B
and
C
depending on the value
r
,
s
and
t
.
Now let's extend the number of vertices to three in the form of a triangle
as shown in Figure 11.13. This time we will use
r
,sand
t
to control the
interpolation. We would start as follows:
V
=
r
A
+
s
B
+
t
C
where
A
,
B
and
C
are the position vectors for
A
,
B
and
C
respectively, and
V
is the position vector for the point
V
.
Let
r
=1
−
s
−
t
and
r
+
s
+
t
=1
Once more, we begin with 2D coordinates
A
(
x
A
,y
A
)
,B
(
x
B
,y
B
)and
C
(
x
C
,y
C
)
where
x
V
=
rx
A
+
sx
B
+
tx
C
y
V
=
ry
A
+
sy
B
+
ty
C
When
r
=1
,V
is coincident with A;
s
=1
,V
is coincident with B;
t
=1
,V
is coincident with
C
.
Similarly, when
r
=0
,V
is located on the edge
BC
;
s
=0
,V
is located on the edge
CA
;
t
=0
,V
is located on the edge
AB
.
For all other values of
r
,
s
and
t
,where
r
+
s
+
t
=1and0
≤
r, s, t
≤
1,
V
is inside triangle ∆
ABC
, otherwise it is outside the triangle.