Presentation is loading. Please wait.

Presentation is loading. Please wait.

Splines II – Interpolating Curves

Similar presentations


Presentation on theme: "Splines II – Interpolating Curves"— Presentation transcript:

1 Splines II – Interpolating Curves
based on: Michael Gleicher: Curves, chapter 15 in Fundamentals of Computer Graphics, 3rd ed. (Shirley & Marschner) Slides by Marc van Kreveld

2 Polynomial pieces Canonical form of a polynomial of degree n defined with vector coefficients ai Generalized form of a polynomial defined with vector coefficients ci that are blended by the m polynomials bi(t) The degree is the max of the degrees of the bi(t) Note: the b_i are normal polynomials in t, they are not vectors like a and c and f. So c_i b_i(t) is vector-scalar multiplication. Using blending polynomials is the way to make splines

3 Example Canonical form: f(t) = (2,3) + (0,1) t + (5,2) t2 + (-1,-1) t3
A generalized form could be: f(t) = (7,-3) (t - t3) + (3,1) (t + t2 + t3) Or it could be: f(t) = (0,3) (t - t3) + (-4,1) (t - 2t2 + t3) + (0,1) (t + t2) + (-9,2) (2t2 + t3) + (0,1) (7t + t2 + 6t3) The canonical form of a cubic always has four coefficients, a generalized form can have any number of coefficients

4 Recall: Basis and constraint matrices
Specifications of a curve give a constraint matrix p0 = f(0) = a a a2 p1 = f(0.5) = a a a2 p2 = f(1) = a a a2 Its inverse B = C–1 is the basis matrix (quadratic curve)

5 Blending functions Blending functions (or basis functions) are functions of u and specify how to “mix” the specified constraints (points to pass through, derivatives, …) Let u = [ 1 u u2 u3 … un ] be the powers of u b(u) = u B, a vector whose elements are the blending functions

6 Blending functions u = [ 1 u u2 u3 … un ]
b(u) = u B so we obtain for the usual quadric example with three points specified: Three points specified, meaning the one at u=0, u=0.5, and u=1.

7 Blending functions We can now blend the control points

8 Blending functions We see the contributions of each point depending on u For fixed u, we linearly interpolate the three points

9 Blending functions 1 For any fixed u, this is linear interpolation of the three points 1 0.5 u

10 Blending functions Note the sum of the contributions +

11 Polynomials for interpolation
Given points p = (p0, p1, … , pn) and increasing parameter values t = (t0, t1, … , tn), we can make a polynomial of degree n that passes through pi exactly at parameter value ti so f(ti) = pi p1 p2 p5 p4 p0 p3

12 Polynomials for interpolation
Given points p = (p0, p1, … , pn) and increasing parameter values t = (t0, t1, … , tn), we can make a polynomial of degree n that passes through pi exactly at parameter value ti so f(ti) = pi p1 p2 p5 Assuming the same five points, the same t_0, t_2, t_3, and t_5 for both curves, we get a different shape when changing t_1 and t_4 p4 p0 p3 the brown curve has t1’ > t1 and t4’ < t4

13 Polynomials for interpolation
Method Set up constraint matrix as before Invert to get basis matrix, giving the n+1 basis functions bi(t) and the polynomial f(t) : Alternative method (Lagrange form)

14 Why not use polynomials to interpolate 5 or more points
Polynomials of higher degree have extra wiggles overshoots non-locality: moving the point pn changes the curve even near p0 ; also when we add a point at the end

15 Why not use polynomials to interpolate 5 or more points
This gets worse with higher degree (more points) Suppose we get the six (eleven) points that were sampled from the purple curve, but we don’t know the purple curve. We want to use the six (eleven) points to reconstruct the curve using an interpolating polynomial. The polynomial needs to have degree five (ten) to be sure that it passes through all six (eleven) points. The interpolating polynomial of degree five (ten) is shown in green.

16 Blending again A piecewise-linear curve (polygonal line) can also be defined using blending functions 1 0  u  0.5 0.5  u  1 p1 p0 1 p2 0.5 u

17 Piecewise cubic polynomials
Allows position and derivative at each end Allows C2 continuity Are in a sense the most smooth curve: minimum curvature over its length (curvature: second derivative) curvature low curvature 0 curvature high

18 Cubic polynomials f(u) = a0 + a1 u + a2 u2 + a3 u3 in canonical form
Four control points (points or derivatives on curve) needed For piecewise cubic curves: n pieces require 4n control points, but C0 continuity already fixes n – 1 of them

19 Cubic polynomials The ideal properties:
Each piece is cubic The curve interpolates the control points The curve has local control The curve has C2 continuity We can have any three but not all four properties: Natural cubics do not have local control Cubic B-splines do not interpolate the control points Cardinal splines are not C2

20 Natural cubics The first piece specifies start and end positions, and the first and second derivative at the start For each other piece, the position, first and second derivative match with the piece before it  only the endpoint can be specified freely A curve with n pieces has n+3 control “points” in total (n+1 points and 2 derivative specifications) p1 p2 p0 p3

21 Natural cubics We get (with f(u) = a0 + u a1 + u2 a2 + u3 a3): p0 = f (0) = a a a a3 p1 = f’(0) = a1 + 20 a2 + 302 a3 p2 = f’’(0) = a2 + 60 a3 p3 = f (1) = a a a a3 constraint matrix

22 Natural cubics When you modify your natural cubic, for instance by changing the derivative at the start of the first piece, then the whole curve changes  not local

23 Hermite cubics Specifies positions of start and end, and the derivatives at these points C1 continuous since the start position of a piece must be the same as the end position of the previous piece, and the same is true for the derivatives A curve with n pieces has 2n+2 control “points” in total p1 p2 p0 p3

24 Hermite cubics Local control: changing the position or derivative of any point influences only the piece before and the piece after that point See slides of Curves I lecture

25 Cardinal cubics Specifies positions only; the derivatives at each point are determined by the points before and after it C1 continuous A curve with n pieces has n+3 control points in total p1 p2 p3 p0 p1 p3 p0 p2

26 Cardinal cubics A tension parameter t  [0,1) determines the “strength” of bending Each derivative vector pi-1 pi+1 is scaled by (1 – t)/2 p1 p1 p2 p2 Note: literature often uses tension in differently, namely multiplication of the vector by t instead of (1-t)/2 p0 p0 p3 p3 t = 0 (Catmull-Rom splines) t = 0.5

27 Cardinal cubics Red cardinal spline: very high tension, derivatives at control points ignored, so t = 1 and (1-t)/2 = 0 Orange to purple: lower and lower tension

28 Cardinal cubics We can set up the constraints: f(0) = p1 f(1) = p2 f’(0) = ½ (1 – t) (p2 – p0) f’(1) = ½ (1 – t) (p3 – p1) Rewrite to get expressions for p0, p1, p2 and p3 The first and last pieces are not yet specified; no derivative is specified at p0 and pn Therefore, imagine points p-1, pn+1 as additional first and last points  n pieces require n+3 control points p2 p0 p3 p1

29 Summary Piecewise cubic curves are popular for modeling
We want C2 continuity, locality, and interpolation; we can get only two of these with cubics Natural cubics do not have locality Hermite cubics are only C1 continuous Cardinal cubics are only C1 continuous The splines that follow next (Bezier and B-spline) will not interpolate but approximate the control points

30 Questions Assume piecewise linear interpolation by blending functions, where the curve passes through points p0, p1, p2, p3, and p4 at u = 0, 0.25, 0.5, 0.75, and 1. Define the five blending functions bi (u) so that Assume that someone defines quadratic blending functions as on slides 5-9, except that b2(u) = u2. Does the resulting curve pass through its defining points. Is the resulting curve translation-invariant?


Download ppt "Splines II – Interpolating Curves"

Similar presentations


Ads by Google