0% found this document useful (0 votes)
185 views22 pages

Bezier Curves

1) Bézier curves were developed by Pierre Bézier to aid in automobile shape design and are defined by blending functions between control points. 2) A cubic Bézier curve can be thought of as the shifting center of mass of four point masses as their weights change according to cubic polynomial blending functions of a parameter t. 3) Bézier curves have useful properties like passing through the first and last control points and being tangent to the lines between adjacent control points. They are commonly used in font definition.

Uploaded by

ATUL CHAUHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views22 pages

Bezier Curves

1) Bézier curves were developed by Pierre Bézier to aid in automobile shape design and are defined by blending functions between control points. 2) A cubic Bézier curve can be thought of as the shifting center of mass of four point masses as their weights change according to cubic polynomial blending functions of a parameter t. 3) Bézier curves have useful properties like passing through the first and last control points and being tangent to the lines between adjacent control points. They are commonly used in font definition.

Uploaded by

ATUL CHAUHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Chapter 2

BEZIER CURVES

Bezier curves are named after their inventor, Dr. Pierre Bezier. Bezier was an engineer with the
Renault car company and set out in the early 1960s to develop a curve formulation which would
lend itself to shape design.
Engineers may find it most understandable to think of Bezier curves in terms of the center of
mass of a set of point masses. For example, consider the four masses m0 , m1 , m2 , and m3 located
at points P0 , P1 , P2 , P3 . The center of mass of these four point masses is given by the equation

P1 P2

P0 P3

Figure 2.1: Center of mass of four points.

m0 P0 + m1 P1 + m2 P2 + m3 P3
P = .
m0 + m 1 + m 2 + m 3
Next, imagine that instead of being fixed, constant values, each mass varies as a function of some
parameter t. In specific, let m0 = (1 t)3 , m1 = 3t(1 t)2 , m2 = 3t2 (1 t) and m3 = t3 .
The values of these masses as a function of t is shown in this graph: Now, for each value of t, the
masses assume different weights and their center of mass changes continuously. In fact, as t varies
between 0 and 1, a curve is swept out by the center of masses. This curve is a cubic Bezier curve
cubic because the mass equations are cubic polynomials in t. Notice that, for any value of t,
m0 + m1 + m2 + m3 1, and so we can simply write the equation of this Bezier curve as
P = m0 P0 + m1 P1 + m2 P2 + m3 P3 .
Note that when t = 0, m0 = 1 and m1 = m2 = m3 = 0. This forces the curve to pass through
P0 . Also, when t = 1, m3 = 1 and m0 = m1 = m2 = 0, thus the curve also passes through point P3 .
Furthermore, the curve is tangent to P0 P1 and P3 P2 . These properties make Bezier curves

13
14 CHAPTER 2. BEZIER CURVES

m
1
m0 m3

m1 m2

t
0
0 1

Figure 2.2: Cubic Bezier blending functions.

P1 P2

P0 P3

Figure 2.3: Cubic Bezier curve.


15

an intuitively meaningful means for describing free-form shapes. Here are some other examples of
cubic Bezier curves which illustrate these properties. These variable masses m i are normally called

Figure 2.4: Examples of cubic Bezier curves.

blending functions and their locations Pi are known as control points or Bezier points. If we draw
straight lines between adjacent control points, as in a dot to dot puzzle, the resulting figure is known
as a control polygon. The blending functions, in the case of Bezier curves, are known as Bernstein
polynomials. We will later look at other curves formed with different blending functions.
Bezier curves of any degree can be defined. Figure 2.5 shows sample curves of degree one through
four. A degree n Bezier curve has n + 1 control points whose blending functions are denoted B in (t),

Degree 1 Degree 2

Degree 3 Degree 4

Figure 2.5: Bezier curves of various degree.

where ! "
n
Bin (t) = (1 t)ni ti , i = 0, 1, ..., n.
i
# $
Recall that ni is called a binomial coefficient, sometimes spoken n - choose - i, and is equal to
i!(ni)! . In our introductory example, n = 3 and m0 = B0 = (1 t) , m1 = B1 = 3t(1 t) ,
n! 3 3 3 2

m2 = B23 = 3t2 (1 t) and m3 = B33 = t3 . Bin (t) is also referred to as the ith Bernstein polynomial
16 CHAPTER 2. BEZIER CURVES

of degree n. The equation of a Bezier curve is thus:


%n ! "
n
P(t) = (1 t)ni ti Pi . (2.1)
i=0
i

Figure 2.6: Font definition using Bezier curves.

A common use for Bezier curves is in font definition. Figure 2.6 shows the outline a letter g
created using Bezier curves. All PostScript font outlines are defined use cubic and linear Bezier
curves.

2.1 Bezier Curves over Arbitrary Parameter Intervals


Equation 2.1 gives the equation of a Bezier curve which starts at t = 0 and ends at t = 1. It is
useful, especially when fitting together a string of Bezier curves, to allow an arbitrary parameter
interval:
t0 t t 1
such that P(t0 ) = P0 and P(t1 ) = Pn . This can be accomplished by modifying equation 2.1:
&n #n$
i=0 i (t1 t) (t t0 )i Pi
ni
P(t) = = (2.2)
(t1 t0 )n

%n ! "
n t1 t ni t t0 i
( ) ( ) Pi .
i=0
i t1 t 0 t1 t 0

2.2 Subdivision of Bezier Curves


The most fundamental algorithm for dealing with Bezier curves is the subdivision algorithm. This
was devised in 1959 by Paul de Casteljau (who was working for the Citroen automobile company)
and is referred to as the de Casteljau algorithm. It is sometimes known as the geometric construction
algorithm.
Consider a Bezier curve defined over the parameter interval [0, 1]. It is possible to subdivide
such a curve into two new Bezier curves, one of them over the domain 0 t and the other over
2.2. SUBDIVISION OF BEZIER CURVES 17

t 1. These two new Bezier curves, considered together, are equivalent to the single original
curve from which they were derived.
As illustrated in Figure 2.7, begin by adding a superscript of 0 to the original control points,
then compute
Pji = (1 )Pj1
i + Pj1
i+1 ; j = 1, . . . , n; i = 0, . . . , n j. (2.3)
Then, the curve over the parameter domain 0 t is defined using control points P00 , P10 , P20 , . . . , Pn0
and the curve over the parameter domain t 1 is defined using control points Pn0 , Pn1
1 , P2n2 , . . . , P0n .

P20 P11 P20


P11
P12
P10 P10 P02
P12
P21
P02 P03 P03
P01 P21
P01
P30 P30
P00 P00
t = .4 t = .6

Figure 2.7: Subdividing a cubic Bezier curve.

Figure 2.8 shows that when a Bezier curve is repeatedly subdivided, the collection of control
polygons converge to the curve.

1 curve 2 curves

4 curves 8 curves

Figure 2.8: Recursively subdividing a quadratic Bezier curve.

One immediate value of the de Casteljau algorithm is that it provides a numerically stable means
of computing the coordinates of any point along the curve. Its extension to curves of any degree
should be obvious.
18 CHAPTER 2. BEZIER CURVES

It can be shown that if a curve is repeatedly subdivided, the resulting collection of control points
converges to the curve. Thus, one way of plotting a Bezier curve is to simply subdivide it an
appropriate number of times and plot the control polygons.
The de Casteljau algorithm works even for parameter values outside of the original parameter
interval. Fig. 2.9 shows a quadratic Bezier curve subdivided at = 2. The de Castelau algorithm

P01

P11
P10
P20

P02
P00
t=2

Figure 2.9: Subdividing a quadratic Bezier curve.

is numerically stable as long as the parameter subdivision parameter is within the parameter domain
of the curve.

2.3 Degree Elevation


Another useful algorithm is the degree elevation algorithm. This has many uses. For example, some
modeling systems use only cubic Bezier curves. However, it is important to be able to represent
degree two curves exactly. A curve of degree two can be exactly represented as a Bezier curve of
degree three or higher. In fact, any Bezier curve can be represented as a Bezier curve of higher
degree.
We illustrate by raising the degree of a cubic Bezier curve to degree four. We denote the cubic
Bezier curve in the usual way:

x(t) = P0 B03 (t) + P1 B13 (t) + P2 B23 (t) + P3 B33 (t)

Note that this curve is not changed at all if we multiply it by [t + (1 t)] 1. However,
multiplication in this way does serve to raise the degree of the Bezier curve by one. Its effect in the
cubic case is to create five control points from the original four. Those five control points thus define
a degree four Bezier curve which is precisely the same as the original degree three curve. The new
control points Pi are easily found as follows:

P0 = P0

1 3
P1 = P0 + P1
4 4
2.3. DEGREE ELEVATION 19

P1 old P2* P2

P1* new P3*

1/2

1/4

P3 P4*
P0* P0

Figure 2.10: Degree elevation.

2 2
P2 = P1 + P2
4 4
3 1
P3 = P2 + P3
4 4
P4 = P3
This works for any degree n as follows:
i
Pi = i Pi1 + (1 i )Pi , i = .
n+1
Furthermore, this degree elevation can be applied repeatedly to raise the degree to any level, as
shown in Figure 2.11. Note that the control polygon converges to the curve itself.

Degree 2 Degree 3 Degree 4

Degree 5 Degree 6 Degree 7

Figure 2.11: Repeated degree elevation.


20 CHAPTER 2. BEZIER CURVES

2.4 Distance between Two Bezier Curves


The problem often arises of determining how closely a given Bezier curve is approximated by a
second Bezier curve. For example, if a given cubic curve can be adequately represented by a degree
elevated quadratic curve, it would be computationally advantageous to replace the cubic curve with
the quadratic curve.
Given two Bezier curves
n
% n
%
P(t) = Pi Bin (t); Q(t) = Qi Bin (t)
i=0 i=0

the vector P(t) Q(t) between points of equal parameter value on the two curves can itself be
expressed as a Bezier curve
n
%
D(t) = P(t) Q(t) = (Pi Qi )Bin (t)
i=0

whose control points are Di = Pi Qi . The vector from the origin to the point D(t) is P(t) Q(t).
Thus, the distance between the two curves is bounded by the largest distance from the origin to any
of the control points Di .

Q1
Q2
P1 P2
P3-Q3

t=1/2

P0-Q0 P2-Q2

P3 P1-Q1
Q0
P0 Q3

Figure 2.12: Difference curve.

2.5 Derivatives
The parametric derivatives of a Bezier curve can be determined geometrically from its control points.
For a curve of degree n with control points Pi , the first parametric derivative can be expressed as
a curve of degree n 1 with control points Di where

Di = n(Pi+1 Pi )
2.6. CONTINUITY 21

D0

3(P1-P0)

P1 (0,0) P(t)
P0 P(t) 3(P3-P2)
P2
P3 3(P2-P1)
D2

D1

Figure 2.13: Hodograph.

For example, the cubic Bezier curve in Fig. 2.13 has a first derivative curve as shown. Of course,
the first derivative of a parametric curve provides us with a tangent vector. This is illustrated in
Fig. 2.13 for the point t = .3. This differentiation can be repeated to obtain higher derivatives as
well.
The first derivative curve is known as a hodograph. It is interesting to note that if the hodograph
passes through the origin, there is a cusp corresponding to that point on the original curve!
Note that the hodograph we have just described relates only to Bezier curves, NOT to rational
Bezier curves or any other curve that we will study. The derivative of any other curve must be
computed by differentiation.

2.6 Continuity
In describing a shape using free-form curves, it is common to use several curve segments which are
joined together with some degree of continuity. Normally, a single Bezier curve will not suffice to
define a complex shape. Recall the last time you used a French curve. You most likely were not able
to find a single stretch along the French curve which met your needs, and were forced to segment your
curve into three or four pieces which could be drawn by the French curve. These adjoining pieces
probably had the same tangent lines at their common endpoints. This same piecewise construction
is used in Bezier curves.
There are two types of continuity that can be imposed on two adjoining Bezier curves: parametric
continuity and geometric continuity. In general, two curves which are parametric continuous to a
certain degree are also geometric continuous to that same degree, but the reverse is not so.
Parametric continuity is given the notation C i , which means ith degree parametric continuity.
This means that the two adjacent curves have identical ith degree parametric derivatives, as well as
all lower derivatives. Thus, C 0 means simply that the two adjacent curves share a common endpoint.
C 1 means that the two curves not only share the same endpoint, but also that they have the same
tangent vector at their shared endpoint, in magnitude as well as in direction. C 2 means that two
curves are C 1 and in addition that they have the same second order parametric derivatives at their
22 CHAPTER 2. BEZIER CURVES

shared endpoint, both in magnitude and in direction.


In Fig. 2.14, the two curves are obviously at least C 0 because p3 q0 . Furthermore, they are

q3
p0

q2
p1

p2 p3 q0 q1

Figure 2.14: C 2 Bezier curves.

C 1 if line segments p2 p3 and q0 q1 are collinear and of equal length. It also appears that they
are C 2 , which you can verify by sketching the second derivative curves.
The conditions for geometric continuity (also known as visual continuity) are less strict than
for parametric continuity. For G1 , we merely require that line segments p2 p3 and q0 q1 are
collinear, but they need not be of equal length. This amounts to saying that they have a common
tangent line, though the magnitude of the tangent vector may be different. G2 (second order visual
or geometric continuity) means that the two neighboring curves have the same tangent line and also
the same curvature at their common boundary. The curvature of a Bezier curve at its endpoint is
given by
n1 h
=
n a2
where n is the degree of the curve and a and h are as shown in Fig. 2.15. Note that a is the length
of the first leg of the control polygon, and h is the perpendicular distance from P2 to the first leg of
the control polygon.
Two curves that are Gn can always be reparameterized so that they are C n . This provides a
practical definition of Gn continuity.

2.7 Three Dimensional Bezier Curves


It should be obvious that if the control points happen to be defined in three dimensional space, the
resulting Bezier curve is also three dimensional. Such a curve is sometimes called a space curve,
and a two dimensional curve is called a planar curve. Note that since a degree two Bezier curve is
defined using three control points, every degree two curve is planar, even if the control points are in
a three dimensional coordinate system.

2.8 Rational Bezier Curves


It is possible to change the shape of a Bezier curve by scaling the blending functions B in of the
control points by values which we denote wi . These wi are known as control point weights. Since it
P3

2.8. RATIONAL BEZIER CURVES 23

P2

P0

h
a P1

Figure 2.15: Endpoint curvature.

is essential for the blending functions to sum to one (or else the curve will change with the coordinate
system), we must normalize the blending functions by dividing through by their total value. Thus,
the equation becomes

w0 B0n (t)P0 + ... + wn Bnn (t)Pn


.
w0 B0n (t) + ... + wn Bnn (t)

The effect of changing a control point weight is illustrated in Fig. 2.16. This type of curve is known
as a rational Bezier curve, because the blending functions are rational polynomials, or the ratio of
two polynomials. The Bezier curves that we have dealt with up to now are sometimes known as
non-rational or integral Bezier curves. There are more important reasons for using rational Bezier
curves than simply the increased control it provides over the shape of the curve. For example, a
perspective drawing of a 3D Bezier curve (integral or rational) is a rational Bezier curve. Also,
rational Bezier curves are needed to exactly express all conic sections. A degree two integral Bezier
curve can only represent a parabola. Exact representation of circles requires rational degree two
Bezier curves.
A rational Bezier curve can be viewed as the projection of a 3-D curve. Fig. 2.17 shows two
curves: a 3-D curve and a 2-D curve. The 2-D curve lies on the plane z = 1 and it is defined as the
projection of the 3-D curve onto the plane z = 1. One way to consider this is to imagine a funny
looking cone whose vertex is at the origin and which contains the 3-D curve. In other words, this
cone is the collection of all lines which contain the origin and a point on the curve. Then, the 2-D
rational Bezier curve is the intersection of the cone with the plane z = 1.
If the 2-D rational Bezier curve has control points (xi , yi ) with corresponding weights wi , then
the (X, Y, Z) coordinates of the 3-D curve are (xi wi , yi wi , wi ). Denote points on the 3-D curve using
upper case variables (X(t), Y (t), Z(t)) and on the 2-D curve using lower case variables (x(t), y(t)).
Then, any point on the 2-D rational Bezier curve can be computed by computing the corresponding
point on the 3-D curve, (X(t), Y (t), Z(t)), and projecting it to the plane z = 1 by setting

X(t) Y (t)
x(t) = , y(t) = .
Z(t) Z(t)
24 CHAPTER 2. BEZIER CURVES

P2

w2=5 w2=10
P1
w2=2

w2=1

w2=.5

w2=0

P3

P0

Figure 2.16: Rational Bezier curve.

2.9 Tangency and Curvature


The equations for the endpoint tangency and curvature of a rational Bezier curve must be computed
using the quotient rule for derivatives it does not work to simply compute the tangent vector
and curvature for the three dimensional non-rational Bezier curve and then project that value to
the (x, y) plane. For a degree n rational Bezier curve,

xn (t)
x(t) = =
d(t)
# $ # $ # $
w0 x0 n0 (1 t)n + w1 x1 n1 (1 t)n1 t + w2 x2 n2 (1 t)n2 t2 + . . .
# $ # $ # $ ;
w0 n0 (1 t)n + w1 n1 (1 t)n1 t + w2 n2 (1 t)n2 t2 + . . .
yn (t)
y(t) = =
d(t)
# $ # $ # $
w0 y0 n0 (1 t)n + w1 y1 n1 (1 t)n1 t + w2 y2 n2 (1 t)n2 t2 + . . .
#n$ #n$ #n$
w0 0 (1 t)n + w1 1 (1 t)n1 t + w2 2 (1 t)n2 t2 + . . .
the equation for the tangent vector t = 0 must be found by evaluating the following equations:

d(0)xn (0) d(0)xn (0)

d(0)yn (0) d(0)y n (0)
x(0) = ; y(0) =
d (0)
2 d (0)
2

from which
w1
P# (0) = n(P1 P0 ).
w0
2.9. TANGENCY AND CURVATURE 25

(x1,y1,1)w1

(x2,y2,1)w2
(x0,y0,1)w0
z

(x3,y3,1)w3
(x1,y1,1)
(x2,y2,1)
z=1 (x0,y0,1) (x3,y3,1)

y
x
z

xi
wi
z=1
1
x
xiwi

Figure 2.17: Rational curve as the projection of a 3-D curve.


26 CHAPTER 2. BEZIER CURVES

and the curvature at t = 0 is found by evaluating the curvature equation

|xy yx|
= 3
(x2 + y 2 ) 2

from which it can be shown


w0 w2 n 1 h
(0) =
w12 n a2
where a and h are as shown in Figure 2.15.

2.10 Reparametrization
Any integral parametric curve X(t) = (x(t), y(t)) can be reparametrized by the substitution
t = f (u). If f (u) = a0 + a1 u, then the reparametrization has the effect of changing the
range over which the curve segment is defined. Thus, two Bezier subdivisions can always accomplish
exactly what a linear parameter substitution does.
It is also legal for f (u) to be nonlinear. This, of course, does not change the shape of the curve
but it does cause the curve to be improperly parametrized, which means that to each point on the
curve there corresponds more than one parameter value u. There are occasions when it is desirable
to do this. If so, however, it is advisable that the curve does not end up being multiply traced, which
means that portions of the curve get redrawn as the parameter sweeps from zero to one.
A rational parametric curve can be reparametrized with the substitution t = f (u)/g(u). In this
case, it is actually possible to perform a rational-linear reparametrization which does not change the
endpoints of our curve segment. If we let

a(1 u) + bu
t =
c(1 u) + du

and want u = 0 when t = 0 and u = 1 when t = 1, then a = 0 and b = d. Since we can scale then
numerator and denominator without affecting the reparametrization, set c = 1 and we are left with
bu
t =
(1 u) + bu

A rational Bezier curve


#n$ # $ # $
0 w#0 P 0 (1 t)
n
+ n1 w1 P1 (1 t)n1 t + ... + nn wn Pn tn
X(t) = n
$ # $ # $
n + n w (1 t)n1 t + ... + n w tn
0 w0 (1 t) 1 1 n n

can be raparametrized without changing its endpoints by making the substitutions

bu (1 u)
t = , (1 t) = .
(1 u) + bu (1 u) + bu

After multiplying numerator and denominator by ((1 u) + bu)n , we obtain


#n$ 0 # $ # $
0 (b w#0 )P0 (1 t)
n
+ n1 (b1 w1 )P1 (1 t)n1 t + ... + nn (bn wn )Pn tn
X(t) = $
n 0
# $ # $
n + n b1 w (1 t)n1 t + ... + n bn w tn
0 b w0 (1 t) 1 1 n n

In other words, if we scale the weights wi by bi , the curve will not be changed!
2.11. CIRCULAR ARCS 27

Q0; w0= 1
P0; w0= 1
e
P1; w1= cosq/2 Q1; w1= (1 + 2cosq/2)/3
r r
q q Q2; w2= (1 + 2cosq/2)/3
d

e
P2; w2= 1 Q3; w3= 1

Figure 2.18: Circular arcs.

2.11 Circular Arcs


Circular arcs can be exactly represented using rational Bezier curves. Figure 2.18 shows a circular
arc as both a degree two and a degree three rational Bezier curve. Of course, the control polygons
are tangent to the circle. The degree three case is a simple degree elevation of the degree two case.
The length e is given by

2 sin 2
e= r.
1 + 2 cos 2

The degree two case has trouble when approaches 180 since P1 moves to infinity, although this
can be remedied by just using homogeneous coordinates. The degree three case has the advantage
that it can represent a larger arc, but even here the length e goes to infinity as approaches 240 .
For large arcs, a simple solution is to just cut the arc in half and use two cubic Bezier curves. A
complete circle can be represented as a degree five Bezier curve as shown in Figure 2.19. Here, the

p3 = (-2,4) p2 = (2,4)

p4 = (-4,0) p5 = (0,0) p0 = (0,0) p1 = (4,0)

Figure 2.19: Circle as Degree 5 Rational Bezier Curve.

weights are w0 = w5 = 1 and w1 = w2 = w3 = w4 = 15 .


28 CHAPTER 2. BEZIER CURVES

2.12 Explicit Bezier Curves


An explicit Bezier curve is one for which the x-coordinates & of the control points are evenly spaced
n
between 0 and 1. That is, Pi = ( ni , yi ), i = 0, . . . , n. Since i=0 ni Bin (t) t[(1 t) + t]n t, such
a Bezier curve takes on the important special form

x = t
y = f (t)

or simply
y = f (x).
An explicit Bezier curve is sometimes called a non-parametric Bezier curve. It is just a polynomial
function expressed in the Bernstein polynomial basis. Figure 2.20 shows a degree five explicit Bezier
curve.

P1
P4
P5
.2
0 .4 .6 .8 1

P2
P0
P3

Figure 2.20: Explicit Bezier curve.

2.13 Integrating Bernstein polynomials


Recall that the hodograph (first derivative) of a Bezier curve is easily found by simply differencing
adjacent control points (Section 2.5). It is equally simple to compute the integral of a Bernstein
polynomial. Since the integral of a polynomial in Bernstein form
n
%
p(t) = pi Bin (t) (2.4)
i=0

is that polynomial whose derivative is p(t). If the desired integral is a degree n + 1 polynomial in
Bernstein form
n+1
%
q(t) = qi Bin+1 (t), (2.5)
i=0
2.14. FORWARD DIFFERENCING 29

we have
pi = (n + 1)(qi+1 qi ). (2.6)
Hence, q0 = 0 and
&i1
j=0 pj
qi = , i = 1, n + 1. (2.7)
n+1
Note that if p(t) is expressed as an explicit Bezier curve, q(t) can be interpreted as the area under
p(t) between the lines x = 0 and x = t. Thus, the entire area under an explicit Bezier curve can be
computed as simply the average of the control points! This is so because
&n
j=0 pj
q(1) = qn+1 = . (2.8)
n+1

2.14 Forward Differencing


Horners algorithm is the fastest method for evaluating a polynomial at a single point. For a degree
n polynomial, it requires n multiplies and n adds.
If a polynomial is to be evaluated at several evenly spaced values t, t + , t + 2, . . . , t + k, the
fastest method is to use forward differences.
Consider a degree 1 polynomial
f (t) = a0 + a1 t.
The difference between two adjacent function values is

1 (t) = f (t + ) f (t) = [a0 + a1 (t + )] [a0 + a1 t] = a1 .

Thus, f (t) can be evaluated at several evenly spaced points using the algorithm:
1 = a1
t0 = 0
f (0) = a0
for i = 1 to k do
ti = ti1 +
f (ti ) = f (ti1 ) + 1
endfor
Thus, each successive evaluation requires only one add, as opposed to one add and one multiply
for Horners algorithm.
This idea extends to polynomials of any degree. For the quadratic case,

f (t) = a0 + a1 t + a2 t2 .

The difference between two adjacent function values is

1 (t) = f (t + ) f (t) = [a0 + a1 (t + ) + a2 (t + )2 ] [a0 + a1 t + a2 t2 ]

1 (t) = a1 + a2 2 + 2a2 t.
We can now write
30 CHAPTER 2. BEZIER CURVES

t0 = 0
f (0) = a0
for i = 1 to k do
ti = ti1 +
1 (ti ) = a1 + a2 2 + 2a2 ti1
f (ti ) = f (ti1 ) + 1 (ti1 )
endfor

In this case, (t) is a linear polynomial, so we can evaluate it as above, by defining

2 (t) = 1 (t + ) 1 (t) = 2a2 2

and our algorithm now becomes

t0 = 0
f (0) = a0
1 = a1 + a2 2
2 = 2a2 2
for i = 1 to k do
ti = ti1 +
f (ti ) = f (ti1 ) + 1
1 = 1 + 2
endfor

It should be clear that for a degree n polynomial, each successive evaluation requires n adds and no
multiplies! For a cubic polynomial

f (t) = a0 + a1 t + a2 t2 + a3 t3 ,

the forward difference algorithm becomes

t0 = 0
f (0) = a0
1 = a1 + a2 2 + a3 3
2 = 2a2 2 + 6a3 3
3 = 6a3 3
for i = 1 to k do
ti = ti1 +
f (ti ) = f (ti1 ) + 1
1 = 1 + 2
2 = 2 + 3
endfor
2.14. FORWARD DIFFERENCING 31

Several questions remain. First, what are the initial values for the i if we want to start at
some value other than t = 0. Second, what is a general equation for the i for a general degree n
polynomial f (t). Also, what if our polynomial is not in power basis.
These questions can be answered almost trivially by observing the following. Since t i+1 = ti + ,
we have
1 (ti ) = f (ti+1 ) f (t);
j (ti ) = j1 (ti+1 ) j1 (ti ), j = 2, . . . , n;
n (ti ) = n (ti+1 ) = n (ti+k ) = a constant
n+1 = 0
Thus, our initial values for j (ti ) can be found by simply computing f (ti ), f (ti+1 ), . . . , f (ti+n )
and from them computing the initial differences. This lends itself nicely to a table. Here is the table
for a degree four case:
f (ti ) f (ti+1 ) f (ti+2 ) f (ti+3 ) f (ti+4 )
1 (ti ) 1 (ti+1 ) 1 (ti+2 ) 1 (ti+3 )
2 (ti ) 2 (ti+1 ) 2 (ti+2 )
3 (ti ) 3 (ti+1 )
4 (ti )
0 0 0 0 0
To compute f (ti+5 ), we simply note that every number R in this table, along with its right hand
neighbor Rright and the number directly beneath it Rdown obey the rule
Rright = R + Rdown .
Thus, we can simply fill in the values
4 (ti+1 ) = 4 (ti ) + 0
3 (ti+2 ) = 3 (ti+1 ) + 4 (ti+1 )
2 (ti+3 ) = 2 (ti+2 ) + 3 (ti+2 )
1 (ti+4 ) = 1 (ti+3 ) + 2 (ti+3 )
f (ti+5 ) = f (ti+4 ) + 1 (ti+4 )
Note that this technique is independent of the basis in which f (t) is defined. Thus, even if it
is defined in Bernstein basis, all we need to do is to evaluate it n + 1 times to initiate the forward
differencing.
For example, consider the degree 4 polynomial for which f (ti ) = 1, f (ti+1 ) = 3, f (ti+2 ) = 2,
f (ti+3 ) = 5, f (ti+4 ) = 4. We can compute f (ti+5 ) = 24, f (ti+6 ) = 117, and f (ti+7 ) = 328
from the following difference table:
t: ti ti+1 ti+2 ti+3 ti+4 ti+5 ti+6 ti+7
f (t) : 1 3 2 5 4 24 117 328
1 (t) : 2 1 3 1 28 93 211
2 (t) : 3 4 4 27 65 118
3 (t) : 7 8 23 38 53
4 (t) : 15 15 15 15 15
5 (t) : 0 0 0 0 0 0 0 0
32 CHAPTER 2. BEZIER CURVES

2.15 Forward Differencing


Horners algorithm is the fastest method for evaluating a polynomial at a single point. For a degree
n polynomial, it requires n multiplies and n adds.
If a polynomial is to be evaluated at several evenly spaced values t, t + , t + 2, . . . , t + k, the
fastest method is to use forward differences.
Consider a degree 1 polynomial
f (t) = a0 + a1 t.
The difference between two adjacent function values is

1 (t) = f (t + ) f (t) = [a0 + a1 (t + )] [a0 + a1 t] = a1 .

Thus, f (t) can be evaluated at several evenly spaced points using the algorithm:
1 = a1
t0 = 0
f (0) = a0
for i = 1 to k do
ti = ti1 +
f (ti ) = f (ti1 ) + 1
endfor
Thus, each successive evaluation requires only one add, as opposed to one add and one multiply
for Horners algorithm.
This idea extends to polynomials of any degree. For the quadratic case,

f (t) = a0 + a1 t + a2 t2 .

The difference between two adjacent function values is

1 (t) = f (t + ) f (t) = [a0 + a1 (t + ) + a2 (t + )2 ] [a0 + a1 t + a2 t2 ]

1 (t) = a1 + a2 2 + 2a2 t.
We can now write
t0 = 0
f (0) = a0
for i = 1 to k do
ti = ti1 +
1 (ti ) = a1 + a2 2 + 2a2 ti1
f (ti ) = f (ti1 ) + 1 (ti1 )
endfor
In this case, (t) is a linear polynomial, so we can evaluate it as above, by defining

2 (t) = 1 (t + ) 1 (t) = 2a2 2

and our algorithm now becomes


2.15. FORWARD DIFFERENCING 33

t0 = 0
f (0) = a0
1 = a1 + a2 2
2 = 2a2 2
for i = 1 to k do
ti = ti1 +
f (ti ) = f (ti1 ) + 1
1 = 1 + 2
endfor

It should be clear that for a degree n polynomial, each successive evaluation requires n adds and no
multiplies! For a cubic polynomial

f (t) = a0 + a1 t + a2 t2 + a3 t3 ,

the forward difference algorithm becomes

t0 = 0
f (0) = a0
1 = a1 + a2 2 + a3 3
2 = 2a2 2 + 6a3 3
3 = 6a3 3
for i = 1 to k do
ti = ti1 +
f (ti ) = f (ti1 ) + 1
1 = 1 + 2
2 = 2 + 3
endfor

Several questions remain. First, what are the initial values for the i if we want to start at
some value other than t = 0. Second, what is a general equation for the i for a general degree n
polynomial f (t). Also, what if our polynomial is not in power basis.
These questions can be answered almost trivially by observing the following. Since t i+1 = ti + ,
we have
1 (ti ) = f (ti+1 ) f (t);

j (ti ) = j1 (ti+1 ) j1 (ti ), j = 2, . . . , n;

n (ti ) = n (ti+1 ) = n (ti+k ) = a constant

n+1 = 0
34 CHAPTER 2. BEZIER CURVES

Thus, our initial values for j (ti ) can be found by simply computing f (ti ), f (ti+1 ), . . . , f (ti+n )
and from them computing the initial differences. This lends itself nicely to a table. Here is the table
for a degree four case:

f (ti ) f (ti+1 ) f (ti+2 ) f (ti+3 ) f (ti+4 )


1 (ti ) 1 (ti+1 ) 1 (ti+2 ) 1 (ti+3 )
2 (ti ) 2 (ti+1 ) 2 (ti+2 )
3 (ti ) 3 (ti+1 )
4 (ti )
0 0 0 0 0

To compute f (ti+5 ), we simply note that every number R in this table, along with its right hand
neighbor Rright and the number directly beneath it Rdown obey the rule

Rright = R + Rdown .

Thus, we can simply fill in the values

4 (ti+1 ) = 4 (ti ) + 0

3 (ti+2 ) = 3 (ti+1 ) + 4 (ti+1 )


2 (ti+3 ) = 2 (ti+2 ) + 3 (ti+2 )
1 (ti+4 ) = 1 (ti+3 ) + 2 (ti+3 )
f (ti+5 ) = f (ti+4 ) + 1 (ti+4 )
Note that this technique is independent of the basis in which f (t) is defined. Thus, even if it
is defined in Bernstein basis, all we need to do is to evaluate it n + 1 times to initiate the forward
differencing.
For example, consider the degree 4 polynomial for which f (ti ) = 1, f (ti+1 ) = 3, f (ti+2 ) = 2,
f (ti+3 ) = 5, f (ti+4 ) = 4. We can compute f (ti+5 ) = 24, f (ti+6 ) = 117, and f (ti+7 ) = 328
from the following difference table:

t: ti ti+1 ti+2 ti+3 ti+4 ti+5 ti+6 ti+7


f (t) : 1 3 2 5 4 24 117 328
1 (t) : 2 1 3 1 28 93 211
2 (t) : 3 4 4 27 65 118
3 (t) : 7 8 23 38 53
4 (t) : 15 15 15 15 15
5 (t) : 0 0 0 0 0 0 0 0

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy