splines ii – interpolating curves
DESCRIPTION
Splines II – Interpolating Curves. based on: Michael Gleicher : Curves , chapter 15 in Fundamentals of Computer Graphics, 3 rd ed. (Shirley & Marschner ) Slides by Marc van Kreveld. Polynomial pieces. - PowerPoint PPT PresentationTRANSCRIPT
Splines II – Interpolating Curvesbased on:
Michael Gleicher: Curves, chapter 15 inFundamentals of Computer Graphics, 3rd ed.
(Shirley & Marschner)Slides by Marc van Kreveld
1
Polynomial pieces
n
i
iitt
0
af
m
iii tbt
0
cf
Canonical form of a polynomial of degree n defined with vector coefficients ai
Generalized form of a polynomial defined with vector coefficients ci that are blended by the m polynomials bi(t)
The degree is the max of the degrees of the bi(t)
Using blending polynomials is the way to make splines2
Recall: Basis and constraint matrices• Specifications of a curve give a constraint matrix
p0 = f(0) = a0 + 0 a1 + 02 a2 p1 = f(0.5) = a0 + 0.5 a1 + 0.52 a2 p2 = f(1) = a0 + 1 a1 + 12 a2
• Its inverse B = C–1 is the basis matrix
1110.250.51001
C (quadratic curve)
3
Blending functions
• Blending functions (or basis functions) are functions of u and specify how to “mix” the specified constraints (points to pass through, derivatives, …)
• Let u = [ 1 u u2 u3 … un ] be the powers of u• b(u) = u B, a vector whose elements are the blending
functions
4
Blending functions• u = [ 1 u u2 u3 … un ]• b(u) = u B so we obtain for the usual quadric example with
three points specified:
24-21-43-001
1CB
2
2
2
21
244231
24-21-43-001
1uuuuuu
uuuCuB
5
Blending functions
• We can now blend the control points
i
n
ii ubu pf
0
)()(
)()()(
244231
)(2
1
0
2
2
2
ububub
uuuuuu
b uBu
6
Blending functions
i
n
ii ubu pf
0)()(
)()()(
244231
)(2
1
0
2
2
2
ububub
uuuuuu
b uBu
22
12
02 244231 ppp )()()( uuuuuu
We see the contributions of each point depending on u
For fixed u, we linearly interpolate the three points7
Blending functions
22 2uuub )(
20 231 uuub )(
0 10.5
21 44 uuub )(
22
12
02 244231 ppp )()()( uuuuuu
u
1
8
Blending functions
• Note the sum of the contributions
22 210 uuub )(
20 231 uuub )(
21 440 uuub )(
1210 )()()( ububub+
9
Polynomials for interpolation
• Given points p = (p0, p1, … , pn) and increasing para-meter values t = (t0, t1, … , tn), we can make a poly-nomial of degree n that passes through pi exactly at parameter value ti so f(ti) = pi
p4
p3
p2p1
p0
p5
10
Polynomials for interpolation
• Given points p = (p0, p1, … , pn) and increasing para-meter values t = (t0, t1, … , tn), we can make a poly-nomial of degree n that passes through pi exactly at parameter value ti so f(ti) = pi
p4
p3
p2p1
p0
p5
the brown curve has t1’ > t1 and t4’ < t4 11
Polynomials for interpolation
• Method– Set up constraint matrix as before
• Invert to get basis matrix, giving the n+1 basis functions bi(t) and the polynomial f(t) :
• Alternative method (Lagrange form)
i
n
ii tbt pf
0
)()(
n
ijj ji
ji tt
tttb
,
)(0
12
Why not use polynomials to interpolate 5 or more points
• Polynomials of higher degree have– extra wiggles– overshoots
– non-locality: moving the point pn changes the curve even near p0 ; also when we add a point at the end
13
Why not use polynomials to interpolate 5 or more points
• This gets worse with higher degree (more points)
14
Blending again
• A piecewise-linear curve (polygonal line) can also be defined using blending functions
12
02 uub )(
)(ub0
0 10.5
)(ub1
u
1
0 u 0.5
0.5 u 1
p1
p2
p0
221100 pppf )()()()( ubububu 15
Piecewise cubic polynomials
• Allows position and derivative at each end• Allows C2 continuity• Are in a sense the most smooth curve: minimum
curvature over its length (curvature: second derivative)
curvature 0
curvature low
curvature high16
Cubic polynomials
• f(u) = a0 + a1 u + a2 u2 + a3 u3 in canonical form• Four control points (points or derivatives on curve)
needed• For piecewise cubic curves: n pieces require 4n
control points, but C0 continuity already fixes n – 1 of them
17
Cubic polynomials
• The ideal properties:– Each piece is cubic– The curve interpolates the control points– The curve has local control– The curve has C2 continuity
• We can have any three but not all four properties:– Natural cubics do not have local control– Cubic B-splines do not interpolate the control points– Cardinal splines are not C2
18
Natural cubics
• The first piece specifies start and end positions, and the first and second derivative at the start
• For each other piece, the position, first and second derivative match with the piece before it only the endpoint can be specified freely
• A curve with n pieces has n+3 control “points” in total (n+1 points and 2 derivative specifications)
p1 p2p0p3
19
Natural cubics
• We get (with f(u) = a0 + u a1 + u2 a2 + u3 a3):
p0 = f (0) = a0 + 0 a1 + 02 a2 + 03 a3 p1 = f’(0) = 1 a1 + 20 a2 + 302 a3 p2 = f’’(0) = 2 a2 + 60 a3 p3 = f (1) = a0 + 1 a1 + 12 a2 + 13 a3
1111020000100001
Cconstraint matrix
20
Natural cubics
• When you modify your natural cubic, for instance by changing the derivative at the start of the first piece, then the whole curve changes
not local
21
Hermite cubics
• Specifies positions of start and end, and the derivatives at these points
• C1 continuous since the start position of a piece must be the same as the end position of the previous piece, and the same is true for the derivatives
• A curve with n pieces has 2n+2 control “points” in total
p2
p0 p3
p1
22
Hermite cubics
• Local control: changing the position or derivative of any point influences only the piece before and the piece after that point
• See slides 34-35 of Curves I lecture
23
Cardinal cubics
• Specifies positions only; the derivatives at each point are determined by the points before and after it
• C1 continuous• A curve with n pieces has n+3 control points in total
p2
p0p3
p1
p0 p2p1 p3
24
Cardinal cubics
• A tension parameter t [0,1) determines the “strength” of bending
• Each derivative vector pi-1 pi+1 is scaled by (1 – t)/2
p2
p0 p3
p1p2
p0 p3
p1
t = 0 (Catmull-Rom splines) t = 0.525
Cardinal cubics
scaling factor related, not the tension t
???
26
Cardinal cubics
• We can set up the constraints:
f(0) = p1
f(1) = p2 f’(0) = ½ (1 – t) (p2 – p0)f’(1) = ½ (1 – t) (p3 – p1)
• Rewrite to get expressions for p0, p1, p2 and p3
• The first and last control points are not interpolated; no derivative would be specified
• Therefore, n pieces require n+3 points
p2
p0 p3
p1
27
Summary
• Piecewise cubic curves are popular for modeling• We want C2 continuity, locality, and interpolation;
we can get only two of these with cubics• Natural cubics do not have locality• Hermite cubics are only C1 continuous• Cardinal cubics are only C1 continuous
• The splines that follow next (Bezier and B-spline) will not interpolate but approximate the control points
28