04.02.2021 Views

SEMINAR

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

T.C.

SÜLEYMAN DEMİREL ÜNİVERSİTESİ

FEN-BİLİMLERİ ENSTİTÜSÜ

BEZIER CURVE FITTING

Idris A. MASOUD

Supervisor:

Prof. Dr. Ahmet SAHINER

PhD SEMINAR II

DEPARTMENT OF MATHEMATICS

ISPARTA-2018,


Contents

Contents 3

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Bernstein Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.1 Building Bernstein Polynomials . . . . . . . . . . . . . . . . . 5

2.2 Bezier Curve . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.3 Bezier Curves with Closed Ends . . . . . . . . . . . . . . . . . 11

3 Bezier solutions of the wave equation . . . . . . . . . . . . . . . . . . 13

3.1 Bezier solutions of the 1D-wave equation . . . . . . . . . . . . 13

3.2 The 1D-wave equation in terms of the control points . . . . . 13

3.3 Computing the solutions of the 1D-wave conditions . . . . . . 14

4 Bezier solutions of the 2D-wave equation . . . . . . . . . . . . . . . . 17

4.1 The 2D-wave equation in terms of the control points . . . . . 17

4.2 A tricubical example . . . . . . . . . . . . . . . . . . . . . . . 18

4.3 Computing the solutions of the 2D-wave conditions . . . . . . 19

5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

6 Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

References 30

3


Abstract

In order to draw things in 2D, we usually rely on lines, which typically get classified

into two categories: straight lines, and curves. The first of these are as easy to draw

as they are easy to make a computer draw. Give a computer the first and last point

in the line, and BAM! straight line. No questions asked.

Curves, however, are a much bigger problem. While we can draw curves with ridiculous

ease freehand, computers are a bit handicapped in that they can’t draw curves

unless there is a mathematical function that describes how it should be drawn. In

fact, they even need this for straight lines, but the function is ridiculously easy, so

we tend to ignore that as far as computers are concerned, all lines are ”functions”,

regardless of whether they’re straight or curves. However, that does mean that we

need to come up with fast-to-compute functions that lead to nice looking curves on

a computer. There’s a number of these, and in this article we’ll focus on a particular

function that has received quite a bit of attention, and is used in pretty much

anything that can draw curves: ”Bezier” curves


1 Introduction

In order to draw things in 2D, we usually rely on lines, which typically get classified

into two categories: straight lines, and curves. The first of these are as easy to draw

as they are easy to make a computer draw. Give a computer the first and last point

in the line, and BAM! straight line. No questions asked.

Curves, however, are a much bigger problem. While we can draw curves with ridiculous

ease freehand, computers are a bit handicapped in that they can’t draw curves

unless there is a mathematical function that describes how it should be drawn. In

fact, they even need this for straight lines, but the function is ridiculously easy, so

we tend to ignore that as far as computers are concerned, all lines are ”functions”,

regardless of whether they’re straight or curves. However, that does mean that we

need to come up with fast-to-compute functions that lead to nice looking curves on

a computer. There’s a number of these, and in this article we’ll focus on a particular

function that has received quite a bit of attention, and is used in pretty much anything

that can draw curves: ”Bezier” curves

They’re named after Pierre Bezier, who is principally responsible for getting them

known to the world as a curve well-suited for design work (working for Renault and

publishing his investigations in 1962), although he was not the first, or only one, to

”invent” these type of curves. One might be tempted to say that the mathematician

Paul de Casteljau was first, investigating the nature of these curves in 1959 while

working at Citroen, coming up with a really elegant way of figuring out how to draw

them. However, de Casteljau did not publish his work, making the question ”who

was first” hard to answer in any absolute sense. Or is it? Bezier curves are, at their

core, ”Bernstein polynomials”, a family of mathematical functions investigated by

Sergei Natanovich Bernstein, with publications on them at least as far back as 1912.

Anyway, that’s mostly trivia, what you are more likely to care about is that these

curves are handy: you can link up multiple Bezier curves so that the combination

looks like a single curve. If you’ve ever drawn Photoshop ”paths” or worked with

vector drawing programs like Flash, Illustrator or nkscape, those curves you’ve been

drawing are Bezier curves.

So, what if you need to program them yourself? What are the pitfalls? How do you

draw them? What are the bounding boxes, how do you determine intersections, how

can you extrude a curve, in short: how do you do everything that you might want

when you do with these curves? That’s what this page is for. Prepare to be mathed!

1


2 Bernstein Polynomials

The Bernstein polynomials are an approximation to a given function over an interval

[a,b]. The values of the function are required over a set of evenly distributed points

in [a,b] rather than an arbitrarily distributed set used in the previous sections. This

seems, at first, to be a restriction that is not desirable. But as we shall learn, this

type of spline is very useful in creating or constructing smooth curves that conform to

a user-specified shape. These curves are called Bezier curves. So here we deal mainly

with methods and procedures for generating shapes rather than function approximations

to sets of data points.

Now,we introduce the Bernstein polynomials which are the foundation for building

Bezier curves. The Bernstein polynomials of degree n associated with function

y(x) on [a,b] is defined as:

B n (y, x) =

1

n∑

( ) n

(x − a) i (b − x) n−i y(x

(b − a) n i ) (1)

i

i=0

where ( n

i)

are the binomial coefficients and

x i = a + i b − a , n = 0, 1, 2, ..., n (2)

n

is an evenly distributed set of points in [a, b] generated by Equation (2) and not given

data values. Indeed,B n (y, x) is not an interpolating polynomial.

The Bernstein polynomials exhibit distinctly different behavior. They are polynomials

of degree n which vanish at the end points a and b.Over the entire interval[a,b],

B n (y, x) is a single function rather than a combination of piecewise functions. The

coefficients of the polynomials are the same for the entire interval. In contrast, in the

case of the polynomial splines and B-splines, the coefficients are generally different

from sub-interval to sub-interval.

Although B n (y, x) require values of y(x) over only a set of discrete points x i rather

than over the entire interval, the values y(x i ) are part of the coefficients. The polynomials

do not pass through externally supplied points (x i , y(x i )) . They are not splines

by definition.

In this section, the generated points x i are only dependent on the degree n once [a,b]is

set because positions x i vary according to Equation 2. The Bernstein polynomials

require different x i for different degree n, theny(x i ) is determined from a function

y(x). So strictly speaking, the function y(x) cannot be viewed as data as it could be

in dealing with interpolating polynomials or splines. A set of arbitrarily distributed

discrete data points will not satisfy the construction requirements of the Bernstein

polynomials. This appears to be a serious restriction, but as will be seen later, this

2


is not disadvantageous to our purpose.

One would then ask, what is the use of the Bernstein polynomials? The answer is

that the Bernstein polynomials are approximations to the function y(x). As we will

show later, when the degree increases, they converge uniformly to y(x) .

The values of a and b are not essential in the construction of the Bernstein polynomial.

For the sake of convenience,[a,b] is chosen as the interval of x. For instance, by

a simple linear transformation, any [a,b]can be transformed to [a,b] by introducing a

new independent variable z per the linear transformation

z = x − a

b − a

and

x = a + (b − a)z

Clearly,z ∈ [0, 1] for x ∈ [a, b] . Substituting z for x in the Bernstein polynomials,

we get

1

n∑

( ) n

B n (y, x) =

(b − a) i z i (b − x) n−i y(z

(b − a) n i )

i

where

=

n∑

i=0

i=0

z i = x i − a

b − a = i n ,

( n

i

)

z i (1 − z) n−i y(z i )

i = 0, 1, 2, ..., n

However to comply with common notation, we revert to x ∈ [0, 1] and use x from

here on, so the Bernstein polynomials are rewritten as

B n (y, x) =

1

n∑

( ) n

x i (1 − x) n−i y( 1 (b − a) n i n ) =

i=0

n∑

i=0

B n,i y( 1 ), x ∈ [0, 1] (3)

n

where B n,i are called the Bernstein basis polynomials and are defined as

( ) n

B n,i = x i (1 − x) n−i , i = 0, 1, 2, ..., n, x ∈ [0, 1]

i

Clearly, the coefficients of the Bernstein basis polynomials are dependent on n

and i and nothing else. There is no function y(x) in the basis formula; it appears in

the polynomial, Equation 3, where it is evaluated at points i/n , not in the basis. To

get a sense of the polynomials, lets first write all the Bernstein basis polynomials up

to degree n = 4 .

3


n = 0 : B 0,0 = 1

n = 1 : B 1,0 = 1 − x, B 1,1 = x

n = 2 : B 2,0 = (1 − x) 2 , B 2,1 = 2x(1 − x), B 2,2 = x 2

n = 3 : B 3,0 = (1 − x) 3 , B 3,1 = 3x(1 − x) 2 , B 3,2 = 3x 2 (1 − x), B 3,3 = x 3

n = 4 : B 4,0 = (1−x) 4 , B 4,1 = 4x(1−x) 3 , B 4,2 = 6x 2 (1−x) 2 , B 4,3 = 4x 3 (1−x), B 4,4 = x 4

For every degree n , there are n+1 basis polynomials which are the building blocks

for the Bernstein polynomials. Looking at these formulas, especially the coefficients,

one may recognize that they are familiar. In fact, recalling the expanded formula for

(a + b) n , the above expressions are for the casea = 1 − x and b = x .

basically,B n,i (x) are the individual terms of the expanded expression of[(1 − x) + x] n .

To make this even easier, the basis polynomials can be generated by recalling the

Pascal (Yang Hui, Khayam) Triangle

P ower

Coefficients

0 1

1 1 1

2 1 2 1

3 1 3 3 1

4 1 4 6 4 1

5 1 5 10 10 5 1

6 1 6 15 20 15 6 1

which provides the coefficients for powers of (1 − x) and x , respectively.

Example 1. For sure, we can write a program to calculate the formula directly. But

since we need it for any degree n , it is better to have a recursive algorithm. To do

this, we introduce the following equation:

B n,i = (1 − x)B n−1,i (x) + xB n−1,i−1 (x), i = 0, 1, 2, 3, ..., n − 1 (4)

where i = 0 and n are not included. Fori = 0 , the second term above would

requirei − 1 = −1 , which is not permitted. For i = n , the first term would require

i = n for degreen − 1 which is not permitted either.

4


(Note: in B p,q , p is always greater than q because for

binompq p ≥ q. ) For the i = 0 and i = n term, we have

B n,0 = (1 − x)B n−1,0 (x); B n,n = xB n−1,n−1 (x); (5)

where B n−1,0 and B n−1,n−1 are already obtained from the previous computational

cycle. To prove the recursive formula, we have

(1 − x)B n−1,i (x) + xB n−1,i−1 (x) =

(n − 1)!

i!(n − 1 − i)! xi (1 − x) n−i−1 (1 − x)+

(n − 1)!

(i − 1)!(n − 1 − i + 1)! xi−1 (1 − x) n−i−1 x

= x i (1−x) n−i (n − 1)!

[

i!(n − 1 − i)! + (n − 1)!

(i − 1)!(n − i)! ]

= x i (1 − x) n−i n!

i!(n − i)! [n − i

n + i n ]

= B n,i (x).

We wrote a recursive formula in MATLAB language for the obverse example(see

MATLAB Program(1)).

2.1 Building Bernstein Polynomials

Of course, one would note that [(1 − x) + x] n = 1 for all ns. Then from the binomial

theorem, for any given n , the summation of B n,i over all i is also exactly 1 .

n∑

B n,i (x) =

i=0

1

n∑

(b − a) n

i=0

( n

i

)

(x i (1 − x) n−i = [(1 − x) + x] n = 1

Thus, for the function y(x) = 1 , the Bernstein polynomial,B n (1, x) = ∑ n

i=0 B n(x).1 =

1, so that in this case Equation 3 matches the function y = 1 exactly. In general, (3)

only approximates a function y.

Differentiating the above equation, we get

0 =

1

n∑

( ) n

(x i−1 (1 − x) n−i−1 [i(1 − x) + (n − i)x] n

(b − a) n i

=

i=0

1

n∑

( ) n

(x i−1 (1 − x) n−i−1 [i − nx]

(b − a) n i

i=0

5


Multiplying by x(1 − x)/n , we get

n∑

i=0

n∑

i=0

( n

i

)

(x i (1 − x) n−i ( i n − x) = 0

( ) n

(x i (1 − x) n−i i n∑

( ) n

i n = x x i (1 − x) n−i = x

i

i=0

B n (x, x) = xB n (1, x) = x

which means for the function y(x) = x, the Bernstein polynomial is also exactly

the function itself.

Example 2. Prove that the Bernstein polynomialB n (y, x)is linear in regard to function

y.

Proof. For any constants a and b , and two functions f and g , we get

B n (af + bg, x) =

n∑

( n i )[af( i n ) + bg( i n )] = aB n(f, x) + bB n (g, x)

i=0

Then for any linear function y(x) = ax + b,we have

B n (y, x) = aB n (x, x) + bB n (1, x) = ax + b = y

which means the Bernstein polynomials for a linear function is also exactly the function

itself.

Could this be true for all polynomial functions? The answer is no. Lets considery

as a quadratic function, the simplest of which would be y(x) = x 2 . Differentiating

x = B n (x, x) we get

1 =

n∑

( n i )xi−1 (1 − x) n−i−1 (i − nx) i n

i=0

then multiplying by x(1−x)

n

=

n∑

i=0

x(1 − x)

n

=

n∑

i=0

( n

i

)

x i (1 − x) n−i ( i

n) 2

− x

( n

i

)

x i (1 − x) n−i ( i n − x) i n

6

n∑

i=0

( )

( )

n i

x i (1 − x) n−i

i n


= B n (x 2 , x) − xB n (x, x) = B n (x 2 , x) − x 2

So B n (x 2 , x) ≠ x 2 ,but rather it is an approximation to x 2 .And the error term is

‖B n (x 2 , x) − x 2 ‖ = ‖

x(1 − x)

‖ ≤ 1

n 4n

→ 0, as n → ∞

Generally, we have the following theorem stating that the Bernstein polynomials are

an approximation to the function y .

Theorem 1. (Weierstrass Theorem) If is continuous on[0, 1], then B n (y, x) converges

uniformly to y .

Please refer to Buchanan and Turner (1992) for the proof of this theorem. Lets

see how well Bernstein polynomials do in approximating a function.

Example 3. Evaluate the Bernstein polynomials for V sin 4x on [0,1]. A MATLAB

program is written for this example (see MATLAB Program(2) )

Figure 1: Evaluation of sin4x using the Bernstein polynomials

As can be seen in Figure 1, the Bernstein polynomials are not very good at

converging towards sin4x . Generally, this is true for all functions other than those

simple ones discussed above. Well, our interest here is to create the Bezier curve,

which is discussed in the following section, not particularly to approximate functions.

2.2 Bezier Curve

The Bezier curves are intended to develop shapes. For instance, if we view the curves

in Figure 1 as the generation of a sequence of shapes rather than an approximation to

7


a function, we might be satisfied with the results. Indeed, this is the objective of the

Bezier curves: the generation of shapes in design. Lets run (MATLAB Program(3))

First, we have four control points in this example Let the function be the linear spline

Figure 2: Bezier curves for polygons

i 1 2 3 4

x p 0.0 0.3 0.7 1.0

y p 0.1 0.6 0.8 0.2

Table 1

passing through these points. The shape of the function is then a polygon. This and

the resulting Bernstein polynomials for n = 3 to 6 are plotted in Figure 2a. It is clear

that these smooth curves converge towards the polygon. Beside the two endpoints,

these curves do not pass through the polygon.

The polygon is of a concave shape, and so are the curves. When the shape of the

8


polygon is convex, so are the curves as shown in Figure 2b. This conclusion is generally

true. These curves are called Bezier curves.

Lets move the second control point in Figure 2a to (0.3, 0.0). The resulting polygon

(Figure 2c) is convex at the beginning and concave near the end. The Bezier curves

also are convex at the beginning and concave near the end. Similar things happen

when the third control point in Figure 2d is changed to (0.7,0.8).

So by setting up several control points, the Bezier curves are created from the resulting

polygon. These curves have certain shapes like concave, convex or more generally

complicated. We are not interested in converging the Bezier curves to the polygon

by increasing the degree n. That would be very slow and unnecessary. Our interest

is to generate a smooth curve to our liking while n is relatively low. This process is

fast and easy to implement in a computer code. And this is the beauty of the Bezier

curve.

To further illustrate the essence and power of the Bezier curve, lets look at the

following example. It is more complex, but the code remains the same, other than

the control points.

Example 4. Create a smooth curve, which satisfying the following requirements

1. Must pass through endpoints (0,0) and (1,0.1);

2. Be convex and increase initially;

3. Be convex and decrease near the end;

4. Reach its maximum value of 0.6 near x = 0.6;

5. The maximum should be its only stationary point on [0,1].

For this example we design (MATLAB Program(4)).

As a first step, the following 7 points are selected as control points. The function y

is the linear spline across these points. Then the Bernstein polynomials of the orders

3 to 6 are plotted in Figure 3a.

i 1 2 3 4 5 6 7

x p 0.0 0.2 0.4 0.5 0.7 0.9 11

y p 0.0 -0.1 0.45 0.6 0.6 -0.1 0.1

Table 2

• The selection of points 1 and 7 are obvious. That is according to requirement

No.1 above and should be kept in all subsequent tries.

9


• Because of the requirements of the convexity of the curve near both ends, we

put y = −0.1 at x = 0.2 and 0.9.

Then, we put two points in the middle, (0.5, 0.6) and (0.7, 0.6), in trying to get the

curve to pass through (0.6, 0.6). The resulting curves (n = 3to 6), plotted in Figure

Figure 3: Bezier curves

3a, do not have a convex shape at the beginning for n = 3, but they do for higher

degrees. For n = 5 and 6, the curves decrease from zero. So we probably need to

raise the second control point a bit. Also, the high point of the curves only reach

y = 0.4, not 0.6 as required. This can be corrected by raising the 4 th and 5 th control

points.

Implementing these two changes in the second try, we get curves in Figure 3b. They

are better. The decrease of y at the beginning is eliminated. The high value of y is

raised from 0.4 to 0.55. Raising y at x = 0.5 and 0.7 further to 0.9 from 0.8, generates

the Bezier curves plotted in Figure 3c.

10


This time the curves are generally good. Lets use n = 6 for our final solution. The

only adjustment is to move the peak a bit lower and to the right. This is accomplished

by setting the two high control points to (0.52, 0.88) and (0.72, 0.88). The n = 6

curve in Figure 3d is pretty satisfactory with respect to all the requirements.

From this example, we can appreciate the flexibility and convenience of the Bezier

curves. Setting up the program is simple. It is easy to just have several control points

and move them around, or even deleting or adding new control points. These moves

do not require any change in the core of the code.

2.3 Bezier Curves with Closed Ends

So far we discussed the Bezier curves with open ends. Sometimes we would like

to generate a closed curve, or a curve having going back and forth on the x- axis.

Obviously the formula above does not permit this.

This problem is actually easy to fix. A dummy variable t is introduced and both x

and y are treated as functions of t . They can be written as

x(t) =

n∑

x i B n,i (t), y(t) =

i=0

n∑

y i B n,i (t)

i=0

For a closed or self-crossed curve, or more precisely, a closed or self-crossed polygon

from the control points chosen, we can start from any control point and let t = 0

there. Then chose a path to go through all the other points while t increases. Finally

we go back to the starting control point and use it again fort = 1 . This scheme

is a parametric representation of the curve, a very important concept in computer

graphics.

Example 5. Generate the infinity sign ∞ For this example we design (MATLAB

Program(5)) The plots in Figures 4(a), (b) and (c) illustrate Bezier curves for three

degrees:

• n = 7, 9, 11.

The control curves for each plot are given by the following data:

• Plot (a):

x p -1 -2/3 -1/3 1/3 2/3 1 2/3 1/3 -1/3 -2/3 -1

y p 0 2/3 2/3 -2/3 -2/3 0 2/3 2/3 -2/3 -2/3 0

Table 3

11


• Plot (b):

x p -1 -2/3 -1/3 1/2 1 3/2 1 1/2 -1/3 -2/3 -1

y p 0 1 1 -3/2 -3/2 0 3/2 3/2 -1 -1 0

Table 4

• Plot (c):

x p -0.8 -0.6 -1/4 1/2 1 3/2 1 1/2 -1/4 -0.6 -0.8

y p 0 0.9 0.9 -3/2 -3/2 0 3/2 3/2 -0.9 -0.9 0

Table 5

where xp,yp are the control points for the curves. Note: the control lines are not

shown for plots (b) and (c).

Figure 4: . Creating the infinite sign with the Bezier Curve

12


3 Bezier solutions of the wave equation

In this section, we study polynomial solutions in the Bezier form of the wave equation

in dimensions one and two. We explicitly determine which control points of the Bezier

solution at two different times fix the solution.

The usual approach to the search of solutions to the wave equation is to state a

Cauchy problem of the kind: To find a function verifying the wave equation with

initial conditions the value of the function at time t = 0 and the value at time St =

0S of its partial derivative with respect to the time.

3.1 Bezier solutions of the 1D-wave equation

If a string of uniform linear density is stretched to a uniform tension and if, in the

equilibrium position, the string coincides with the x-axis, then when the string is

disturbed slightly from its equilibrium position, the transverse displacement u(x, t)

satisfies an equation in which the second partial derivative of u with respect to x is

proportional to the second partial derivative with respect to t,

∂2u ∂2u

= c2 (6)

∂x2 ∂t 2

This is known as the one-dimensional wave equation. The usual approach is to state

a Cauchy problem of the kind: To find a function u(x, t) verifying Eq. 6 with initial

conditions u(x, 0) = u 0 (x) and ∂u(x,

0) = v ∂t 0(x).

Along this section we shall take c = 1 as the constant of proportionality. Then, the

1D-wave equation can be written as

∂2u

∂x − ∂2u

2 ∂t = 0 (7)

2

The only difference with the harmonic equation is a sign. So we can borrow the same

study we did for the harmonic Bezier surfaces in [1] and [5]. Moreover, we shall look

for solutions of Eq. 7 where not only for each t 0 the string u(x; t 0 ) is a Bezier curve,

but even the evolution along time of the string is of Bezier kind:

u(x, t) =

m,n

i,j=0

B m i (x)B n j (t)P ij , x, t ∈ [0, 1]

3.2 The 1D-wave equation in terms of the control points

A simple change of sign transforms the harmonic conditions into the 1D-wave conditions.

13


Theorem 2. Given a control net in R 3 ,{P ij } m,n

i,j=0 ,the associated Bezier surface,u :

[0, 1] × [0, 1] → R 3 ,is a solution of the 1D-wave equation if and only if for any

i ∈ {1, ..., m} and j ∈ {1, ..., n}.

P i+2,j a im +P i+1,j (b i−1,m −2a im )+P i−1,j (b i−1,m −2c i−2,m )+P i−2,j c i−2,m −P i,j+2 a jn −

P i,j+1 (b j−1,n −2a jn )−P i,j−1 (b j−1,n −2c j−2,n )−P i,j−2 c j−2,n +P ij ((a im −2b i−1,m +c i−2,m )

−(a jn − 2b j−1,n + c j−2,n )) = 0,

where, for i ∈ {1, ..., m − 2}.

a in = (n − i)(n − i − 1), b in = 2(i + 1)(n − i − 1), c in = (i + 1)(i + 2),

and a in = b in = c in = 0

otherwise.

Note that the equations in the statement of the Theorem can be understood as

generated by an adaptable mask.

The results obtained for harmonic Bezier surfaces indicate that given the first and

last rows of control points, all the other control points are determined. The same is

true for Bezier solutions of the 1D-wave equation.

For example, for m = n = 3, given P 00 , P 10 , P 20 , P 30 and P 03 , P 13 , P 23 , P 33 , the

other control points are determined by

P 01 = 1/3(4P 10 + 2P 13 − 2P 20 − P 23 ),

P 31 = 1/3(−2P 10 − P 13 + 4P 20 + 2P 23 ),

P 02 = 1/3(2P 10 + 4P 13 − P 20 − 2P 23 ),

P 32 = 1/3(−P 10 − 2P 13 + 2P 20 + 4P 23 ),

P 11 = 1/9(−4P 00 − 2P 03 + 12P 10 + 6P 13 − 2P 30 − P 33 ),

P 12 = 1/9(−2P 00 − 4P 03 + 6P 10 + 12P 13 − P 30 − 2P 33 ),

P 21 = 1/9(−2P 00 − P 03 + 12P 20 + 6P 23 − 4P 30 − 2P 33 ),

P 22 = 1/9(−P 00 − 2P 03 + 6P 20 + 12P 23 − 2P 30 − 4P 33 ).

Let us recall that {P i0 } m i=0 are the control points of the Bezier string at time t = 0

and {P in } m i=0 are the control points of the Bezier string at time t = 1. This gives us

a non usual approach to the wave equation. Instead of fixing the initial state of the

string and its first partial derivative with respect to the time we are fixing the initial

and final states of the string.

The next figure shows the solution of the 1D-wave equation as a two-dimensional

surface.

3.3 Computing the solutions of the 1D-wave conditions

We have seen that in low dimensions, the 1D-wave conditions imply that some of the

control points can be expressed as linear combinations of the other control points.

This is true for any dimension, i.e., the initial and final states fully determine the

14


Figure 5: A solution of the 1D-wave equation as a two-dimensional surface.

initial and final states are plotted thicker.

The

Bezier solution of the 1D-wave equation. We prove that for a square net for simplicity.

Proposition 3. Let u(x, t) = ∑ n

i,j=0 Bn i (x)Bj n (t)P ij be a Bezier solution of degree

n ≥ 2of the 1D-wave equation with control net {P ij } n i,j=0,then:

1. If n is odd, control points in the inner rows{P ij } n−1,n

i=1,j=0 are determined by the

control points in the first and last rows,{P 0j } n j=0 and{P nj } n j=0.

2. If n is even, control points in the inner rows{P ij } n−1,n

i=1,j=0and also the corner control

point P nn are determined by the control points in the first and last{P 0j } n j=0

and{P nj } n−1

j=0 . rows,

The analogous statement and proof for the harmonic case can be seen in [5]. We shall

include here the proof for the 1D-wave case for the sake of completeness and because

it gives some clues for what we will do later in the 2D case.

Proof. Let us consider the case n odd. Let us write the Bezier chart in the usual

basis of polynomials

n∑ A ij

u(x, t) =

i!j! xi t j ,

i,j=0

15


where A ij ∈ R 3 .

The 1D-wave equation (∂2 − ∂2 )u = 0can be translated into a system of linear

∂x 2 ∂t 2

equations in terms of the coefficients{A ij } n i,j=0

A i+2,j − A i,j+2 = 0

i, j = 0, ..., n

but with the convention A i+1,j = A i+2,j = A i,n+2 = A i,n+1 = 0

This means that any coefficient A ij with i > 1can be related with A i+2,j−2 and so on

until the second subindex is 0 or 1, or until the rst subindex is greater than n. In this

second case,A ij is directly 0. Indeed, if i + 2j > nthenb A i,2j = A i,2j+1 = 0, otherwise

A i,2j = A i+2j,0 , A i,2j+1 = A i+2j,1 , (8)

Note that the first and last rows of control points determine the starting and finnal

curves u(x, 0), u(x, 1), x ∈ [0, 1]. The first border curve is

and the second one is

u(x, 0)

u(x, 1) =

n∑

A i0 x i (9)

i=0

n∑ n∑

( A ij )x i (10)

i=0

From Eq. 8 we can obtain coefficients A i0 for i = 0, ..., n. Having in mind the

expression of u(x, t) in terms of Bernstein polynomials the formula of the change of

basis from the basis of Bernstein polynomials to the usual basis says us that

( ) n

A i0 = △ i0 P 00 , i = 0, 1, ..., n,

i

where △ i0 is the incremental operator. Thanks to Eq. 7, we can reduce Eq. 9

n∑

( ) n

= △ i0 P 0n , i = 0, 1, ..., n,

i

j=0

to just a system of linear equations involving the coefficients A i1 .

Moreover, the matrix of coefficients of this system is triangular and with the unit in

the diagonal entries. Therefore, the knowledge of the first and last rows of control

points, implies the knowledge of the coefficients A i0 and A i1 and then, the knowledge

of all the coefficients, i.e., of the whole solution u(x, t), or equivalently, of the whole

control net. For the even case, the arguments are similar.

16

j=0


4 Bezier solutions of the 2D-wave equation

If a thin elastic membrane of uniform areal density is stretched to a uniform tension

and if, in the equilibrium position, the membrane coincides with the xy-plane, then

the small transverse vibration u(x, y, t) of the point (x, y) of the membrane satisfies

an equation in which the two dimensional Laplacian of u is proportional to the second

partial derivative with respect to t,

( ∂2

∂x 2 + ∂2

∂t 2 )u = △u = c2 ∂2 u

∂t 2 .

This equation is called the two-dimensional wave equation.

As before, we shall assume that the constant of proportionality is c = 1. Then, the

2D-wave equation can be written as

(△ − ∂2

∂t 2 )u = 0

The operator △− ∂2

∂t 2 is sometimes called the D’Alembertian operator. It is the typical

example of hyperbolic operator. As in the previous section, we shall look for solutions

of Eq. 6 where not only for each t 0 the membrane u(x, y, t 0 ) is a Bezier surface, but

even the evolution along time of the membrane is of Bezier kind:

u(x, y, t) =

l,m,n

i,j,k=0

B l i(x)B m j (y)B n k (t) P ijk , x, y, t ∈ [0, 1] (11)

We shall call the set of control points {P ijk } l,m,n

i,j,k=0the control web.

4.1 The 2D-wave equation in terms of the control points

Theorem 4. Given a control web in R 3 , {P ijk } l,m,n

i,j,k=0

the associated Bezieru : [0, 1] ×

[0, 1] × [0, 1] → R 3 ,s a solution of the 2D-wave equation if and only if for any

i ∈ {1, ..., l}, j ∈ {1, ...m}, andk ∈ {1, ..., n}

a il △ 200 P ijk + b i−1,l △ 200 P i−1,jk + c i−2,l △ 200 P i−2,jk

+ a jm △ 020 P ijk + b j−1,m △ 020 P i,j−1,k + c j−2,m △ 020 P i,j−2,k

− a kn △ 002 P ijk − b k−1,n △ 002 P ij,k−1 − c k−2,n △ 002 P ij,k−2 = 0 (12)

where, for i ∈ {0, ..., l − 2}

a in = (n − i)(n − i − 1), b in = 2(i + 1)(n − i − 1), c in = (i + 1)(i + 2), and a in =

b in = c in = 0 otherwise.

17


The proof is analogous to that of harmonic Bezier surfaces. To obtain a statement

similar to that of Th. 1 all it lacks to do is to expand the incremental operators.

4.2 A tricubical example

A study of Eqs. 12 for l = m = n = 3 shows that given the border control points of

the initial and final states (2 × 12) of the Bezier membrane, the other control points

(4 + 16 + 16 + 4) of the whole control web are determined. In the next Figure the

independent border control points of the initial and final states are plotted thicker.

Figure 6: Left n = 2. Right n = 3.

The Figure 8 shows six states of the evolution of a solution for the 2D-wave

equation with border control points (the black ones) in the initial and nal states as

follows in Figure 7,

Figure 7: the initial and final states.

18


Figure 8: solution for the 2D-wave equation with border control points.

4.3 Computing the solutions of the 2D-wave conditions

To solve in general Eqs.(12) for degrees other than 2 and 3 is a difficult task even for

a symbolic computation program. In order to do that, it is better to come back to

the usual basis of polynomials.

Lemma 5. Let f(x, y, t) = ∑ n a i,j,k

i,j,k i!j!k! xi y j t k be a polynomial solution of degree n ≥ 2

of the 2D-wave equation, then, all coefficients{a ijk } n i,j=0,k=2 are totally determined by

the coefficients {a ij0 , a ij1 } n i,j=0 moreover these two sets of coefficients verify if n = 2p

that

p∑

r=0

( p

r)

a i+2r,j+2(p−r),1 = 0 ,

and if n = 2p − 1 that

p∑

( p

a i+2r,j+2(p−r),0 = 0 ,

r)

r=0

p+1

( ) p + 1

a i+2r,j+2(p+1−r),0 = 0

r

r=0

19

p∑

r=0

( p

r)

a i+2r,j+2(p−r),1 = 0


for i + j < n in both cases.

Proof. The 2D-wave condition f = 0can be translated into a system of linear equations

in terms of the coefficients {a ijk } n i,j,k=0

a i+2,j,k + a i,j+2,k − a i,j,k+2 = 0, (13)

for i, j, k = 0, ..., n, but with the convention a ijk = 0 if any of the indexes is greater

than n.

This means that any coefficient a ijk with k > 1 can be written as a ijk = a i+2,j,k−2 +

a i,j+2,k−2 and so on until the last subindex is 0 or 1,or until one of the first two

subindexes is greater than n. Indeed,

a i,j,2k =

k∑

r=0

( k

r)

a i+2r,j+2(k−r),0 , a i,j,2k+1 =

k∑

r=0

( k

r)

a i+2r,j+2(k−r),1 . (14)

Note that using relations (12) we can solve all the Eqs. 13 in terms of {a i,j,0 , a i,j,1 }

for k = 0, ..., n − 2, but not for k = n − 1, n. For these two values, Eqs. 13 are

for i, j = 0, ..., n, or, equivalently

a i+2,j,n−1 + a i,j+2,n−1 = 0,

a i+2,j,n + a i,j+2,n = 0,

a i,j,n+1 = a i,j,n+2 = 0,

and with relations (14) we get the expressions (11) for n even and (12) when n is odd.

Those are a set of relations between coefficients with last subindex 0 or 1. Moreover, it

can be seen that if i+j ≥ n then the corresponding equations identically vanishes.

Proposition 6. Let u(x, y, t) = ∑ l,m,n

i,j,k=0 Bl i(x)Bj m (y)Bk n(t) P ijk be a Bezier solution of

degree n of the 2D-wave equation with {P ijk } n i,j,k=0 as control web, then the control

points in the inner levels{P ijk } n,n−1

i,j=0,k=1

are determined by the control points in the

first and last rows,{P ij0 } n i,j=0 and {P ijn } n i,j=0. Moreover, there are also central control

points of the initial and final states which are determined by the other control points.

5 Conclusion

20


6 Appendix

Listing 1: MATLAB Program(1)

function b = bernstein_basis (n,xx)

% BERNSTEIN_BASIS Bernstein basis polynomials ;

% BERNSTEIN_BASIS returns values of Bernstein basis

% polynomials Bn ,i(xx),n >=1 at xx;

%b is a vector of length n+1, b(i +1) =Bn ,i(xx), i=0 ,1 ,.. ,n;

if ( (xx <0.0) | (xx >1.0) );

error ('xx out of range in function " bernstein_basis "!')

;

end ;

xx_1 =1.0 - xx;

b =1: n +1; % index shifted from [0,n] to [1,n +1];

for i =1: n; % starting from B_1 ,1, build Bn ,i from Bn -1,i;

b(i +1) =xx*b(i);

for j=i -1: -1:1;

b(j +1) = xx_1 *b(j +1) +xx*b(j);

end ;

b (1) = xx_1 *b (1) ;

end ;

Listing 2: MATLAB Program(2)

x= linspace (0.0 ,1.0 , n1); % evenly distributed points on

[0 ,1]

plot (x,sin (4.0* x),'k -+ '); % First , plot the function sin4x

on [0 ,1].

hold ;

for n =2:6; % n is the degree of Bernstein polynomials

np1 =n +1; % for every n, there are n+1 data pts and

basis polynomials

x1= linspace (0.0 ,1.0 , np1 ); % MUST be evenly distributed

pts .

y1= fuser (x1); % f(i/n)

21


for i =1: n1;

b1= bernstein_basis (n,x(i)); % Call function

bernstein_basis for degree n

y(i)=y1*b1 ';

end ;

% plot the Bernstein polynomials of various degrees

if n ==2;

plot (x,y,'k-o');

elseif n ==3;

plot (x,y,'k--');

elseif n ==4;

plot (x,y,'k -. ');

elseif n ==5;

plot (x,y,'k:');

elseif n ==6;

plot (x,y,'k-');

end ;

end ;

legend ('sin4x ','B_2 ( sin4x ;x)','B_3 ( sin4x ;x)','B_4 ( sin4x ;x)

', ...

'B_5 ( sin4x ;x)','B_6 ( sin4x ;x)' ,0);

xlabel ('x'), ylabel ('y'),title ('Evaluation of B_n ( sin4x ;x)

');

grid ;

function f= fuser (x)

f= sin (4* x);

% *****************************************************

Listing 3: MATLAB Program(3)

function

bezier_example_1

% Define control points to change shape of Bezier curves

for iexample =1:4;

if iexample ==1;

22


xp =[0.0 0.3 0.7 1.0];

yp =[0.1 0.6 0.8 0.2];

itfig =1;

elseif iexample ==2;

xp =[0.0 0.3 0.7 1.0];

yp =[0.8 0.2 0.4 0.9];

itfig =2;

elseif iexample ==3;

xp =[0.0 0.3 0.7 1.0];

yp =[0.1 0.0 0.8 0.2];

itfig =3;

elseif iexample ==4;

xp =[0.0 0.3 0.7 1.0];

yp =[0.8 0.2 0.8 0.9];

itfig =4;

end ;

subplot (2 ,2 , itfig );

n2 =41;

x= linspace (0.0 ,1.0 , n2); % Use n2 = 41 evenly

distributed points on [0 ,1]

for n =3:6; % n is the degree of Bernstein polynomials

np1 =n +1; % for every n, there are n+1 data pts and

basis polynomials

x1= linspace (0.0 ,1.0 , np1 ); % MUST be evenly

distributed pts .

y1= linear_spline_2 (xp ,yp ,x1); % y is a linear spline

passing through these points

for i =1: n2; % loop for the 41 evenly distributed

points

xx=x(i);

b1= bernstein_basis (n,xx); % Call function

bernstein_basis at each point

y(i)=y1*b1 ';

end ;

% plot the Bernstein polynomials of various degrees

if n ==3;

23


plot (x,y,'k'); hold ;

elseif n ==4;

plot (x,y,'k--');

elseif n ==5;

plot (x,y,'k -. ');

elseif n ==6;

plot (x,y,'k:');

end ;

end ;

% Plot the polygon and control points

np= length (xp) -1;

for i =1: np +1;

plot (xp(i),yp(i),'ko ');

if i<np +1;

xp1 =[ xp(i) xp(i +1) ];

yp1 =[ yp(i) yp(i +1) ];

plot (xp1 ,yp1 ,'k');

end ;

end ;

if iexample ==1;

text (0.02 ,0.75 , '(a)');

elseif iexample ==2;

text (0.02 ,0.95 , '(b)');

elseif iexample ==3;

text (0.02 ,0.75 , '(c)');

elseif iexample ==4;

text (0.02 ,0.95 , '(d)');

legend ('n=3 ','n=4 ','n=5 ','n=6 ' ,4);

end ;

xlabel ('x'); ylabel ('y'); grid ;

end ;

Listing 4: MATLAB Program(4)

function

bezier_example_2

% Define control points to change shape of Bezier curves

24


for iexample =1:4;

if iexample ==1;

xp =[0.0 0.2 0.40 0.5 0.7 0.9 1.0];

yp =[0.0 -0.1 0.45 0.6 0.6 -0.1 0.1];

itfig =1;

elseif iexample ==2;

xp =[0.0 0.2 0.40 0.5 0.7 0.9 1.0];

yp =[0.0 0.0 0.45 0.8 0.8 -0.1 0.1];

itfig =2;

elseif iexample ==3;

xp =[0.0 0.2 0.40 0.5 0.7 0.9 1.0];

yp =[0.0 0.0 0.45 0.9 0.9 -0.1 0.1];

itfig =3;

elseif iexample ==4;

xp =[0.0 0.2 0.40 0.52 0.72 0.9 1.0];

yp =[0.0 0.0 0.45 0.88 0.88 -0.1 0.1];

itfig =4;

end ;

subplot (2 ,2 , itfig );

n2 =41;

x= linspace (0.0 ,1.0 , n2); % Use n2 = 41 evenly

distributed points on [0 ,1]

for n =3:6; % n is the degree of Bernstein polynomials

np1 =n +1; % for every n, there are n+1 data pts and

basis polynomials

x1= linspace (0.0 ,1.0 , np1 ); % MUST be evenly

distributed pts .

y1= linear_spline_2 (xp ,yp ,x1); % y is a linear spline

passing through these points

for i =1: n2; % loop for the 41 evenly distributed

points

xx=x(i);

b1= bernstein_basis (n,xx); % Call function

bernstein_basis at each point

y(i)=y1*b1 ';

end ;

25


% plot the Bernstein polynomials of various degrees

if n ==3;

plot (x,y,'k');

hold ;

elseif n ==4;

plot (x,y,'k--');

elseif n ==5;

plot (x,y,'k -. ');

elseif n ==6;

plot (x,y,'k:');

end ;

end ;

% Plot the polygon and control points

np= length (xp) -1;

for i =1: np +1;

plot (xp(i),yp(i),'ko ');

if i<np +1;

xp1 =[ xp(i) xp(i +1) ];

yp1 =[ yp(i) yp(i +1) ];

plot (xp1 ,yp1 ,'k');

end ;

end ;

axis ([0 1 -0.5 1]) ;

if iexample ==1;

text (0.9 ,0.9 , '(a)');

legend ('n=3 ','n=4 ','n=5 ','n=6 ' ,2);

elseif iexample ==2;

text (0.9 ,0.9 , '(b)');

elseif iexample ==3;

text (0.9 ,0.9 , '(c)');

elseif iexample ==4;

text (0.9 ,0.9 , '(d)');

end ;

xlabel ('x'); ylabel ('y'); grid ;

end ;

Listing 5: MATLAB Program(5)

26


function

bezier_example_3

% Define control points to change shape of Bezier curves

a13 =1.0/3.0;

a23 =2.0/3.0;

for iexample =1:3;

if iexample ==1;

xp =[ -1.0 -a23 -a13 a13 a23 1.0 a23 a13 -a13 -a23

-1.0];

yp =[ 0.0 a23 a23 -a23 -a23 0.0 a23 a23 -a23 -a23

0.0];

elseif iexample ==2;

xp =[ -1.0 -a23 -a13 0.5 1.0 1.5 1.0 0.5 -a13 -a23

-1.0];

yp =[ 0.0 1.0 1.0 -1.5 -1.5 0.0 1.5 1.5 -1.0 -1.0

0.0];

elseif iexample ==3;

xp =[ -0.8 -0.6 -0.25 0.5 1.0 1.5 1.0 0.5 -0.25 -0.6

-0.8];

yp =[ 0.0 0.9 0.9 -1.5 -1.5 0.0 1.5 1.5 -0.9 -0.9

0.0];

end ;

subplot (2 ,2 , iexample );

np= length (xp) -1;

tp= linspace (0.0 ,1.0 , np +1) ; % MUST be evenly distributed

pts on interval [0 ,1]

% Define dummy variable t

n2 =41;

t= linspace (0.0 ,1.0 , n2);

% x and y defined as functions of t

x=t;

y=t;

for n =7:2:11; % n is the degree of Bernstein

polynomials

np1 =n +1; % for every n, there are n+1 data pts and

basis polynomials

27


t1= linspace (0.0 ,1.0 , np1 ); % MUST be evenly

distributed pts .

% Both x and y are interpolated using linear spline

at control points

x1= linear_spline_2 (tp ,xp ,t1);

y1= linear_spline_2 (tp ,yp ,t1);

for i =1: n2; % loop for the 41 evenly distributed

points

tt=t(i);

b1= bernstein_basis (n,tt); % Call function

bernstein_basis at each t

x(i)=x1*b1 ';

y(i)=y1*b1 ';

end ;

% plot the Bernstein polynomials of various degrees

if n ==7;

plot (x,y,'k'); hold ;

elseif n ==9;

plot (x,y,'k--');

elseif n ==11;

plot (x,y,'k -. ');

elseif n ==13;

plot (x,y,'k:');

end ;

end ;

if iexample ==1;

for i =1: np +1;

title ('Bezier Curve ');

plot (xp(i),yp(i),'ko ');

if i<np +1;

b1 =[ xp(i) xp(i +1) ];

c1 =[ yp(i) yp(i +1) ];

plot (b1 ,c1 ,'k');

end ;

end ;

elseif iexample ==2;

legend ('n=7 ','n=9 ','n =11 ' ,0);

28


end ;

xlabel ('x'); ylabel ('y'); grid ;

end ;

29


References

Cheney, W. and Kincaid, D., Numerical Mathematics and Computing, Third

Edition, Brooks/Cole Publishing Company, 1994.

Buchanan, J.L. and Turner, P.R., Numerical Methods and Analysis, McGraw-Hill,

1992.

Beltran, J. V., and Juan Monterde. ”Bezier solutions of the wave equation.” International

Conference on Computational Science and Its Applications. Springer,

Berlin, Heidelberg, 2004.

Ansari, D and Huang, K.-W. Non-parametric dominant point detection, Pattern

Recognition 24(9), 1991.

30

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!