Geometric Modeling Summer Semester 2010

Polynomial Curves Piecewise · Splines Bases · Properties Today...

Topics: • Mathematical Background • & Approximation • Spline Curves ƒ Piecewise Cubic Interpolation ƒ Splines with local control – Hermite Splines – Bezier Splines – Uniform B‐Splines – Non‐Uniform B‐Splines

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 2/ 116 Polynomial Spline Curves Piecewise Cubic Interpolation What we have so far...

What we have so far: • Given a basis, we can interpolate and approximate points ƒ Curves, surfaces, higher dimensional objects ƒ Functions (heightfields) and parametric objects ƒ Differential properties can be prescribed as well

Problem: • We need a suitable basis • Polynomial bases don’t work for large degree (say ≥ 10) ƒ Monomials – numerical nightmare ƒ Orthogonal polynomials: Runge’s phenomenon still limits applicability

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 4/ 116 Piecewise Polynomials

Key Idea: • Polynomials of high degree don’t work • Therefore: Use piecewise polynomials of low degree • What is a good degree to use?

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 5/ 116 Choosing the Degree...

Candidates:

• d = 0 (piecewise constant): not smooth

• d = 1 (piecewise linear): not smooth enough

• d = 2 (piecewise quadratic): constant 2nd derivative, still too inflexible

• d = 3 (piecewise cubic): degree of choice for computer graphics applications

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 6/ 116 Cubic Splines

Cubic piecewise polynomials: • We can attain C2 continuity without fixing the second derivative throughout the curve • C2 continuity is perceptually important ƒ The eye can see second order shading discontinuities (esp.: reflective objects) ƒ Motion: continuous position, velocity & acceleration Discontinuous acceleration noticeable (object/camera motion) • One more argument for cubics: ƒ Among all C2 curves that interpolate a set of points (and obey to the same end conditions), a piecewise cubic curve has the least integral acceleration (“smoothest curve you can get” in this sense).

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 7/ 116 Piecewise Cubic Interpolation

y2 y0 y 1 p2 p1 yn )( )( iii 2)( i 3)( pn i )( 0 1 2 +++= 3 tctctccxp Setup:

• (n+1) control points y0...yn (to be interpolated)

• For simplicity: assume uniform spacing t0...tn = (0,1,2,...,n)

• n cubic polynomial pieces p1...pn parametrized over [0...1] • Multidimensional case: solve problem for each axis (x,y,z)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 8/ 116 Conditions

y2 y0 y 1 p2 p1 yn pn (4n degrees of freedom)

=∀ 1... i )0(: = ypni i−1 (n conditions)

=∀ 1... i )1(: = ypni i (n conditions) d d =∀ 2...ni p = p )1()0(: (n‐1 conditions) dt i dt i−1 d 2 d 2 =∀ 2...ni p = p )1()0(: (n‐1 conditions) dt 2 i dt 2 i−1 2 dimensional null space (so far)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 9/ 116 Conditions

y2 y0 y 1 p2 p1 yn pn

additional: =∀ 1... i )0(: = ypni i−1 (n conditions) d 2 =∀ 1... i )1(: = ypni i (n conditions) 2 p1 = 0)0( d d dt =∀ 2...ni p = p )1()0(: (n‐1 conditions) 2 dt i dt i−1 d 2 pn = 0)1( d 2 d 2 dt =∀ 2...ni p = p )1()0(: (n‐1 conditions) dt 2 i dt 2 i−1 alternative: cyclic boundary conditions (closed curves)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 10 / 116 Numerical Solution

⎛ *** ⎞ Solving the system of equations: ⎜ **** ⎟ ⎜ ***** ⎟ • Band matrix, bandwidth O(1) ⎜ ***** ⎟ ⎜ ***** ⎟ • Can be solved in O(n) time & space ⎜ ***** ⎟ for n variables ⎜ **** ⎟ ⎝ *** ⎠

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 11 / 116 Cubics Minimize Acceleration

Theorem:

• Given n data points (yi, ti) to interpolate and fixed end conditions (either prescribed 1st derivative, or zero second derivative), a piecewise cubic interpolant minimizes n the energy: = ∫ tffE )('')( 2 dt 0 • This means: A cubic spline curve has the least square acceleration. • Related to elastic energy: Hooke’s elastic energy of a n 2 straight line is given by: E f = ∫λ κ [2)( f]( ) dtt 0 • I.e.: cubic spline interpolation approximates elastic beams.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 12 / 116 Proof: Cubics Minimize Acceleration

Cubic spline: c(t) Another C2 interpolating curve: a(t) Residual: d(t) = a(t) – c(t). Energy functional: n = ∫ taaE )('')( 2 dt 0 n ∫[]+= tdtc )('')('' 2 dt 0 n n n = tc 2 dt + tdtc dt + ∫∫∫ td )('')('')(''2)('' 2 dt 0 0 0

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 13 / 116 Proof: Cubics Minimize Acceleration

Cubic spline: c(t) Integration by parts: b b 2 tbta dt = []=bt − xbxatbta )()(')()()(')( dt Another C interpolating curve: a(t) ∫ =at ∫ a a Residual: d(t) = a(t) – c(t). Energy functional: n n n = tcaE 2 dt + tdtc dt + ∫∫∫ td )('')('')(''2)('')( 2 dt 0 0 0 Integration by parts: n n tdtc dt = []n − tdtctdtc )(')(''')(')('')('')('' dt ∫ 0 ∫ 0 0 n = []c ()tat c t =nt −− c tdt )(')(''')(')(')('' dt t =0 ∫ 0 n c = c ()()  nan c n −− c   a c −− ∫ tdt )(')(''')0(')0(')0('')(')(')('' dt 0for 0if identical first 0for 0if identical first 0 c n' =0)(' order end cond. c'' n =0)( order end cond.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 14 / 116 Proof: Cubics Minimize Acceleration

Cubic spline: c(t) Integration by parts: b b 2 tbta dt = []=bt − xbxatbta )()(')()()(')( dt Another C interpolating curve: a(t) ∫ =at ∫ a a Residual: d(t) = a(t) – c(t). Energy functional: n n n = tcaE 2 dt + tdtc dt + ∫∫∫ td )('')('')(''2)('')( 2 dt 0 0 0 Middle term (cont.): n n tdt )(')(''' dt ∫ tdtc )('')('' dt = ∫ c  0 0 piecewise const. n−1 (''' += 5.0 ) []tdic )( it += 1 ∑  =it i=0 = 0(interpola tion) = 0

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 15 / 116 Proof: Cubics Minimize Acceleration

Cubic spline: c(t) Another C2 interpolating curve: a(t) Residual: d(t) = a(t) – c(t). Energy functional: n n = tcaE 2 dt + ∫∫ td )('')('')( 2 dt 0  0 cubic spline additional energy: positive Positive additional energy: Any function that differs in second derivative from c will have higher energy. ⇒ c is a minimal function in terms of E.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 16 / 116 Polynomial Spline Curves Spline Bases with Local Control So what’s missing?

So we have solved our problem –what’s left to do? • Target area: interactive geometric modeling • Shape of the entire curve depends on all control points • Changing one control point can affect the whole curve • Not a big issue for algorithmic curve control ƒ Fitting curves to data, optimizing curves according to some objective function, etc... • But not acceptable for modeling by humans • “User interface problem”: We want local control.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 18 / 116 Notation

Function design problem: t f(t) c1 • Function f: R → R c2 c3 f(t) = c1b1(t) + c2b2(t) + c3b3(t) + ...

• Coefficients c1, c2, c3, ... ∈ R u function graph

Curve design problem p t y 2 n • Function f: R → R p1

p3 f(t) = b1(t)p1 + b2(t)p2 + b3(t)p3 + ... x • ∈ Rn “Control points” p1, p2, p3, ... parametric curve

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 19 / 116 New Idea

Problem: Again the basis... • We want a basis such that the coefficients / control points have intuitive meaning • Then we can just let the user edit the control points • The effect of control point editing has to be intuitive enough to be manually controllable

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 20 / 116 Desirable Properties

Useful requirements for a spline basis: • The curve should be well behaved: smooth basis functions • Local control: basis functions with compact support • Affine invariance: ƒ Applying an affine map x → Ax + b to the control points should have the same effect as transforming the curve ƒ In particular: rotation, translation ƒ Otherwise, interactive curve editing is almost impossible • Convex hull property: ƒ Good to have: The curve is in the convex hull of its control points ƒ Avoids at least too weird oscillations ƒ Computational advantages (recursive intersection tests)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 21 / 116 Affine Invariance

Affine Invariance: • Affine map: x → Ax + b • Part I: Linear invariance –we get this automatically ⎛ p x )( ⎞ n n ⎜ i ⎟ ƒ Linear approach: y)( f = pii = ∑∑ i tbtbt )()()( ⎜pi ⎟ i=1 i=1 ⎜ z)( ⎟ ⎜ p ⎟ ⎝ i ⎠ ⎛ n ⎞ n ƒ Therefore: () ⎟ () )( = ⎜ )( pAfA ii ⎟ = ∑∑ i tbtbt )( Api ⎝ i=1 ⎠ i=1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 22 / 116 Affine Invariance

Affine Invariance: • Affine map: x → Ax + b • Part II: Translational invariance – need some brains n n n ⎛ n ⎞ ƒ ∑ tb )( ()ii bp =+ pii + ∑∑ i b += ⎜∑ i tbtftbtb )()()()( ⎟ b i=1 i=1 i=1 ⎝i =1 ⎠ must sum to one ƒ For translational invariance, the sum of the basis functions must be one everywhere (for all parameter values t that are used). ƒ This is called “partition of unity property”.

ƒ The bi form an “affine combination” of the control points pi. ƒ This is absolutely necessary for human modeling.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 23 / 116 Convex Hull Property

Convex combinations:

• A convex combination of a set of points {p1,...,pn} is any point of the form: n n ƒ λ pii with : ∑∑ λi 1 and 1 ..ni λλii ≤≥=∀= 1,0: i=1 i=1

ƒ (Remark: λi ≤ 1 is redundant) • The set of all admissible convex combinations forms the convex hull of the point set ƒ Easy to see (simple exercise): This convex hull is the smallest set

that contains all points {p1,...,pn} and every complete straight line between two elements of the set.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 24 / 116 Convex Hull Property

Accordingly: • If we have this property: n Ω∈∀ ∑ i tbt 1)(: and =∀Ω∈∀= 1: .. i tbnit ≥ 0)(: i=1 the constructed curves / surfaces will be: ƒ Affine invariant (translations, linear maps) ƒ Be restricted to the convex hull of the control points • Corollary: Curves with this property will have linear precision, i.e.: if all control points lie on a straight line, the curve is a straight line segment, too. • Surfaces with planar control points will be flat, too.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 25 / 116 Convex Hull Property

Convex Hull Property: • Very useful property ƒ Avoids at least the worst oscillations (no escape from convex hull, unlike through control points) ƒ Linear precision property is intuitive (people expect this) ƒ Can be used fast range checks – Test for intersection with convex hull first, then the object. – Recursive intersection algorithms in conjunction with subdivision rules (more on this later)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 26 / 116 Spline Techniques

Spline bases we will look at in this lecture: • Hermite interpolation • Bezier curves & surfaces • Uniform B‐splines • Non‐uniform B‐splines • [NURBS: Non‐uniform rational B‐splines] (not linear, more on this later)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 27 / 116 Spline Techniques

Two views: • Linear algebra: polynomial function spaces ƒ Basis changes ƒ Derivatives and continuity conditions • Geometry: Successive linear interpolation (“blossoming”) ƒ Construct polynomial spline curves by repeated linear interpolation of control points ƒ More intuitive explanations of properties ƒ Mathematical formalism: Blossoming and polar forms

This part of the lecture will deal with the linear algebra view. Blossoming gets a separate chapter...

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 28 / 116 Polynomial Spline Curves Hermite Splines Hermite Splines

Overview: • Simple spline technique, easy to implement • Has some shortcomings • We will look at C1 cubic Hermite splines as an example

Key Idea: • Specify position and derivatives at the endpoints of each segment • Come up with a rule to match them easily • Precompute basis for this purpose

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 30 / 116 Illustration

h1 h2 h3

)( )( iii 2)( i 3)( i )( 0 1 2 +++= 3 tctctccth

For each segment hi(t) we know:

• Positions: hi(0), hi(1)

• Derivatives: ∂t hi(0), ∂t hi(1)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 31 / 116 Hermite Basis

Linear system: (one dimension, one segment) 2 3 )0( = ph 0 =⇒ pc 00 )( 210 +++= 3tctctccth )1( = ph =+++⇒ pcccc 2 1 13210 ++= 32)(' 321 tctccth

)0(' = mh 0 =⇒ mc 01

)1(' = mh 1 32 =++⇒ mccc 1321

⎛ 0001 ⎞⎛c ⎞ ⎛ p ⎞ ⎛ 0001 ⎞⎛ p0 ⎞ ⎛c0 ⎞ ⎜ ⎟⎜ 0 ⎟ ⎜ 0 ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ 1111 ⎟⎜c1 ⎟ ⎜ p1 ⎟ ⎜ 0100 ⎟⎜ p1 ⎟ ⎜c1 ⎟ = ⎟ = ⎜ ⎟ ⎜ 0010 ⎟⎜c ⎟ ⎜m ⎟ ⎜ −−− 1233 ⎟⎜m c ⎜ ⎟⎜ 2 ⎟ ⎜ 0 ⎟ ⎜ ⎟⎜ 0 ⎟ ⎜ 2 ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ 1122 ⎟⎜m ⎟ ⎜c ⎟ ⎝ 3210 ⎠⎝c3 ⎠ ⎝m1 ⎠ ⎝ − ⎠⎝ 1 ⎠ ⎝ 3 ⎠

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 32 / 116 Hermite Basis

Solution: ⎛ 0001 ⎞ ⎛ p ⎞ ⎜ ⎟ ⎜ 0 ⎟ 32 ⎜ 0100 ⎟ ⎜ p1 ⎟ f = [],,,1)( tttt ⎟ ⎜ −−− 1233 ⎟ ⎜m ⎜ ⎟ ⎜ 0 ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ − 1122 ⎠ ⎝m1 ⎠ Basis Functions: +−= 231)( ttth 32 p0 32 p1 −= 23)( ttth 2)( +−= tttth 32 m0 )( +−= ttth 32 m1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 33 / 116 Hermite Basis

Properties: • h and h sum to one. p0 p1 (affine invariant w.r.t. position) • Curve might leave convex hull of control points

Open question: • How to specify derivatives?

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 34 / 116 Illustration

xi‐1

xi+1 fi xi fi+1

Simple rule for derivatives: • Derivatives: − xx f :)0( =∂ ii −2 ∈ 2{(, ..ni }) it 2 − xx f :)1( =∂ ii −+ 11 1{(, ..ni −∈ 1}) it 2

t 1 :)0( −=∂ xxf 01

nt :)1( −=∂ xxf nn −1 • “Catmull‐Rom Spline”

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 35 / 116 Properties

Properties of this spline construction: • Interpolates original points • Local control

• C1 continuous • Affine invariant • No convex hull property ƒ Tends to “overshoot” ƒ This can be really nasty in practice

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 36 / 116 Polynomial Spline Curves Bezier Curves Bezier Splines

History: • Bezier splines developed ƒ by Paul de Casteljau at Citroën (1959) ƒ Pierre Bézier at Renault (1962) for designing smooth free‐form parts in automotive design applications. • Today: The standard tool for 2D curve editing, Cubic 2D Bezier curves are used almost everywhere: ƒ Postscript, PDF, Truetype (quadratic curves), Windows GDI... ƒ Corel Draw, Powerpoint, Illustrator, ... • Widely used in 3D curve & surface modeling as well

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 38 / 116 All You See is Bezier Curves...

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 39 / 116 Bernstein Basis

Bezier splines use the Bernstein basis:

)( nn n)()( • Bernstein basis of degree n: = { 0 , 1 ,...,BBBB n } ⎛n⎞ n)( ⎜ ⎟ i ()−in (degree n) i tB = ⎜ ⎟ 1:)( −tt = Bi−th basis function ⎝ i ⎠ • Each basis function is a polynomial of degree n. • The basis functions form a partition of unity n ⎛n⎞ n n ⎜ ⎟ i −in n)( ()tttt )1()1(1 =−+=+−= ∑⎜ ⎟ 1 =− ()∑ i tBtt )( i=0 ⎝ i ⎠ i=0 (binomial theorem)

(n) • For t ∈ [0..1], the basis functions are positive (Bi (t) ≥ 0).

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 40 / 116 Examples

The first three Bernstein bases: n=1 (linear) )0( B0 = 1: B0 B1 )1( )1( 0 ()1: −= 1 := tBtB

)2( ()2 )2( ()2)2( 0 1: −= 1 12: −= 2 := tBttBtB

)3( ()3 )3( 2 () 0 1: −= 1 13: −= ttBtB n=2 (quad.) n=3 (cubic) () 2)3( 3)3( B B0 B3 2 13: 3 :=−= tBttB 0 B2 B 1 B1 B2

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 41 / 116 Bernstein Basis

Bernstein basis properties: n=3 (cubic) ⎛n⎞ B0 B3 • )( nn n)()( n)( ⎜ ⎟ i −in = {}0 , 1 ,...,BBBB n , i tB = ⎜ ⎟ ()1:)( −tt ⎝ i ⎠ B1 B2 • Basis for polynomials of degree n. n)( • Each basis function Bi has its maximum at i/n. • Recursive computation: n =10 n)( n− )1( n− )1( i ()−= i + i−1 tBttBttB )()(1:)( 0 n with 0 i 0)(,1)( for ∉== 0{ ...nitBtB }

n n • Symmetry: i −in −= tBtB )1()(

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 42 / 116 Bezier Curves

Bezier curves Properties: n=3 (cubic) n B0 B3 n)( • Curves: )( = ∑pf ii tBt )( i=0 B1 B2 • Considering the interval t ∈ [0..1] • Bezier curves are affine invariant. • Bezier curves are contained in the

convex hull of the control points. n =10 • The influence of the control points is moving along the curve with index i. Largest influence at t = i/n. • However: A single curve segment has no fully local control.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 43 / 116 Bezier Curves: Examples

Bezier Curves: p2 n=3 (cubic) n B0 B3 n)( p )( = pf Bt 1 • ∑ ii p i=0 3 B1 B2

p0

p3 p3

p2 p0 p p 1 p 2 1 p3 p2 p1 p0 p0

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 44 / 116 Matrix Form

Matrix Notation: Bezier → Monomials

⎛ 001 ⎞⎛p ⎞ ⎟⎜ 0 ⎟ 2 ⎜ (quadratic case) f = []1)( ttt ⎜− 022 ⎟⎜p1 ⎟ ⎜ ⎟⎜ ⎟ ⎝ − 121 ⎠⎝p2 ⎠

⎛ 0001 ⎞⎛p0 ⎞ ⎜ ⎟⎜ ⎟ 32 ⎜− 0033 ⎟⎜p1 ⎟ f = []1)( tttt ⎜ ⎟ (cubic case) ⎜ − 0363 ⎟ p ⎜ ⎟⎜ 2 ⎟ ⎜ ⎟⎜ ⎟ ⎝ −− 1331 ⎠⎝p3 ⎠

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 45 / 116 Format Conversion

Conversion: Compute Bezier coefficients from monomial coefficients

(Bez.) −1 ⎛c ⎞ ⎛ 001 ⎞ ⎛c ⎞ ⎜ 0 ⎟ 0 (Bez.) ⎜ ⎟ ⎜ ⎟ ⎜c1 ⎟ ⎜−= 022 ⎟ ⎜c1 ⎟ (quadratic case) (Bez.) ⎟ ⎜c ⎟ ⎜ 121 ⎟ ⎜c ⎟ ⎝ 2 ⎠ ⎝ − ⎠ ⎝ 2 ⎠

(Bez.) −1 ⎛c ⎞ ⎛ 0001 ⎞ ⎛c0 ⎞ ⎜ 0 ⎜ ⎟ (Bez.) ⎟ ⎜ ⎟ ⎜c1 ⎟ ⎜− 0033 ⎟ ⎜c1 ⎟ ⎜ (Bez.) ⎟ = ⎜ ⎟ (cubic case) c ⎜ − 0363 ⎟ c ⎜ 2 ⎟ ⎜ ⎟ ⎜ 2 ⎟ ⎜ (Bez.) ⎟ ⎜ ⎟ ⎜ ⎟ ⎝c3 ⎠ ⎝ −− 1331 ⎠ ⎝c3 ⎠

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 46 / 116 Format Conversion

Conversion: quadratic to cubic

)3( −1 )2( ⎛c ⎞ 0001 ⎛c ⎞ ⎜ 0 ⎛ ⎞ ⎛ 001 0⎞⎜ 0 ⎟ )3( ⎟ ⎜ ⎟ ⎜ ⎟ )2( ⎜c1 ⎟ ⎜− 0033 ⎟ ⎜− 022 0⎟⎜c1 ⎟ ⎜ )3( ⎟ = ⎜ ⎟ ⎜ ⎟⎜ )2( ⎟ c2 − 0363 − 121 0 c2 ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ )3( ⎟ ⎜ ⎟ 0000 ⎜ ⎟ ⎝c3 ⎠ ⎝ −− 1331 ⎠ ⎝ ⎠⎝ 0 ⎠ Convert to monomials and back to Bezier coefficients. (Other degrees similar)

Example Application: Output of TrueType fonts in Postscript.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 47 / 116 The Other Way Round...

Reducing the degree: • Exact solution is not always possible • Approximate solution: least‐squares (function approximation) • System of normal equations: ~ ~ ~ ~ ~ ~ ⎛ , " ,bbbb ⎞⎛ c ⎞ ⎛ (), fxb ⎞ ⎜ 11 n 1 ⎟⎜ 1 ⎟ ⎜ 1 ⎟ m ⎜ #%# ⎟⎜ ⎟ = ⎜ ## ⎟ = tbctf )(:)(, ⎜ ⎜ ⎟ ∑ ii ~ ~ ~ ~ ⎟⎜~ ⎟ ~ i=1 ⎜ , " ,bbbb ⎟ c ⎜ (), fxb ⎟ ⎝ 1 n ⎠⎝ nnn ⎠ ⎝ n ⎠ ⎛ ~ ~ ~ ~ ⎞ ~ ⎛ ~ ⎞ , 11 " n ,bbbb 1 ⎛ c ⎞ 1 ()i tbxb )(, ⎜ ⎟⎜ 1 ⎟ m ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⇔ #%# ⎜ # ⎟ = ci # ⎜ ∑ ⎜ ⎟ ~ ~ ~ ~ ⎟⎜~ ⎟ i=1 ~ ⎜ , " ,bbbb ⎟ c ⎜ ()tbxb )(, ⎟ ⎝ 1 n ⎠⎝ nnn ⎠ ⎝ in ⎠ Geometric Modeling SoSem 2010 – Polynomial Spline Curves 48 / 116 Cubic → Quadratic Case

Reducing the degree: Cubic → Quadratic

⎛ 1 1 1 ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ ⎜ ⎟ ~ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ 7 14 35 ⎟⎛ c0 ⎞ ⎜ 6 ⎟ ⎜ 10 ⎟ ⎜ 20 ⎟ ⎜ 60 ⎟ 1 3 9 ⎜ ⎟ 1 1 1 1 ⎜ ⎟ ~c = ⎜ ⎟ + ⎜ ⎟ + ⎜ ⎟ + cccc ⎜ ⎟ ⎜ ⎟⎜ 1 ⎟ 0 ⎜ ⎟ 1 ⎜ ⎟ 2 ⎜ ⎟ 3 ⎜ ⎟ 14 35 140 ⎜~ ⎟ 15 10 10 15 ⎜ 1 9 3 ⎟⎝ c2 ⎠ ⎜ 1 ⎟ ⎜ 1 ⎟ ⎜ 1 ⎟ ⎜ 1 ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ 35 140 35 ⎠ ⎝ 60 ⎠ ⎝ 20 ⎠ ⎝ 10 ⎠ ⎝ 6 ⎠

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 49 / 116 Polynomial Spline Curves Bezier Splines Bezier Splines

Local control: Bezier splines • Concatenate several curve segments • Question: Which constraints to place upon the control points in order to get C‐1, C0, C1, C2 continuity?

(i) p2 (i+1) (i) p3 p1 (i) p3 (i+1) (i) p0 p0 (i+1) p2 (i+1) p1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 51 / 116 Derivatives

Bernstein basis properties: • Derivatives:

d n)( ⎛n⎞ i− }1{ −in i}{ in −− }1{ i tB )( = ⎜ ⎟()it ()1)(1 −−−− ttint () dt ⎝ i ⎠ n! n! } = it i− }1{ ()1− t −in − i ()1)( −− ttin in −− 1{ ()− iin !! ()− iin !!

⎡⎛n −1⎞ i−1{ } −in ⎛n −1⎞ i in −− }1{ ⎤ = n⎢⎜ ⎟ ()1−tt − ⎜ ⎟ 1− tt ()⎥ ⎣⎝ i −1 ⎠ ⎝ i ⎠ ⎦

n− )1( n− )1( = []i−1 − i tBtBn )()(

({k} = k if k > 0, zero otherwise)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 52 / 116 Derivatives

Bernstein basis properties: • Derivatives:

d2 d ⎛n⎞ n)( tB )( = ⎜ ⎟(it i− }1{ ()−in i 1)(1 −−−− ttint ()in −− }1{ ) 2 i ⎜ ⎟ dt dt ⎝ i ⎠

⎛n⎞ i− }2{ −in i− }1{ in −− }1{ = ⎜ ⎟(i − it ()1)(1}1{ −−−− ttinit () ⎝ i ⎠ i− }1{ ()1)( in −− }1{ 1{ }( i}{ ()1) −−−−+−−− ttininttini in −− }2{ )

n− )2( n− )2( n− )2( −= []i−2 − i−1 + i tBtBtBnn )()(2)()1(

({k} = k if k > 0, zero otherwise)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 53 / 116 Bezier Curve Properties

Important for continuous concatenation: n=3 (cubic) B B • Function value at {0,1}: 0 3 B B n ⎛n⎞ 1 2 ⎜ ⎟ i −in f t)( = ∑⎜ ⎟ ()1−tt pi i=0 ⎝ i ⎠

)0( = pf 0

)1( = pf n n =10 • First derivative vector at {0,1}

• Second derivative vector at {0,1}

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 54 / 116 Bezier Curve Properties

Important for continuous concatenation: n=3 (cubic) B B • Function value at {0,1}: 0 3 B1 B2 = pf 0 ,)0( )1( = pf n • First derivative vector at {0,1}: n d n− )1( n− )1( f )( = ∑[]i−1 − i tBtBnt )()( pi dt i=0

n− )1( n− )1( n− )1( ([]−= 0 )( p + [ 00 − 1 tBtBtBn )()( ]p1 + ... n =10

n− )1( n− )1( n− )1( ...+ []n−2 − n−1 )()( pn−1 + []n−1 tBtBtB )( pn ) d d f( )0 n()−= pp f( )1 n()−= pp dt 01 dt nn −1 • Second derivative vector at {0,1}

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 55 / 116 Bezier Curve Properties

Important for continuous concatenation: n=3 (cubic) B B • Function value at {0,1}: 0 3 B1 B2 = pf 0 ,)0( )1( = pf n • First derivative vector at {0,1}: n d n− )1( n− )1( f )( = ∑[]i−1 − i tBtBnt )()( pi dt i=0

n− )1( n− )1( n− )1( ([]−= 0 )( p + [ 00 − 1 tBtBtBn )()( ]p1 + ... n =10

n− )1( n− )1( n− )1( ...+ []n−2 − n−1 )()( pn−1 + []n−1 tBtBtB )( pn )

)0(' n()−= ppf 01 )1(' = n( − ppf nn −1 )

• Second derivative vector at {0,1}

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 56 / 116 Bezier Curve Properties

Important for continuous concatenation: n=3 (cubic) B B • Function value at {0,1}: 0 3 B1 B2 )0( = pf 0

)1( = pf n • First derivative vector at {0,1}:

)0(' n[]−= ppf 01 n =10 )1(' n[]−= ppf nn −1 • Second derivative vector at {0,1}:

f nn −= []−2)1()0('' + ppp 210

f nn −= []−2)1()1('' + ppp nnn −− 21

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 57 / 116 Bezier Spline Continuity

Rules for Bezier spline continuity: • C0 continuity: ƒ Each spline segment interpolates the first and last control point ƒ Therefore: Points of neighboring segments have to coincide for C0 continuity.

p(i+1) (i+1) 2 (i) p1 p2 (i+1) (i) p3 p1 (i) p3 p(i+1) (i) 0 p0

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 58 / 116 Bezier Spline Continuity

Rules for Bezier spline continuity: • Additional requirement for C1 continuity:

ƒ Tangent vectors are proportional to differences p1 – p0, pn – pn‐1 ƒ Therefore: These vectors must be identical for C1 continuity

(i+1) p2 (i) p2 (i+1) (i) p3 p1 (i) p3

(i) (i+1) p0 p 0 (i+1) p1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 59 / 116 Bezier Spline Continuity

Rules for Bezier spline continuity: • Additional requirement for C2 continuity: 2 2 ƒ d /dt vectors are prop. to (p2 –2p1 + p0), (pn –2pn‐1 + pn‐2) ƒ Tangents must be the same (C2 implies C1) ƒ Therefore: Triangle of first / last three points must be the same

(i+1) (i) p3 p2 (i) p1 (i) p3

(i+1) p(i) (i+1) p 0 p0 2 (i+1) p1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 60 / 116 In Practice

In practice: • Everyone is using cubic Bezier curves • Higher degrees rare (CAD/CAM applications) • Typically: “points & handles” interface • Four modes: ƒ Discontinuous (two curves) ƒ C0 Continuous (points meet) ƒ Tangent direction continuous (handles point into the same direction, but different length) (“G1 continuous”, more on this shortly) ƒ C1 Continuous (handle points have symmetric vectors) • C2 is rarely supported (too restrictive, no local control)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 61 / 116 Bezier Curve Editing

C‐1 continuity C0 continuity

G1 continuity C1 continuity

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 62 / 116 Geometric Continuity

Parametric Continuity: • C0, C1, C2... continuity. • Does a particle moving on this curve have a smooth trajectory (position, velocity, acceleration,...)? • Useful for animation (object movement, camera paths)

Geometric Continuity: • Is the curve itself smooth? • C.f.: differential geometry – parametrization independent measures • More relevant for modeling (curve design)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 63 / 116 Geometric Continuity

Geometric Continuity: • G0 = C0: position varies continuously • G1: tangent directions varies continuously ƒ In other words: the normalized tangent varies continuously ƒ Equivalently: The curve can be reparametrized so that it becomes C1. ƒ Also equivalent: A unit speed parametrization would be C1. • G2: curvature varies continuously ƒ Equivalently: The curve can be reparametrized so that it becomes C2. ƒ Also equivalent: A unit speed parametrization would be C2.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 64 / 116 Geometric Continuity for Bezier Splines

This means:

G1 continuity

This Bezier curve is G1: It can be reparametrized to become C1. (Just increase the speed for the second segment by ratio of tangent vector lengths.)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 65 / 116 Polynomial Spline Curves Uniform Cubic B‐Splines Literature

Literature: • An Introduction to Splines for use in Computer Graphics and Geometric Modeling Richard H. Bartels, John C. Beatty, Brian A. Barsky Morgan Kaufmann 1987

(now hard to get, waited several month on Amazon)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 67 / 116 Overview

Uniform cubic B‐splines • This is a special case of general B‐splines ƒ (which additionally provide arbitrary degree and general and non‐uniform parametrization) • We look at this first to get an intuition for the basic ideas and concepts for B‐splines • Some derivations are left out – will be shown later for the general case

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 68 / 116 Overview

Improvement over cubic Bezier splines: • C2 continuity is easily attainable • We will use only one type of basis functions ƒ Shifted in the domain to create curves with multiple segments ƒ This principle is conceptually easier to apply in general modeling problems (e.g. as a basis for finite elements, for PDEs or variational problems)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 69 / 116 Key Ideas

1.0

Key Ideas: 0.8

0.6

• We design one basis function b(t) 0.4

0.2

• Properties: 0.0 1.0 2.0 3.0 4.0 ƒ b(t) is C2 continuous. ƒ b(t) is piecewise polynomial, degree 3 (cubic). ƒ b(t) has local support. ƒ Overlaying shifted b(t + i) forms a partition of unity. ƒ b(t) ≥ 0 for all t • In short: We build‐in all the desirable properties into the basis. Linear combinations will inherit these.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 70 / 116 Shifted Basis Functions

1.0 1.0

0.8 0.8 i=‐1 i=0 i=1 i=2 i=3 0.6 0.6 p2(t‐1) p3(t‐2) 0.4 0.4

0.2 p1(t) p4(t‐3) 0.2

0.0 1.0 2.0 3.0 4.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 basis function b(t) shifted basis functions b(t‐i) for [0..6] Basis function:

• Consists of four polynomial parts p1...p4. • Shifted basis b(t – i): spacing of 1.

• Each interval to be used must be overlapped by 4 different bi.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 71 / 116 Basis Function

1.0 1 )( = ttp 3 1 6 0.8 0.6 1 32 p2(t‐1) p3(t‐2) 2 )( ()−++= 3331 ttttp 6 0.4 1 tp )( ()+−= 364 tt 32 0.2 p1(t) p4(t‐3) 3 6 1 0.0 1.0 2.0 3.0 4.0 )( ()331 −+−= ttttp 32 4 6 basis function b(t) ⎧0 if t < 0 ⎧0 if t < 0 ⎪ 1 3 ⎪ tp t t t ≤< ⎪ 1 )( if ≤< 10 ⎪ 6 if 10 ⎪ ⎪ 1 ()2 3 ⎪ 2 tp )1( if t ≤<− 21 ⎪ 6 1(3)1(31 ttt −−−+−+ )1(3) if t ≤< 21 tb )( = ⎨ = ⎨ 1 2 3 tp t ()tt t ⎪ 3 )2( if ≤<− 32 ⎪ 6 −+−− )2(3)2(64 if ≤< 32 1 ⎪ tp )3( if t ≤<− 43 ⎪ ()2 ttt −−−+−− )3()3(3)3(31 3 if t ≤< 43 ⎪ 4 ⎪ 6 ⎩⎪0 if t > 4 ⎩⎪0 if t > 4

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 72 / 116 Creating Curves

1.0

0.8 i=‐1 i=0 i=1 i=2 i=3 0.6 0.4 0.2

0.0 1.0 2.0 3.0 4.0 5.0 6.0 Creating uniform B‐spline curves:

• Choose parameter interval [nstart‐2, nend+2,], nstart < nend ∈ Z • Use all shifted basis functions that overlap this interval:

B = {b(t –[nstart‐1]), ..., b(t –[nend+1])}

nend +1 • Form linear combinations: f = ∑ − itbt )()( pi ni start−= 1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 73 / 116 Uniform B‐Spline Curves

one segment

two segments

three segments

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 74 / 116 Discontinuities

Continuity Control • Easier than with Bezier curves • The parametric function is always C2, by construction • However: We can create curves with lower geometric smoothness ƒ This will lead to a degenerate (non‐regular) parametrization ƒ This problem is fixed with general, non‐uniform B‐Splines • Basic idea: Double control points ƒ Single points: G2 curve ƒ Double points: G1 curve ƒ Triple points: G0 curve

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 75 / 116 Continuity Control

single points

× 1

double point

× 2

triple point (interpolates that point)

× 3

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 76 / 116 Illustration

× 2 × 3

1.0 1.0 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2

0.0 1.0 2.0 3.0 4.0 5.0 6.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 77 / 116 End Conditions

Problem: • We need at least 4 points for one spline segment, 5 for two and so on. • Means: We need s + 3 control points for s segments (rather than s + 1), two more than in spline interpolation. • This is inconvenient... • Simple solution: ƒ Use double or triple end points ƒ Triple end points will be interpolated ƒ We will get along with s + 1 control points

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 78 / 116 Knot Sequences

× 1 × 1 × 1 × 1 × 1 × 1

× 3 × 3 × 3

Specifying a uniform, cubic B‐Spline curve:

• A set of control points p1, ..., pn.

• Knot multiplicities (i1, ..., ik), ij ∈ {1,2,3}, Σij = n. ƒ For example (3,1,1,1,3,1,1,1,3) – Creates one sharp corner in the middle of the spline – Interpolates the end points

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 79 / 116 Conversion to Bezier Basis

Uniform B‐Splines can be converted to the Bezier Format: • Cubic polynomial pieces • Each can be represented as Bezier segment • Just a basis change...

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 80 / 116 Basis Change

⎛ 1410 ⎞ Uniform B‐Spline: ⎜ ⎟ 1 1 ⎜ − 3030 ⎟ )( = ttp 3 M = 1 UB→Mn ⎜ − 3630 ⎟ 6 6 ⎜ ⎟ ⎜ ⎟ 1 32 ⎝ −− 1331 ⎠ )( ()−++= 3331 ttttp 2 6 ⎛ 0001 ⎞ ⎜ ⎟ 1 32 ⎜− 0033 ⎟ tp )( ()+−= 364 tt M = 3 6 Bez→Mn ⎜ − 0363 ⎟ ⎜ ⎟ ⎜ ⎟ 1 32 ⎝ −− 1331 ⎠ 4 )( ()331 −+−= ttttp −1 6 MUB→Bez = ()M Bez→Mn MUB→Mn Bezier‐Spline: ⎛ ~ )1( ⎞ )1( bi ⎛ bi ⎞ ⎜ ⎟ ⎜ ⎟ 3 2 ~ )2( )2( )3( )3( ⎜b ⎟ ⎜ b ⎟ 0 (1: −= ) 1 (13: −= ttBtB ) i = M i−1 ⎜ ~ )3( ⎟ UB→Bez⎜ )3( ⎟ bi bi−2 2)3( 3)3( ⎜ ⎟ ⎜ ⎟ 2 ()3 :13: =−= tBttB ⎜~ )4( ⎟ ⎜ )4( ⎟ ⎝bi ⎠ ⎝bi−3 ⎠

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 81 / 116 Where does the basis come from?

How do we construct a B‐Spline basis? • Derivation of uniform cubic B‐Splines? • Generalizations: ƒ General degree? ƒ Non‐uniform parametrization?

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 82 / 116 Three Approaches:

Three ways to get the basis: 1. The elementary approach: ƒ Derive a linear system of equations, solve 2. Repeated convolution: ƒ d‐fold convolution of box functions 3. de‐Boor Recursion: ƒ Repeated linear interpolation

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 83 / 116 The Elementary Approach

1.0 Cubic Uniform B‐Spline Basis: 0.8 0.6 • One basis function, just shifted p2(t‐1) p3(t‐2) 0.4 • Consists of four pieces p1, p2, p3, p4. 0.2 p1(t) p4(t‐3) • We just need the coefficients of the pieces 0.0 1.0 2.0 3.0 4.0 basis function b(t) • Setting up a linear system...

pieces pi(t)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 84 / 116 The Elementary Approach

1.0 Linear system: 0.8 p = p′ = p′′ = 0)0(0)0(0)0( 0.6 1 1 1 p2(t‐1) p3(t‐2) 1 = 2 1′ = 2 1′′′ = pppppp 2′′ )0()1()0()1()0()1( 0.4 p (t) p (t‐3) 2 = 3 2′ = 3 2′′′ = pppppp 3′′ )0()1()0()1()0()1( 0.2 1 4 = ′ = ′′′ = pppppp ′′ )0()1()0()1()0()1( 3 4 3 4 3 4 0.0 1.0 2.0 3.0 4.0 p4 = p4′ = p4′′ = 0)1(0)1(0)1( basis function b(t) ⎛ 1 ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ 0⎜ ⎟ + 1⎜ ⎟ + 2⎜ ⎟ + pppp 3⎜ ⎟ = 1 ⎝ 2 ⎠ ⎝ 2 ⎠ ⎝ 2 ⎠ ⎝ 2 ⎠

pieces pi(t)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 85 / 116 The Elementary Approach

p1 = p1′ = p1′′ = 0)0(0)0(0)0(

Normalization: 1 = 2 1′ = 2 1′′′ = pppppp 2′′ )0()1()0()1()0()1( = ′ = ′′′ = pppppp ′′ )0()1()0()1()0()1( • 2 3 2 3 2 3 Completely determines the pi. 3 = 4 3′ = 4 3′′′ = pppppp 4′′ )0()1()0()1()0()1( p = p′ = p′′ = 0)1(0)1(0)1( • Turns out to hold everywhere in [0,1] 4 4 4 ⎛ 1 ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ 0 ⎜ ⎟ + 1⎜ ⎟ + 2 ⎜ ⎟ + pppp 3⎜ ⎟ = 1 • Not yet clear why ⎝ 2 ⎠ ⎝ 2 ⎠ ⎝ 2 ⎠ ⎝ 2 ⎠ • But: if it is possible, our conditions are sufficient • So we have to show that it is possible

Positivity: • Not enforced; we get this accidentally (simplicity) • Same argument: if it’s possible, the conditions are sufficient

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 86 / 116 Properties

Minimal Support: • We have 16 conditions (cubic case) ƒ 15 for smoothness, one for normalization ƒ Easy to see: linear independent • Need 4 polynomial segments to get sufficiently many degrees of freedom • Consequence: Any C2 function with 3 or less polynomial segments, and the zero function everywhere else, must be the zero function. ƒ 15 linear independent constraints, homogeneous. ƒ Zero vector is the only solution. • Therefore: We have minimal support.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 87 / 116 Repeated Convolution

Convolution: • Weighted average of functions g • Definition: f ∞ =⊗ ∫ − txgxftgtf )()()()( dx ∞− t Example:

⊗ =

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 88 / 116 Repeated Convolution

A Different Derivation: • We start with 0th degree basis functions • Increase smoothness by convolution

Degree‐zero B‐Spline:

)0( ⎧ ,1 if t ∈ 0[ ... )1 tb )( = ⎨ ⎩ ,0 otherwise General‐degree B‐Spline: ∞ i i )0()()( =⊗= ∫ i )0()( − txbxbtbtbtb )()()()()( dx ∞−

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 89 / 116 Illustration

1 1

b0 b0

‐1 0 1 2 ‐1 0 1 2

1 1

b0 b0

‐1 0 1 2 ‐1 0 1 2

1 1

b0 b0

‐1 0 1 2 ‐1 0 1 2

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 90 / 116 Illustration

1 1

b0 b0

‐1 0 1 2 ‐1 0 1 2

Result: • Piecewise linear B‐spline basis function

• Each convolution with b0 increases the continuity by 1.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 91 / 116 Illustration

1 1

b0 b1 ‐1 0 1 2 ‐2 ‐1 0 1

1 1

b0 b1 ‐1 0 1 2 ‐2 ‐1 0 1

1 1

b0 b1 ‐1 0 1 2 ‐2 ‐1 0 1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 92 / 116 Smoothness

Convolution with a box filter increases smoothness: k‐1 k Function f that is C at t = t0, and C everywhere else: t+1 : tfbff dt −+==⊗= tFtF )()1()( ⊗ 0 ∫ t d i d i Di =Δ tf − ()(: ), i 0)( for 1..kitfDtf −==Δ 1 dti dti − + d j d j−1 ⎛ d ⎞ d j−2 ⎛ d ⎞ ⊗ tf )( = ⎜ ⊗ tf )( ⎟ = ⎜ ()−+ tFtF )()1( ⎟ dt j dt j−1 ⎝ dt ⎠ dt j−2 ⎝ dt ⎠ d j−2 = ()−+ tftf )()1( dt j−2 j j−1 ⊗ )( ()−+Δ=Δ tftfDtfD )()1(

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 93 / 116 Partition of Unity

Proof by Induction: 1 1

b0 b0 b2 b2 b2 b2 ‐1 0 1 ‐1 0 1 2 degree zero: OK degree d: given

1 1

b0 b0 b0 b0 b2 b2 ‐1 0 1 2 ‐1 0 1 2 degree d... degree d+1: follows

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 94 / 116 Other Properties

Positivity: • By definition

Continuity: • Smoothness increasing property: k‐fold convolution is Ck.

Piecewise polynomial: • Easy to see: Polynomial in each interval • Degree k for k‐fold convolution.

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 95 / 116 Consequences

Consequences: • The constructed functions are identical to the explicitly constructed ones (limited degrees of freedom) • This means, the explicitly constructed basis has the same properties (partition of unity, positivity)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 96 / 116 Repeated Linear Interpolation

Another way to increase smoothness:

× t t × t ∈ [0..2] +

t

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 97 / 116 Repeated Linear Interpolation

Another way to increase smoothness:

× t t × t ∈ [0..3] +

t t

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 98 / 116 Plot of the Three Pieces

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 99 / 116 Repeated Linear Interpolation

General Principle:

× t t × t ∈ [0..d+1] +

t

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 100 / 116 De Boor Recursion

The uniform B‐spline basis of degree d is given as:

0 ⎧ ,1 if 1 <≤− iti i tN )( = ⎨ ⎩ ,0 otherwise

()it −− 1 ()−+ tdi d tN )( = d −1 tN )( + d −1 tN )( i ()()idi −−−+ 11 i ()()−+ idi i+1

it +− 1 −+ tdi = d −1 tN )( + d −1 tN )( d i d i

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 101 / 116 Connection

Three constructions: • It can be shown that this construction is equivalent to the previous two. • Rough idea: ƒ Convolution with a box filter increases degree by one (multiplication with linear weight in de Boor formula) ƒ Antiderivative of box filter: evaluate at t, t+1

(corresponds to overlaying Ni, Ni+1) ƒ Need to show that the coefficients match (induction)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 102 / 116 Polynomial Spline Curves Non‐Uniform B‐Splines Generalization

De Boor formula can be generalized: • Arbitrary parameter sequences (“knot sequence”)

(t0, t1, ..., tn) with t0 ≤ t1 ≤ ... ≤ tn ƒ Not necessary to have uniform spacing ƒ Will give us more flexibility in curve design. • Specifying one parameter value multiple times is permitted, e.g. (0, 0, 0, 1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 8, 8) ƒ This has a similar effect as multiple nodes in simple uniform B‐Splines ƒ Will avoid irregular parametrization (means: will create a basis that itself is less smooth, not just the traced out curve)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 104 / 116 General De Boor Recursion

Generalized Formula:

0 ⎧ ,1 if ti−1 <≤ tt i i tN )( = ⎨ ⎩ ,0 otherwise

d − tt i−1 d −1 +di − tt d −1 i tN )( = i tN )( + i+1 tN )( − tt idi −−+ 11 + − tt idi

Remark: • If a knot value is repeated d times, the denominator may vanish • In this case: The fraction is treated as a zero

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 105 / 116 Uniform Case:

For comparison –the uniform case:

0 ⎧ ,1 if 1 <≤− iti i tN )( = ⎨ ⎩ ,0 otherwise

()it −− 1 ()−+ tdi d tN )( = d −1 tN )( + d −1 tN )( i ()()idi −−−+ 11 i ()()−+ idi i+1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 106 / 116 B‐Splines

Constructing a Spline Curve: • Choose a degree d.

• Choose a knot sequence (t0, t1, ..., tn) with t0 ≤ t1 ≤ ... ≤ tn (n ≥ d –1)

• Choose control points p0, p1, ..., pm (m = n – d + 1) • Form the spline curve: n d f = ∑ i tNt )()( pi i=0 De Boor Algorithm: • This evaluation can be expanded explicitly...

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 107 / 116 De Boor Algorithm

n d = ∑ i tNtf )()( pi i=0 n ⎛ − tt ⎞ n ⎛ − tt ⎞ ⎜ i−1 d−1 ⎟ ⎜ +di d−1 ⎟ = ∑⎜ i tN )( ⎟pi + ∑⎜ i+1 tN )( ⎟pi i=0 ⎝ − tt idi −−+ 11 ⎠ i=0 ⎝ + − tt idi ⎠ n ⎛ − tt ⎞ n+1 ⎛ − tt ⎞ ⎜ i−1 d−1 ⎟ ⎜ 1+− di d−1 ⎟ = ∑⎜ i tN )( ⎟pi + ∑⎜ i tN )( ⎟pi−1 i=0 ⎝ − tt idi −−+ 11 ⎠ i=1 ⎝ − tt idi −−+ 11 ⎠ n+1 ⎛ ⎡ − tt ⎤ ⎡ − tt ⎤ ⎞ = ⎜ i−1 d−1 tN )( p + 1+− di d−1 tN )( p ⎟ ∑⎜ ⎢ i ⎥ i ⎢ i ⎥ i−1 ⎟ i=0 ⎝ ⎣ − tt idi −−+ 11 ⎦ ⎣ − tt idi −−+ 11 ⎦ ⎠ n+1 ()()−1 p 1+− −+− tttt pidiii −1 d−1 1 ()()−1 p 1+− −+− tttt pidiii −1 = ∑ i tN pi :)( = i=0 − tt idi −−+ 11 − tt idi −−+ 11 n+1 d−1 1 = ∑ i tN )( pi i=0

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 108 / 116 De Boor Algorithm

n+1 d − )1(1 = ∑ i tNtf )()( pi i=0 + jn −− jd j)(1 j)( ()− tt i−1 j− )1( ()1 −+− jdi − tt j− )1( = ∑ i tN )( pi with: pi = pi + pi−1 i=0 − tt ijdi −−−+ 11 − tt ijdi −−−+ 11 +dn d )(0 = ∑ tN )( pii i=0 This means:

• For t ∈ [ti‐1,...,ti), we obtain the function value f(t). • We can write this as an algorithm...

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 109 / 116 De Boor Algorithm

De Boor Algorithm:

• We want to evaluate f(t)for a t ∈ [ti‐1,...,ti) • We compute: )0( = pp ii For increasing j :

j ()− tt i−1 j−1 ()1 −+− jdi − tt j−1 pi t)( = pi t)( + pi−1 t)( − tt ijdi −−−+ 11 − tt ijdi −−−+ 11

j j−1)( j)( j− j)(1 ()− tt i−1 = αi pi t ()1)( −+ αi pi−1 (t), αi = − tt ijdi −−−+ 11 d −1 Outputp i t)(

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 110 / 116 Example

(0) 1 p )0( = pp (0) 3 ii p 4 2 For increasing j : 1 1 t3=2 ()− tt ()− tt t2=1 p j t)( = i−1 p j−1 t)( + 1 −+− jdi p j−1 t)( 6 2 i − tt i − tt i−1 t = 1.5 ijdi −−−+ 11 ijdi −−−+ 11 j j−1)( j)( j− j)(1 ()− tt i−1 = αi pi t ()1)( −+ αi pi−1 (t), αi = − tt ijdi −−−+ 11 d −1 Outputp i t)(

t4=3 t1=0 (0) (0) p4 p1

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 111 / 116 Data Flow

Data Flow: )0( p −di )0( )1( 1 pp didi +−+− 1 %## )0( )1( d − )2( i−1 pp i−1 " pi−1 )1()0( d − d − )1()2( i pp i " i pp i

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 112 / 116 De Boor Algorithm

Some nice properties: j j−1 j−1 • i = α pp i tt ( −+ α)pi−1 t ()(1)()( for some α) • The algorithm forms only convex combinations of the original data points. ƒ Affine invariance follows directly ƒ Numerically stable –no cancelation or error amplification problems ƒ Much better than transforming to monomial basis ƒ But slower: O(d2) instead O(d) multiplications with Horner scheme in monomial basis

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 113 / 116 Benefits of Non‐Uniform B‐Splines

Improvements over the uniform case: • We can choose the parameter intervals freely ƒ Typically: Use distance between control points as knot distance ƒ Allows better adaptation to distance between control points ƒ Curves tend to “overshoot” less (in particular: problem for B‐Spline interpolation; no convex hull property there) ƒ Achieve more uniform speed for applications in animation • No irregularities ƒ Reduced smoothness, start/end conditions build into the computed bases ƒ Advantages for rendering (no stopping at sharp corners)

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 114 / 116 Examples

The effect of parameter spacing:

uniform

first interval larger

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 115 / 116 Examples

Multiplying Knots

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 116 / 116 A Closer Look at B‐Splines

Need some more tools & properties: • Proof various properties • Operations: Knot insertion, degree elevation, etc. • Convert to alternative bases (e.g. Bezier, monomials)

Problem: • Indexing nightmare • We need a better formalism to understand what’s really going on: blossoming & polars • We will look at that tool first, then go into the details again

Geometric Modeling SoSem 2010 – Polynomial Spline Curves 117 / 117