Splines & Interpolation

Splines & Interpolation

Computer Graphics - Splines - Hendrik Lensch Computer Graphics WS07/08 – Splines Overview • Last Time – Image-Based Rendering • Today – Parametric Curves – Lagrange Interpolation – Hermite Splines – Bezier Splines – DeCasteljau Algorithm – Parameterization Computer Graphics WS07/08 – Splines 2 Curves • Curve descriptions –Explicit • y(x)= ± sqrt(r2 -x2), restricted domain – Implicit: •x2 + y2 = r2 unknown solution set – Parametric: • x(t)= r cos(t), y(t)= r sin(t), t ∈ [0, 2π] • Flexibility and ease of use • Polynomials – Avoids complicated functions (z.B. pow, exp, sin, sqrt) – Use simple polynomials of low degree Computer Graphics WS07/08 – Splines 3 Parametric curves • Separate function in each coordinate – 3D: f(t)= (x(t), y(t), z(t)) Computer Graphics WS07/08 – Splines 4 Monomials • Monomial basis – Simple basis: 1, t, t2, ... (t usually in [0 .. 1]) • Polynomial representation Degree (= Order – 1) n i Coefficients ∈R3 P(t) = ()x(t) y(t) z(t) = ∑t Ai i=0 Monomials – Coefficients can be determined from a sufficient number of constraints (e.g. interpolation of given points) • Given (n+1) parameter values ti and points Pi • Solution of a linear system in the Ai − possible, but inconvenient • Matrix representation ⎡ Ax,n A´y,n Az,n ⎤ ⎢A A A ⎥ n n−1 ⎢ x,n−1 y,n−1 z,n−1 ⎥ P(t) = ()x(t) y(t) z(t) = T (t) A = []t t L 1 ⎢ M ⎥ ⎢ ⎥ ⎣⎢ Ax,0 Ay,0 Az,0 ⎦⎥ Computer Graphics WS07/08 – Splines 5 Derivatives • Derivative = tangent vector – Polynomial of degree (n-1) ⎡ Ax,n A´y,n Az,n ⎤ ⎢A A A ⎥ n−1 n-1 ⎢ x,n−1 y,n−1 z,n−1 ⎥ P´(t) = ()x´(t) y´(t) z´(t) = T´(t) A = []nt (n-1)t L 1 0 ⎢ M ⎥ ⎢ ⎥ ⎣⎢ Ax,0 Ay,0 Az,0 ⎦⎥ • Continuity and smoothness between parametric curves –C0 = G0 = same point – Parametric continuity C1 • Tangent vectors are identical – Geometric continuity G1 • Same direction of tangent vectors – Similar for higher derivatives Computer Graphics WS07/08 – Splines 6 More on Continuity • at one point: • Geometric Continuity: – G0: curves are joined – G1: first derivatives are proportional at joint point, same direction but not necessarily same length – G2: first and second derivatives are proportional • Parametric Continuity: – C0: curves are joined – C1: first derivative equal – C2: first and second derivatives are equal. If t is the time, this implies the acceleration is continuous. – Cn: all derivatives up to and including the nth are equal. Computer Graphics WS07/08 – Splines Lagrange Interpolation • Interpolating basis functions – Lagrange polynomials for a set of parameters T={t0, ..., tn} n n t − t j n ⎧1 i = j Li (t) = ∏ , with Li (t j ) = δij = ⎨ j=o ti − t j ⎩0 otherwise i≠ j • Properties – Good for interpolation at given parameter values • At each ti: One basis function = 1, all others = 0 – Polynomial of degree n (n factors linear in t) • Lagrange Curves – Use Lagrange Polynomials with point coefficients n n P(t) = ∑ Li (t)Pi i=0 Computer Graphics WS07/08 – Splines 8 Lagrange Interpolation • Simple Linear Interpolation –T={t0, t1} t − t 1 1 1 L 1 L 1 L0 (t) = 0 1 t0 − t1 1 t − t0 L1(t) = t1 − t0 t t • Simple Quadratic Interpolation0 1 –T={t0, t1, t2} 1 2 t − t1 t − t2 L0 (t) = 2 t0 − t1 t0 − t2 t0 t1 L0 t2 1 L0 -1 Computer Graphics WS07/08 – Splines 9 Problems • Problems with a single polynomial – Degree depends on the number of interpolation constraints – Strong overshooting for high degree (n > 7) – Problems with smooth joints – Numerically unstable – No local changes Computer Graphics WS07/08 – Splines 10 Splines • Functions for interpolation & approximation – Standard curve and surface primitives in geometric modeling – Key frame and in-betweens in animations – Filtering and reconstruction of images • Historically – Name for a tool in ship building • Flexible metal strip that tries to stay straight – Within computer graphics: • Piecewise polynomial function What Continuity ? Segment 1 Segment 2 Segment 3 Segment 4 Computer Graphics WS07/08 – Splines 11 Linear Interpolation • Hat Functions and Linear Splines 1 y2 y3 T(t) -1 01 1 234 ⎧ 0 t < −1 ⎪ ⎪1+ t −1≤ t < 0 T(t) = ⎨ ⎪1− t 0 ≤ t <1 1 234 ⎩⎪ 0 t ≥1 P(t) = ∑ PiTi (t) = y2T2 (t) + y3T3 (t) Ti (t) = T(t − i) Computer Graphics WS07/08 – Splines 12 Hermite Interpolation • Hermite Basis (cubic) – Interpolation of position P and tangent P´ information for t= {0, 1} 3 H3 H0 3 01 – Basis functions 3 2 H0 (t) = (1− t) (1+ 2t) 3 H1 3 2 H1 (t) = t(1− t) 3 2 H 2 (t) = −t (1− t) 3 H2 3 2 H3 (t) = (3− 2t)t Computer Graphics WS07/08 – Splines 13 Hermite Interpolation • Properties of Hermite Basis Functions –H0 (H3) interpolates smoothly from 1 to 0 (1 to 0) –Hand H have zero derivative at t= 0 and t= 1 3 H3 0 3 H0 3 • No contribution to derivative (H1, H2) –H1 and H2 are zero at t= 0 and t= 1 • No contribution to position (H , H ) 0 3 3 H1 –H1 (H2) has slope 1 at t= 0 (t= 1) • Unit factor for specified derivative vector H3 • Hermite polynomials 2 3 –P0, P`1 are positions ∈R 3 –P`0, P1 are derivatives (tangent vectors) ∈R 3 3 3 3 P(t) = P0 H 0 (t) + P0´H1 (t) + P1´H 2 (t) + P1H3 (t) Computer Graphics WS07/08 – Splines 14 Examples: Hermite Interpolation Computer Graphics WS07/08 – Splines 15 Matrix Representation • Matrix representation ⎡ Ax,n A´y,n Az,n ⎤ ⎢A A A ⎥ 3 2 ⎢ x,n−1 y,n−1 z,n−1 ⎥ P(t) = []t t L 1 = ⎢ M ⎥ ⎢ ⎥ ⎣⎢ Ax,0 Ay,0 Az,0 ⎦⎥ ⎡M11 M12 M13 ⎤ ⎡Gx,3 Gy,3 Gz,3 ⎤ ⎢ ⎥ ⎢M ⎥ G G G 3 2 ⎢ 21 O ⎥ ⎢ x,2 y,2 z,2 ⎥ []t t L 1 = 1424 434 ⎢ ⎥ ⎢Gx,1 Gy,1 Gy,1 ⎥ T ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣⎢Gx,0 Gy,0 Gz,0 ⎦⎥ 142444 43444 14244 4344 Basis Matrix M (4x4) Geometry Matrix G (4x3) T ⎡M11 M12 M13 ⎤⎡ P0 ⎤ ⎢ ⎥⎢ T ⎥ 3 2 M 21 O P1 []t t 1 ⎢ ⎥⎢ ⎥ L ⎢ T ⎥ ⎢ ⎥ P´0 ⎢ ⎥⎢ T ⎥ ⎣ ⎦⎣⎢P´1 ⎦⎥ 142444 43444 123 M G 142444444 4344H 4444 H Basis Functions Computer Graphics WS07/08 – Splines 16 Matrix Representation • For cubic Hermite interpolation we obtain: PT = (0 0 0 1)M G ⎛ PT ⎞ ⎛0 0 0 1⎞ 0 H H ⎜ 0 ⎟ ⎜ ⎟ T T P1 = (1 1 1 1)M H G H ⎜ P ⎟ ⎜1 1 1 1⎟ or 1 = G = M G P´T = (0 0 1 0)M G ⎜ P′T ⎟ H ⎜0 0 1 0⎟ H H 0 H H ⎜ 0 ⎟ ⎜ ⎟ P´T = (3 2 1 0)M G ⎜ T ⎟ ⎜ ⎟ 1 H H ⎝ P1′ ⎠ ⎝3 2 1 0⎠ • Solution: – Two matrices must multiply to unit matrix −1 ⎛0 0 0 1⎞ ⎛ 2 − 2 1 1 ⎞ ⎜ ⎟ ⎜ ⎟ ⎜1 1 1 1⎟ ⎜− 3 3 − 2 −1⎟ M = = H ⎜0 0 1 0⎟ ⎜ 0 0 1 0 ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎝3 2 1 0⎠ ⎝ 1 0 0 0 ⎠ Computer Graphics WS07/08 – Splines 17 Bézier • Bézier Basis [deCasteljau´59, Bézier´62] – Different curve representation – Start and end point – 2 point that are approximated by the curve (cubics) –P´0= 3(b1-b0) and P´1= 3(b3-b2) • Factor 3 due to derivative of t3 T T ⎡ P0 ⎤ ⎡ 1 0 0 0⎤⎡b0 ⎤ ⎢ T ⎥ ⎢ ⎥⎢ T ⎥ P 0 0 0 1 b G = ⎢ 1 ⎥ = ⎢ ⎥⎢ 1 ⎥ = M G H ⎢P´ T ⎥ ⎢− 3 3 0 0⎥⎢bT ⎥ HB B ⎢ 0 ⎥ ⎢ ⎥⎢ 2 ⎥ T 0 0 − 3 3 T ⎣⎢P´1 ⎦⎥ ⎣ ⎦⎣⎢b3 ⎦⎥ Computer Graphics WS07/08 – Splines 18 Basis transformation • Transformation – P(t)=T MH GH = T MH (MHB GB) = T (MHMHB) GB = T MB GB ⎡−1 3 − 3 1⎤ 3 B0 ⎢ 3 − 6 3 0⎥ M = M M = ⎢ ⎥ B H HB ⎢− 3 3 0 0⎥ ⎢ ⎥ 3 ⎣ 1 0 0 0⎦ B3 B3 • Bézier Curves & Basis Functionss 0 3 3 3 B B P(t) = B3 (t)b = 1 2 ∑i=0 i i 3 2 2 3 (1-t) b0 + 3t(1-t) b1 + 3t (1-t)b2 + t b3 n P(t) = B n (t)b ∑i=0 i i n ⎛n⎞ i n−i with Basisfunctions Bi (t) = ⎜ ⎟t (1− t) ⎝ i ⎠ – Basis functions: Bernstein polynomials Computer Graphics WS07/08 – Splines 19 Properties: Bézier • Advantages: – End point interpolation – Tangents explicitly specified – Smooth joints are simple 1 •P3, P4, P5 collinear Æ G continuous – Geometric meaning of control points – Affine invariance ∀∑Bi(t) = 1 – Convex hull property • For 0<t<1: Bi(t) ≥ 0 – Symmetry: Bi(t) = Bn-i(1-t) • Disadvantages – Smooth joints need to be maintained explicitly • Automatic in B-Splines (and NURBS) Computer Graphics WS07/08 – Splines 20 DeCasteljau Algorithm • Direct evaluation of the basis functions – Simple but expensive • Use recursion – Recursive definition of the basis functions n n−1 n−1 Bi (t) = tBi−1 (t) + (1− t)Bi (t) – Inserting this once yields: n n−1 0 n 1 n−1 P(t) = ∑bi Bi (t) = ∑bi (t)Bi (t) i=0 i=0 – with the new Bézier points given by the recursion k k −1 k −1 0 bi (t) = tbi+1 (t) + (1− t)bi (t) and bi (t) = bi Computer Graphics WS07/08 – Splines 21 DeCasteljau Algorithm • DeCasteljau-Algorithm: – Recursive degree reduction of the Bezier curve by using the recursion formula for the Bernstein polynomials n n−1 0 n 1 n−1 n P(t) = ∑bi Bi (t) = ∑bi (t)Bi (t) = L = bi (t)⋅1 i=0 i=0 k k −1 k −1 bi (t) = tbi+1 (t) + (1− t)bi (t) • Example: –t= 0.5 Computer Graphics WS07/08 – Splines 22 DeCasteljau Algorithm • Subdivision using the deCasteljau-Algorithm – Take boundaries of the deCasteljau triangle as new control points for left/right portion of the curve • Extrapolation – Backwards subdivision • Reconstruct triangle from one side Computer Graphics WS07/08 – Splines 23 Catmull-Rom-Splines • Goal – Smooth (C1)-joints between (cubic) spline segments • Algorithm – Tangents given by neighboring points Pi-1 Pi+1 – Construct (cubic) Hermite segments • Advantage – Arbitrary number of control points – Interpolation without overshooting – Local control Computer Graphics WS07/08 – Splines 24 Matrix Representation • Catmull-Rom-Spline – Piecewise polynomial curve – Four control points per segment – For n control points we obtain (n-3) polynomial segments ⎡−1 3 − 3 1⎤⎡ PT ⎤ ⎢ i ⎥ ⎢ 2 − 5 4 1⎥ PT i 1 ⎢ i+1 ⎥ P (t) = TM G = T ⎢ __ ⎥ CR CR 2 ⎢−1 0 1 0⎥⎢PT ⎥ i+2 ⎢ ⎥⎢ T ⎥ ⎣ 0 2 0 0⎦⎢P ⎥ • Application ⎣ i+3 ⎦ – Smooth interpolation of a given sequence of points – Key frame animation, camera movement, etc.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    34 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us