cise, uf - ashish mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · curve (degree d): d t ......

20
 B(asis)-Splines Ashish Myles CISE, UF

Upload: lydang

Post on 15-Apr-2018

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

B(asis)­Splines

Ashish MylesCISE, UF

Page 2: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Splines

● Piecewise polynomial● More flexible than 

single polynomials– can have finite 

support– can be periodic

● Degree d splines – typically Cd­1  continuity

Page 3: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Some polynomial representations

● Polynomials– Power / Taylor series– Newton polynomials– Lagrange polynomials– Hermite polynomials

– Bézier (very special case of B­spline)

● Splines– Box spline (for curves, same as uniform B­spline)

– B­spline

Page 4: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

B­spline examples● http://www.cs.technion.ac.il/~cs234325/Applets/applets/bspline/GermanApplet.html

● http://www.engin.umd.umich.edu/CIS/course.des/cis577/projects/BSP/welcome.html

● http://www.cs.uwaterloo.ca/~r3fraser/splines/bspline.html

● http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/BSplines.html

coefficients

controlpolygon

Page 5: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Polynomials as linear combinations● Power basis 

● Taylor basis 

● Bézier basis 

p t = ∑i=0

dci di 1−td−it i

{1, t ,t2 , ... , td }

{1,t−t0 ,t−t02 ,... ,t−t0

d }

{1−t d , d 1−t d−1t , ... , di 1−t d−it i ,... , td }terms in the binomial expansion of 1−t t d =1

p t = ∑i=0

dcit−t0

i

p t = ∑i=0

dcit

i

Page 6: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Splines as linear combinations

● A linear combination of spline basis functions

● Defined by

– k knots ti 

● non­decreasing sequence specifying domain● determines basis functions (hence continuity and ranges)

– n coefficients ci 

● coefficients with which the basis functions are multiplied

– degree d automatically determined: k = n + d + 1

Page 7: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

B­spline basis

● Basis function:

0

1

deg 1 deg 2 deg 3­1      0        1       2       3 ­1   0    1    2    3    4 ­1  0  1   2   3  4   5

● Non­neg. & finite support

● Shifts add up to 1 in their overlap

● (Uniform B­splines <=> uniformly spaced knots)

Ni0t = {1 if t∈[t i ,t i1]

0 otherwise

Nidt =

t−t it id−t i

N id−1

t t id1−t

t id1−t i1

N i1d−1

t

deg 0­1        0         1         2

Page 8: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

controlpolygon

Spline in B­spline formp t =∑i

ciN idt ● Curve (degree d):

● Example: ci = [1, 3, 2, -1]   (y­coord only)

● Greville abscissa:    natural x­coord for c

● k = n + d + 1  knots

deg 2 deg 3

ti* =

1d∑ j=i1

idt j

Page 9: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

    9

controlpolygon

Geometric Propertiesp t =∑i

ciN idt ● Curve (degree d):

● Affine invariance: ci' = A(c

i)  <=>  p'(t) = A(p(t))

● Convex hull property: curve lies within CH(ci)

deg 2 deg 3

sum to 1,non­negative

Page 10: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Variation diminishing property

● No line intersects the spline more times than it intersects the control polygon.

● i.e. The curve will not wiggle more than the control polygon.

Page 11: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

An alternative to interpolation

● Interpolating samples suffers from the Gibb's phenomenon

● Treating samples as coefficients has no such problems – curve can't wiggle more than coefficients.

Page 12: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Examples of non­uniform splines

● Knot sequence can be denser in areas needing more degrees of freedom.

Page 13: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Decreasing inherent continuity● Knot multiplicity

– Repeating a knot m times decreases the inherent continuity of the basis functionsacross the knot to Cd­m  

Degree d = 3.Same control points in all cases.

Knot sequence is uniform except for multiplicity at t = 7.

uniform

mult 2

mult 3

mult 4

Page 14: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Evaluation – deBoor's Algorithm● Evaluate at t = 4.5 by repeated knot insertion without changing 

the underlying function.single knotat t = 4.5

double knotat t = 4.5

triple knotat t = 4.5

Page 15: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Convergence under knot insertion● Repeated uniform knot insertion converges to function as fast 

as O(h2), with h = knot width.

Page 16: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Derivatives

● Compute using divided differences – deg 1 lower– continuity 1 lower– domain the same

p t = ∑iciN i

d t

p ' t = ∑iaiN i

d−1t

ai =d

t id1−t i1ci1−ci

Page 17: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Matlab spline toolbox

● Written by deBoor himself● I used for my figures:

– spmak, spapi – create/interpolate a B­spline– fnplt – plot the B­spline– fnrfn – do knot insertion– fnder, fnint – differentiation and integration

● It's well documented and comes with tutorials and demos

Page 18: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

Summary

● The B­spline form is– geometrically intuitive– numerically robust– easy to differentiate– easy to make discontinuous– very, very knotty

● Matlab spline toolbox

Page 19: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

More terms to look up

● Tensor­product B­splines– for surfaces, volumes

● Bézier– tensor­product (special case of B­splines)– total­degree (triangular) – no good B­spline 

equivalent

● Blossoms– Excellent theoretical tool– Inefficient for implementation, though

Page 20: CISE, UF - Ashish Mylesashishmyles.com/tutorials/bsplines/bsplines.pdf · Curve (degree d): d t ... Matlab spline toolbox ... – spmak, spapi – create/interpolate a Bspline –

   

References

● Curves and Surfaces for CAGD– Gerald Farin

● Bézier and B­Spline Techniques– Hartmut Prautzsch, Wolfgang Boehm, and Marco 

Paluszny

● Matlab spline toolbox documentation & demos