You are on page 1of 32

Splines and Bezier Curves

Introduction
RepresentingCurves
Anumberofsmalllinesegmentsjoined

Interpolation
Parametricequations
Typesofcurvewestudy
NaturalCubicSplinesandBezierCurves
Derivation
Implementation

Computers cant draw curves.

The more points/line


segments that are used,
the
smoother
the
curve.

Why have curves ?


Representation of irregular surfaces
Example: Auto industry (car body design)

Artists representation
Clay / wood models
Digitizing
Surface modeling (body in white)
Scaling and smoothening
Tool and die Manufacturing

Curve representation
Problem: How to represent a curve easily
and efficiently
Brute force and ignorance approaches:
storing a curve as many small straight line
segments
doesnt work well when scaled
inconvenient to have to specify so many points
need lots of points to make the curve look smooth

working out the equation that represents the curve


difficult for complex curves
moving an individual point requires re-calculation of the
entire curve

Solution - Interpolation
Define a small number of
points
Use a technique called
interpolation to invent the
extra points for us.
Join the points with a series of
(short) straight lines

Requirements

Want mathematical smoothness

Local control

Local data changes have local effect

Continuous with respect to the data

Some number of continuous derivatives of P

No wiggling if data changes slightly

Low computational effort

A solution
Use SEVERAL polynomials
Complete curve consists of several pieces
All pieces are of low order
Third order is the most common

Pieces join smoothly


This is the idea of spline curves
or just splines

Parametric Equations - linear


P1

x1,y1
(13,8)

(7.5,4)
P0
x0 ,y0
(2,3)

dx

dy

Walk from P0 to P1 at a
constant speed.
Start from P0 at t=0
Arrive at P1 at t=1
dx = x1 - x0
dy = y1 - y0
Where are you at a general
time t?

Equation(s) of a straight
line as a function of an x(t) = x0 + t.dx
arbitrary parameter t.
y(t) = y0 + t.dy

Why use parametric equations?


One, two, three or
representation is possible

n-dimensional

Can handle infinite slope of tangents


Can represent multi-valued functions

For this class


Natural Cubic Spline
Bezier Curves

Splines
Define the knots
(x0,y0) - (x3,y3)

Calculate all other points

spline
knots

Splines - History
Draftsman use ducks and
strips of wood (splines) to
draw curves
And pass through the control
points

A Duck (weight)

Ducks trace out curve

Interpolation versus Approximation


V6

V0

V5

V1

Interpolation

V3
V4

V2

Approximation

V4

V3

V0
V6
V1

V2

V5

Hermite Spline
Say the user provides x0 , x1 , x0 , x1
A cubic spline has degree 3, and is of the form:
x at 3 bt 2 ct d
For some constants a, b, c and d derived from the control
points, but how?

We have constraints:

The curve must pass through x0 when t=0


The derivative must be x0 when t=0
The curve must pass through x1 when t=1
The derivative must be x1 when t=1

Hermite Spline
A Hermite spline is a curve for which the user provides:
The endpoints of the curve
The parametric derivatives of the curve at the endpoints
The parametric derivatives are dx/dt, dy/dt, dz/dt
That is enough to define a cubic Hermite spline, more
derivatives are required for higher order curves

Hermite Spline
Solving for the unknowns gives:
a 2 x1 2 x0 x1 x0
b 3x1 3x0 x1 2 x0
c x0
d x0

Rearranging gives:
x x1 ( 2t 3 3t 2 )
x0 ( 2t 3 3t 2 1)
x1 (t 3 t 2 )
x0 (t 3 2t 2 t )

or
x x1

x0

x1

2 3 0
2 3 0
x0
1 1 0

1 2 1

0 t 3

1 t 2

0 t

0 1

Basis Functions
A point on a Hermite curve is obtained by
multiplying each control point by some function
and summing
The functions are called basis functions
1.2

0.8

0.6

0.4

0.2

-0.2

-0.4

x1
x0
x'1
x'0

Bezier Curves
Analternativetosplines
M.BezierwasaFrenchmathematicianwhoworked
fortheRenaultmotorcarcompany.
He invented his curves to allow his firms
computerstodescribetheshapeofcarbodies.

Bezier Approximation
How to provide R1 and R4 ?
R1

P2

P3

R4

P4

P4
P1

P1

Instead of providing R1 and R4 , provide two additional control points ! ! !


P2 and P3
Approxi mation

Bezier curves
Typically, cubic polynomials
Similar to Hermite interpolation
Special way of specifying end tangents
Requires special set of coefficients

Need four points


Two at the ends of a segment
Two control tangent vectors

Bezier curves
Control polygon: control points connected to each
other

Easy to generalize to higher order


Insert more control points
Hermite third order only

Bezier Polynomial Function

n!
i
n i
Bin (t )
.t .(1 t )
i!(n i )!

Parametric equations for x(t),y(t)


n

x(t ) xi .Bin (t )
i 0
n

y (t ) yi .Bin (t )
i 0

Some Bezier Curves

Bezier Curves - properties


Not all of the control points are on the line
Some just attract it towards themselves
Points have influence over the course of the line
Influence (attraction) is calculated from a
polynomial expression

Convex Hull property


P2
P4

P1

P3

Bezier Curve Properties


Bezier curve always passes through the first and last
control points.
The degree of the polynomial defining the curve segment
is one less than the number of defining point.
The curve lies entirely within the convex hull of its control
points
The Bernstein polynomials (the basis functions) sum to 1 and are
everywhere positive

They can be rendered in many ways


E.g.: Convert to line segments with a subdivision algorithm

Disadvantages
The degree of the Bezier curve depends on the
number of control points.
The Bezier curve lacks local control. Changing
the position of one control point affects the entire
curve.

Bezier Surface

S u , v B (u ) B (v ) Pij
i 0 j 0

n
i

m
j

B-splines
Simple B - spline, n 1 points, degree d :
n

p(t ) N i ,d (t )p i , 0 t n d 1, with
i 0

N i ,d (t ) defined recursively :
N i ,0 (t ) 1

if i d t i d 1

0 otherwise
N i ,d (t )

(t i d ) N i ,d 1 (t )
d

(i 1 t ) N i 1,d 1 (t )
d

32

End Of Curves

You might also like