Game Development Reference
In-Depth Information
/ /
d e g r e e
o f
t h e
c u r v e
by
one .
f o r
(
i n t
i
=
0
;
i
<
n
;
++ i )
{
p o i n t s [ i ]
=
p o i n t s [ i ]
∗
( 1 . 0 f
−
t )
+
p o i n t s [ i +1]
∗
t ;
}
}
/ /
R e s u l t
i s
now
i n
t h e
f i r s t
s l o t .
r e t u r n
p o i n t s [ 0 ] ;
}
Listing 13.1
Evaluating a point on a B ezier curve using de Casteljau's algorithm
This gives us a method for locating a point at any given t through re-
peated interpolation, but it doesn't directly give us a closed form expression
to calculate the point in terms of the control points. We emphasize that
such a closed form expression is often not needed, but let's derive it in
monomial form anyway. We're looking for a polynomial grouped by powers
of t. We'll work our way up from the linear and quadratic cases to the cu-
bic.
Section 13.4.2
presents a general pattern leading us to the expression
for arbitrary degree curves.
The linear case comes straight from the recurrence relation without any
real work:
b
i
(t) =
b
i
,
b
i
(t) = (1 − t)[
b
i
(t)] + t[
b
i+1
(t)]
= (1 − t)
b
i
+ t
b
i+1
=
b
i
+ t(
b
i+1
−
b
i
).
Applying one more level gives us a quadratic polynomial:
b
i
(t) = (1 − t)[
b
i
(t)] + t[
b
i+1
(t)]
= (1 − t)[
b
i
+ t(
b
i+1
−
b
i
)] + t[
b
i+1
+ t(
b
i+2
−
b
i+1
)]
= [
b
i
+ t(
b
i+1
−
b
i
)] − t[
b
i
+ t(
b
i+1
−
b
i
)]
+ t[
b
i+1
+ t(
b
i+2
−
b
i+1
)]
=
b
i
+ t(
b
i+1
−
b
i
) − t
b
i
− t
2
(
b
i+1
−
b
i
)
+ t
b
i+1
+ t
2
(
b
i+2
−
b
i+1
)
− 2
b
i
) + t
2
(
b
i
=
b
i
+ t(2
b
i+1
− 2
b
i+1
+
b
i+2
).
In other words, quadratic Bezier curves, which have three control points,
can be expressed in monomial form as
p
(t) =
b
0
(t) =
b
0
+ t(2
b
1
− 2
b
0
) + t
2
(
b
0
− 2
b
1
+
b
2
).
(13.17)
Quadratic Bezier curve
in monomial form
Before we do the last round of interpolation to get the cubic curve, let's
take a closer look at the quadratic expression in Equation (13.17). This
Search WWH ::
Custom Search