
Lecture 12 Interpolation/Splines T. Gambill Department of Computer Science University of Illinois at Urbana-Champaign April 12, 2011 T. Gambill (UIUC) CS 357 April 12, 2011 1 / 38 Fonts == interpolation how do we ”contain” our interpolation? splines Postscript (Adobe): rasterization on-the-fly. Fonts, etc are defined as cubic Bezier´ curves (linear interpolation between lower order Bezier´ curves) TrueType (Apple): similar, quadratic Bezier´ curves, thus cannot convert from TrueType to PS (Type1) losslessly T. Gambill (UIUC) CS 357 April 12, 2011 2 / 38 Why Splines? truetype fonts, postscript, metafonts graphics surfaces smooth surfaces are needed how do we interpolate smoothly a set of data? keywords: Bezier Curves, splines, B-splines, NURBS basic tool: piecewise interpolation T. Gambill (UIUC) CS 357 April 12, 2011 3 / 38 Piecewise Polynomial A function f (x) is considered a piecewise polynomial on [a, b] if there exists a (finite) partition P of [a, b] such that f (x) is a polynomial on each (ti, ti+1) 2 P. Example x3 x 2 [0, 1] f (x) = 8x x 2 (1, 2) <>3 x 2 [2, 3] :> T. Gambill (UIUC) CS 357 April 12, 2011 4 / 38 What do we want? we would like the piecewise polynomial to do two things 1 interpolate (or be close to) some set of data points 2 look nice (smooth) one option is called a spline T. Gambill (UIUC) CS 357 April 12, 2011 5 / 38 Splines A spline is a piecewise polynomial with a certain level of smoothness. take Matlab: plot(1 : 7, rand(1, 7)) this is linear and continuous, but not very smooth the function changes behavior at knots x = 1, x = 2 ..., x = 7 T. Gambill (UIUC) CS 357 April 12, 2011 6 / 38 Degree 1 Splines definition A function S(x) is a spline of degree 1 if: 1 The domain of S(x) is an interval [a, b] 2 S(x) is continuous on [a, b] 3 There is a partition a = t0 < t1 < ··· < tn = b such that S(x) is linear on each subinterval [ti, ti+1]. Example x x 2 [-1, 0] S(x) = 80 x 2 (0, 1) <>2x - 2 x 2 [1, 2] :> T. Gambill (UIUC) CS 357 April 12, 2011 7 / 38 Degree 1 Splines Given data t0,..., tn and y0,..., yn, how do we form a spline? We need two things to hold in the interval [a, b] = [t0, tn]: 1 S(ti) = yi for i = 0,..., n 2 S(x) = Si(x) = aix + bi for x 2 [ti, ti+1] and i = 0,..., n - 1 Write Si(x) in point-slope form Si(x) = yi + mi(x - ti) yi+1 - yi = yi + (x - ti) ti+1 - ti T. Gambill (UIUC) CS 357 April 12, 2011 8 / 38 Evaluation of a Degree 1 Splines: Computing S(x) 1 input t, y vectors of data 2 input evaluation location x 3 find interval i with x 2 [ti, ti+1] 4 S(x) = yi + (x - ti) ((yi+1 - yi)=(ti+1 - ti)) T. Gambill (UIUC) CS 357 April 12, 2011 9 / 38 Determining the coefficients of Si(x) for a Degree 1 Spline Input n + 1 data points t0,..., tn,y0,..., yn Si(x) view: in each interval we have S(x) = Si(x) = aix + bi for x 2 [ti, ti+1], and i = 0,..., n - 1 2 unknowns ai, bi per interval [ti, ti+1] we have Si(ti) = yi and Si(ti+1) = yi+1, for i = 1,..., n - 1 and S0(t0) = y0 and Sn-1(tn) = yn. S(x) view: 2n total unknowns 2 constraints (equations) per interval gives 2n total constraints T. Gambill (UIUC) CS 357 April 12, 2011 10 / 38 Degree 2 Splines definition A function S(x) is a spline of degree 2 if: 1 The domain of S(x) is an interval [a, b] 2 S(x) is continuous on [a, b] 3 S0(x) is continuous on [a, b] 4 There is a partition a = t0 < t1 < ··· < tn = b such that S(x) is quadratic on each subinterval [ti, ti+1]. T. Gambill (UIUC) CS 357 April 12, 2011 11 / 38 Degree 2 Splines S0(x) x 2 [t0, t1] 8S1(x) x 2 [t1, t2] S(x) = >. >. <> Sn-1(x) x 2 [tn-1, tn] > > for each i = 0, 1,..., n - 1 we have:> 2 Si(x) = aix + bix + ci What are ai, bi, ci? T. Gambill (UIUC) CS 357 April 12, 2011 12 / 38 Degree 2 Splines 3 unknowns ai, bi, ci in each interval [ti, ti+1] for i = 0, 1,..., n - 1 3n total unknowns 2n constraints (equations) for matching up the input data (continuity of S(x)): Si(ti) = yi, Si(ti+1) = yi+1 n - 1 interior points require continuity of S0(x): 0 0 Si (ti+1) = Si+1(ti+1) for i = 0, 2,..., n - 2 but this is just n - 1 constraints total of 3n - 1 constraints 0 extra consraint: S (t0) =given, for example. T. Gambill (UIUC) CS 357 April 12, 2011 13 / 38 Degree 3 Spline: Cubic splines definition A function S(x) is a spline of degree 3 if: 1 The domain of S(x) is an interval [a, b] 2 S(x) is continuous on [a, b] 3 S0(x) is continuous on [a, b] 4 S00(x) is continuous on [a, b] 5 There is a partition a = t0 < t1 < ··· < tn = b such that S(x) is cubic on each subinterval [ti, ti+1]. T. Gambill (UIUC) CS 357 April 12, 2011 14 / 38 Degree 3 Splines: Cubic Splines 4n Unknowns In each interval [ti, ti+1] for i = 0, 1,..., n - 1, S(x) looks like 2 3 Si(x) = a0,i + a1,ix + a2,ix + a3,ix n intervals, 4 unknowns per interval 4n unknowns T. Gambill (UIUC) CS 357 April 12, 2011 15 / 38 2n constraints by continuity: Si(ti) = yi and Si(ti+1) = yi+1 for i = 0, 1,..., n - 1 0 0 0 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 00 00 00 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 4n - 2 total constraints This leaves 2 extra degrees of freedom. The cubic spline is not yet unique! Degree 3 Splines: Cubic Splines 4n - 2 Constraints In each interval [ti, ti+1] for i = 0, 1,..., n - 1, S(x) looks like 2 3 Si(x) = a0,i + a1,ix + a2,ix + a3,ix n intervals, 4 unknowns per interval 4n unknowns T. Gambill (UIUC) CS 357 April 12, 2011 16 / 38 0 0 0 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 00 00 00 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 4n - 2 total constraints This leaves 2 extra degrees of freedom. The cubic spline is not yet unique! Degree 3 Splines: Cubic Splines 4n - 2 Constraints In each interval [ti, ti+1] for i = 0, 1,..., n - 1, S(x) looks like 2 3 Si(x) = a0,i + a1,ix + a2,ix + a3,ix n intervals, 4 unknowns per interval 4n unknowns 2n constraints by continuity: Si(ti) = yi and Si(ti+1) = yi+1 for i = 0, 1,..., n - 1 T. Gambill (UIUC) CS 357 April 12, 2011 16 / 38 00 00 00 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 4n - 2 total constraints This leaves 2 extra degrees of freedom. The cubic spline is not yet unique! Degree 3 Splines: Cubic Splines 4n - 2 Constraints In each interval [ti, ti+1] for i = 0, 1,..., n - 1, S(x) looks like 2 3 Si(x) = a0,i + a1,ix + a2,ix + a3,ix n intervals, 4 unknowns per interval 4n unknowns 2n constraints by continuity: Si(ti) = yi and Si(ti+1) = yi+1 for i = 0, 1,..., n - 1 0 0 0 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 T. Gambill (UIUC) CS 357 April 12, 2011 16 / 38 4n - 2 total constraints This leaves 2 extra degrees of freedom. The cubic spline is not yet unique! Degree 3 Splines: Cubic Splines 4n - 2 Constraints In each interval [ti, ti+1] for i = 0, 1,..., n - 1, S(x) looks like 2 3 Si(x) = a0,i + a1,ix + a2,ix + a3,ix n intervals, 4 unknowns per interval 4n unknowns 2n constraints by continuity: Si(ti) = yi and Si(ti+1) = yi+1 for i = 0, 1,..., n - 1 0 0 0 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 00 00 00 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 T. Gambill (UIUC) CS 357 April 12, 2011 16 / 38 This leaves 2 extra degrees of freedom. The cubic spline is not yet unique! Degree 3 Splines: Cubic Splines 4n - 2 Constraints In each interval [ti, ti+1] for i = 0, 1,..., n - 1, S(x) looks like 2 3 Si(x) = a0,i + a1,ix + a2,ix + a3,ix n intervals, 4 unknowns per interval 4n unknowns 2n constraints by continuity: Si(ti) = yi and Si(ti+1) = yi+1 for i = 0, 1,..., n - 1 0 0 0 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 00 00 00 n - 1 constraints by continuity of S (x): Si (ti+1) = Si+1(ti+1) for i = 0, 1,..., n - 2 4n - 2 total constraints T.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages43 Page
-
File Size-