Spline Curves Piecewise Polynomials · Splines Bases · Properties Today
Total Page:16
File Type:pdf, Size:1020Kb
Geometric Modeling Summer Semester 2010 Polynomial Spline Curves Piecewise Polynomials · Splines Bases · Properties Today... Topics: • Mathematical Background • Interpolation & Approximation • Polynomial 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 ()i() i( ) i 2 (i ) 3 pn p x()i= c0 + c1 t +2 c t3 + c t 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) tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 8/ 116 Conditions y2 y0 y 1 p2 p1 yn pn (4n eesdegr of eedom)fr i∀1 = n:... ( pi 0= ) i−1 y (n onditions)c i∀1 = n:... ( pi 1= ) i y (n onditions)c d d ∀i: =2... n (p 0 )= p ( 1( )n‐1 onditions)c dt i dt i−1 d 2 d 2 ∀i: =2... n (p 0 )= p ( 1(n‐1 ) onditions)c dt 2 i dt 2 i−1 2 dimensional null space (so far) tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 9/ 116 Conditions y2 y0 y 1 p2 p1 yn pn additional: i∀1 = n:... ( pi 0= ) i−1 y (n onditions)c d 2 i∀1 = n:... ( pi 1= ) i y (n onditions)c 2(p1 0 )= 0 d d dt ∀i: =2... n (p 0 )= p ( 1( )n‐1 onditions)c 2 dt i dt i−1 d 2(pn 1 )= 0 d 2 d 2 dt ∀i: =2... n (p 0 )= p ( 1(n‐1 ) onditions)c dt 2 i dt 2 i−1 e:tivernaalt cliccy boundary nditionsoc (closed cures)v tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 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 ⎜ ****⎟ ⎝ ***⎠ tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 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:()''()E f= ∫ f2 tdt 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 = ∫λ κ 2ft]( [ ) dt 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). gyEner functional: n E()''() a= ∫ a2 dt t 0 n =''()''()c∫[] t + d2 tdt 0 n n n ''()∫= c t 22 dt + ''()''()c ∫ t ddt t + d ∫ t2 dt ''() 0 0 0 tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 13 / 116 Proof: Cubics Minimize Acceleration Cubic spline: c(t) tionaegrtIn by parts: b b 2 ()'()()()'()()a t badt t = b tt= b − a xdt b x Another C interpolating curve: a(t) ∫ []t= a ∫ a a Residual: d(t) = a(t) – c(t). gyEner functional: n n n ()E ''() a∫= c2 dt 2 t +c ∫''()''() t ddt t + d ∫ t2 dt ''() 0 0 0 iontaegrtIn by parts: n n ''()''()''()'()'''()'()c t dcdt t = t d tn − c tdt d t ∫ []0 ∫ 0 0 n ''()'()'()'''()'()= ct a− t c t t= n − c t ddt t []()t =0 ∫ 0 n c ''() '()= '()cn() a − n ''(0) c n −c a '(0) ()− c −∫ '(0)t ddt t '''()'() 0for 0if etidncial first 0for 0if etidnical firts 0 ''c ( n )= 0 eordr den.dnco c('' n )= 0 edorr den.dnco tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 14 / 116 Proof: Cubics Minimize Acceleration Cubic spline: c(t) tionaegrtIn by parts: b b 2 ()'()()()'()()a t badt t = b tt= b − a xdt b x Another C interpolating curve: a(t) ∫ []t= a ∫ a a Residual: d(t) = a(t) – c(t). gyEner functional: n n n ()E ''() a∫= c2 dt 2 t +c ∫''()''() t ddt t + d ∫ t2 dt ''() 0 0 0 Middle term t.):(con n n '''()'()t ddt t ''()''()c∫ t ddt t =∫ c 0 0 piecewise.tsnco n−1 =c'''( i0 + .) 5 () dt= t i +1 ∑ [] t= i i=0 =0alotpen(ir )noti = 0 tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 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 ()''()''()E a=∫ c2 dt t + d ∫ t2 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 e –w get this automatically ⎛ p()x ⎞ n n ⎜ i ⎟ Linear approach: ()y ()()()tf ∑= bi tp i = ∑i b⎜ p ti ⎟ i=1 i=1 ⎜ ⎟ ⎜ p()z ⎟ ⎝ i ⎠ ⎛ n ⎞ n Therefore: At f()()= ∑ A⎜ bi() t i ⎟ p= ∑()i b()Ap t i ⎝ i=1 ⎠ i=1 tricGeome Modeling SoSem 2010 – lynomialoP Spline Curesv 22 / 116 Affine Invariance Affine Invariance: • Affine map: x → Ax + b • Part II: Translational invariance – need some brains n n n ⎛ n ⎞ ∑bi()p t()+ i b b∑()()()() = tip i + b ∑i tb= f t +⎜∑ i ⎟ bb t 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 ∑λip i wiht : = ∑λi 1 and ∀ i = 1:.. nλi 0 ≥ , λ i 1 ≤ 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.