cubic spline interpolation€¦ · 120202: esm4a - numerical methods 363 visualization and computer...

19
120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation In the following, we want to derive the collocation matrix for cubic spline interpolation. • Let us assume that we have equidistant knots. To fulfill the Schoenberg-Whitney condition that N i n (u i ) 0 , for n=3 we set u i =i+2 for all i. The spline shall be given in B-spline representation, i.e., with n=3.

Upload: others

Post on 20-Apr-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 363

Visualization and Computer Graphics LabJacobs University

Cubic spline interpolation

• In the following, we want to derive the collocationmatrix for cubic spline interpolation.

• Let us assume that we have equidistant knots.• To fulfill the Schoenberg-Whitney condition that

Nin(ui) ≠ 0 , for n=3 we set ui=i+2 for all i.

• The spline shall be given in B-spline representation, i.e.,

with n=3.

Page 2: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 364

Visualization and Computer Graphics LabJacobs University

Cubic spline interpolation

• Cubic B-splines:

• For the collocation matrix, we need to evaluate the B-splines at the knots.

• Obviously, Ni3(uj) ≠ 0 only for j=i-1, j=i, and j=i+1.

• And, Ni3(ui-1) = Ni

3(ui+1).

Page 3: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 365

Visualization and Computer Graphics LabJacobs University

Cubic spline interpolation

• We use the de Boor algorithm to obtainNi

3(ui-1) = 1/6,Ni

3(ui) = 4/6, andNi

3(ui+1) = 1/6.(Exercise)

Page 4: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 366

Visualization and Computer Graphics LabJacobs University

Cubic spline interpolation• Putting it all together, we obtain the collocation matrix

• The matrix is sparse.• More precisely, it is a tridiagonal matrix.• The linear equation system can be solved efficiently

(see Section 2.3).• This is why we picked basis splines with minimal support.

Page 5: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 367

Visualization and Computer Graphics LabJacobs University

Affine invariance

• Looking at the first and the last row of thecollocation matrix, we observe that they do not sumup to one.

• Hence, the solution is not affinely invariant.• Affine invariance, however, is often desired,

especially in geometric modeling.• How can we fix it?

Page 6: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 368

Visualization and Computer Graphics LabJacobs University

Modified cubic spline interpolation

• One idea is to adjust the knot sequence, i.e., make itnon-equidistant at the endpoints.

• Suggestion: instead of knot sequence (2,3,4,5,…,m-1,m,m+1,m+2)use knot sequence (3,3½,4,5,…,m-1,m,m+½,m+1).

• Hence, for the collocation matrix, we need to evaluate the B-splines at values 3½ and m+½.

Page 7: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 369

Visualization and Computer Graphics LabJacobs University

Modified cubic spline interpolation• We have: N0

3(3½) = N33(3½) = 1/48,

N13(3½) = N2

3(3½) = 23/48.• The collocation matrix becomes

• Now all rows sum up to one (partition of unity of B-splines over [3,m-3]).

• The Schoenberg-Whitney condition is still satisfied.

Page 8: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 370

Visualization and Computer Graphics LabJacobs University

Example

• Given: points (p0, …, p4) = (1,2,2,0,1)knots (u0, …, u4) = (3,3½,4,4½,5)

• Collocation matrix:

• Solving for the control points.• Result: (c0, …, c4) = (5/3, 0, 13/3, -16/3, 23)

Page 9: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 371

Visualization and Computer Graphics LabJacobs University

Example• Scaling of

delivers

Page 10: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 372

Visualization and Computer Graphics LabJacobs University

Example• Summing of

delivers s(u)

Page 11: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 373

Visualization and Computer Graphics LabJacobs University

Example

• Interpolation is, of course, restricted to interval [3,5].• For example, at u=u0=3, we obtain:

s(u0) = s(3) = 5/3 • N03(3) + 0 • N1

3(3) + 13/3 • N23(3)

= 5/3 • 1/6 + 0 • 4/6 + 13/3 • 4/6 = 1 = c0

Page 12: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 374

Visualization and Computer Graphics LabJacobs University

Clamped cubic spline interpolation

• Clamped spline interpolation is another way to obtainaffine invariance.

• The idea is to only interpolate points pi at knots ui = i+2 for u1=3,…, um-1=m+1.

• In addition, we interpolate the derivatives at theendpoints u1 and um-1.

• I.e., we have additional interpolation conditionss‘(u1)= d1 and s‘(um-1)=dm-1.

Page 13: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 375

Visualization and Computer Graphics LabJacobs University

Clamped cubic spline interpolation• To do so, we need to compute s‘(u).• The derivative of a B-spline of degree n can be derived

to be

(Exercise).• Hence, we directly obtain

with

first backward differences

Page 14: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 376

Visualization and Computer Graphics LabJacobs University

Clamped cubic spline interpolation

• In order to fullfill s‘(u1) = d1, we have to look at theB-splines of degree 2.

• Recall:

• For our equidistant knots, we obtainN1

2(u1) = N22(u1) = ½

• Hence, s‘(u1) = ½ a1 + ½ a2

= ½ (c1 – c0) + ½ (c2 - c1) = ½ (– c0 + c2 )

Page 15: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 377

Visualization and Computer Graphics LabJacobs University

Clamped cubic spline interpolation

• The collocation matrix becomes

Page 16: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 378

Visualization and Computer Graphics LabJacobs University

Clamped cubic spline interpolation

• Clamped cubic spline:

Page 17: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 379

Visualization and Computer Graphics LabJacobs University

Periodic cubic spline interpolation

• For some applications, one is interested in periodicsplines, i.e., s(u) = s(u+m).

• This implies that ci+m = ci.• In particular, cm = c0 (and pm = p0).• We have the interpolation conditions

s(ui) = pi for i=0,…,m-1and s(um) = p0.

Page 18: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 380

Visualization and Computer Graphics LabJacobs University

Periodic cubic spline interpolation

• Collocation matrix:

Page 19: Cubic spline interpolation€¦ · 120202: ESM4A - Numerical Methods 363 Visualization and Computer Graphics Lab Jacobs University Cubic spline interpolation • In the following,

120202: ESM4A - Numerical Methods 381

Visualization and Computer Graphics LabJacobs University

Periodic cubic spline interpolation

• Periodic spline: