Game Development Reference

In-Depth Information

(

)

P

=− −

1

ww

P

+

w

P

+

w

P

1

2

0

1

1

2

2

(

)

(

)

=+

P

w

P

− +

P

w

P

−

P

.

(6.55)

0

1

1

0

2

2

0

We perform the remainder of our calculations relative to the point
P
by defining

RPP

QPP

Q

=−

=−

=−

0

1

1

0

PP
.

(6.56)

2

2

0

Equation (6.55) now becomes

RQ Q
.

=

ww

+

(6.57)

11

2 2

Taking the dot product of both sides of Equation (6.57) first with

Q
and then

with
Q
gives us the two equations

2

(

)

RQ

⋅

=

wQ

+

w

Q Q

⋅

1

1

1

2

1

2

(

)

RQ

⋅

=

w

Q Q

⋅

+

w Q

2

,

(6.58)

2

1

1

2

2

2

which are written in matrix form as

2

1

Q

QQ

w

Qw

⋅

RQ

⋅

1

2

1

1

=

RQ
.

(6.59)

QQ

⋅

2

⋅

1

2

2

2

2

We can now easily solve for

w
and

w
as follows.

−

1

2

1

w

Q

QQ

⋅

RQ

⋅

1

2

1

1

=

2

w

QQ

⋅

Q

RQ

⋅

−⋅

2

1

2

2

2

2

2

1

Q

QQ

RQ

⋅

1

2

1

=

RQ

(6.60)

22

(

)

2

2

QQ

−⋅

QQ

−⋅

QQ

Q

⋅

12

1

2

1

2

1

2

The point
R
lies inside the triangle if and only if all three weights

w
,

w
, and

w

are nonnegative. Since

.

If the vertices
P
,
P
, and
P
have any associated attributes, such as a color or

texture coordinate set, then the interpolated value of those attributes at the point

R
can be calculated using the weights

www

=−

−

, this implies that

ww

+≤

1

0

1

2

1

2

w
,

w
, and

w
. For instance, if the texture

coordinates

,

t

,

,

t

, and

,

t

are associated with the vertices
P
,
P
, and

s

s

s

00

11

22

P
, then the texture coordinates

s t
at the point
R
are given by

Search Nedrilad ::

Custom Search