Professional Documents
Culture Documents
Outline
Hermite Splines
Catmull-Rom Splines
Bezier Curves
Higher Continuity: Natural and B-Splines
Drawing Splines
Curve Representations
Explicit: y = f(x)
y
y = mx + b
Easy to generate points
Must be a function: big limitationvertical lines?
Curve Representations
Explicit: y = f(x)
y
y = mx + b
Easy to generate points
Must be a function: big limitationvertical lines?
x
y
Implicit: f(x,y) = 0
x2 + y 2 ! r 2 = 0
+Easy to test if on the curve
Hard to generate points
Curve Representations
Explicit: y = f(x)
y
y = mx + b
+ Easy to generate points
Must be a function: big limitationvertical lines?
x
y
Implicit: f(x,y) = 0
2
u="/2
x + y !r = 0
u= "
u=0
x
Parameterization of a Curve
Parameterization of a curve: how a change in u moves
you along a given curve in xyz space.
There are an infinite number of parameterizations of a
given curve. Slow, fast, speed continuous or
discontinuous, clockwise (CW) or CCW
Polynomial Interpolation
An n-th degree polynomial fits a curve to n+1 points
called Lagrange Interpolation
result is a curve that is too wiggly, change to any control point
affects entire curve (nonlocal) this method is poor
Linear Interpolation
Chalkboard
Spline Interpolation
Spine Interpolation
Demo
10
Piecewise Polynomials
Spline: lots of little polynomials pieced together
Want to make sure they fit together nicely
Continuous in
position
Continuous in
position and tangent
vector
11
Continuous in
position, tangent,
and curvature
Splines
Types of splines:
Hermite Splines
Catmull-Rom Splines
Bezier Splines
Natural Cubic Splines
B-Splines
NURBS
12
Hermite Curves
Cubic Hermite Splines
P2
P1
Po
That is, we want a way to specify the end points and the
slope at the end points!
7
Splines
chalkboard
13
p(u) = u3 u2
point that
gets drawn
&2
$ "3
u 1$
$0
$
%1
"2 1 1 # & p1 #
3 "2 "1!! $$ p2 !!
0 1 0 ! $ !p1 !
!$ !
0 0 0 " %!p2 "
basis
control matrix
(what the user gets to pick)
p(u) = u3 u2
point that
gets drawn
&2
$ "3
u 1$
$0
$
%1
"2 1 1 # & p1 #
3 "2 "1!! $$ p2 !!
0 1 0 ! $ !p1 !
!$ !
0 0 0 " %!p2 "
basis
control matrix
(what the user gets to pick)
4 Basis Functions
4 Basis Functions
gives C1 continuity
The points that the curve has to pass through are called
knots or knot points
17
Outline
Hermite Splines
Catmull-Rom Splines
Bezier Curves
Higher Continuity: Natural and B-Splines
Drawing Splines
Catmull-Rom Splines
Use for the roller-coaster assignment
With Hermite splines, the designer must specify all the
tangent vectors
Catmull-Rom: an interpolating cubic spline with builtin C1 continuity.
P2
P1
tangent at pi = s(pi+1 - pi-1)
Po
Catmull-Rom Splines
Use for the roller-coaster (next programming
assignment)
With Hermite splines, the designer must arrange for
consecutive tangents to be collinear, to get C1
continuity. This gets tedious.
Catmull-Rom: an interpolating cubic spline with builtin C1 continuity.
chalkboard
18
p(u) = u3 u2
& ! s 2! s s !2
$ 2s s !3 3!2s
u 1$
$ !s 0
s
$
0
%0 1
spline coefficients
CR basis
s # & p1 #
$ !
! s!! $ p2 !
0 ! $ p3 !
!$ !
0 " % p4 "
control vector
19
spline coefficients
CR basis
20
s # & x1
$
! s !! $ x2
0 ! $ x3
!$
0 " % x4
y1 z1 #
y2 z 2 !!
y3 z 3 !
!
y4 z 4 "
control vector
Catmull-Rom Splines
Use for the roller-coaster assignment
With Hermite splines, the designer must specify all the
tangent vectors
Catmull-Rom: an interpolating cubic spline with builtin C1 continuity.
p(u) = u3 u2
& ! s 2! s s !2
$ 2s s !3 3!2s
u 1$
$ !s 0
s
$
0
%0 1
CR basis
s # & p1 #
$ !
! s!! $ p2 !
0 ! $ p3 !
!$ !
0 " % p4 "
control vector
10
Cubic Curves in 3D
Three cubic polynomials, one for each coordinate
x(u) = axu3+bxu2+cxu+dx
y(u) = ayu3+byu2+cyu+dy
z(u) = azu3+bzu2+czu+dz
In matrix notation
[x(u )
y (u ) z (u )] = u 3 u 2
&ax
$b
x
$
u 1
$ cx
$d
% x
11
ay
by
cy
dy
az #
bz !
!
cz !
d z !"
CR basis
12
s # & x1
$x
!
! s! $ 2
0 ! $ x3
!$
0 " % x4
y1 z1 #
!
y2 z 2 !
y3 z 3 !
!
y4 z 4 "
control vector
Outline
Hermite Splines
Catmull-Rom Splines
Bezier Curves
Higher Continuity: Natural and B-Splines
Drawing Splines
Problem with
Catmull-Rom Splines?
No control of derivatives at endpoints!
How can we solve this?
We want something intuitive.
Bezier Curves*
Another variant of the same game
Instead of endpoints and tangents, four control points
P(u=1) = P3
13
3 ! 3 1 # & x1
$x
!
! 6 3 0! $ 2
3 0 0! $ x3
!$
0 0 0 " % x4
Bezier basis
14
y1 z1 #
y2 z 2 !!
y3 z 3 !
!
y4 z4 "
Bezier
control vector
Outline
Hermite Splines
Catmull-Rom Splines
Bezier Curves
Higher Continuity: Natural and B-Splines
Drawing Splines
Piecewise Polynomials
Spline: lots of little polynomials pieced together
Want to make sure they fit together nicely
Continuous in
position
Continuous in
position and tangent
vector
16
Continuous in
position, tangent,
and curvature
17
Local Control
Hermite
YES
Bezier
YES
Catmull-Rom YES
Natural
NO
B-Splines
YES
Continuity
Interpolation
C1
C1
C1
C2
C2
YES
YES
YES
YES
NO
Summary
Cant get C2, interpolation and local control with cubics
18
19
B-Splines*
Give up interpolation
the curve passes near the control points
best generated with interactive placement (because its
hard to guess where the curve will go)
20
B-Spline Basis*
We always need 3 more control points than spline
pieces
& !1 3 ! 3
$ 3 !6 3
1$
MBs =
3
6 $! 3 0
$
4
1
%1
& Pi ! 3 #
$ Pi ! 2 !
!
GBsi = $
$ Pi ! 1 !
!
$
% Pi "
21
1#
!
0!
0!
!
0"
Outline
Hermite Splines
Catmull-Rom Splines
Bezier Curves
Higher Continuity: Natural and B-Splines
Drawing Splines
&! s 2 ! s s ! 2
$2s s ! 3 3 ! 2s
[x y z ] = u 3 u 2 u 1 $
$! s 0
s
$
1
0
%0
CR basis
22
s # & x1
$x
!
! s! $ 2
0 ! $ x3
!$
0 " % x4
y1 z1 #
!
y2 z 2 !
y3 z 3 !
!
y4 z 4 "
control vector
23
Drawing Splines, 2
Method 2: recursive subdivision - vary step size to draw short lines
Subdivide(u0,u1,maxlinelength)
umid = (u0 + u1)/2
x0 = P(u0)
x1 = P(u1)
if |x1 - x0| > maxlinelength
Subdivide(u0,umid,maxlinelength)
Subdivide(umid,u1,maxlinelength)
else drawline(x0,x1)
24
In Summary...
Summary:
Things to know:
basic curve properties (what are the conditions, controls, and properties for
each spline type)
generic matrix formula for uniform cubic splines x(u) = uBG
given definition derive a basis matrix
25