computer graphics
play

Computer Graphics - Splines - Hendrik Lensch Computer Graphics - PowerPoint PPT Presentation

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


  1. Computer Graphics - Splines - Hendrik Lensch Computer Graphics WS07/08 – Splines

  2. Overview • Last Time – Image-Based Rendering • Today – Parametric Curves – Lagrange Interpolation – Hermite Splines – Bezier Splines – DeCasteljau Algorithm – Parameterization 2 Computer Graphics WS07/08 – Splines

  3. Curves • Curve descriptions – Explicit • y(x)= ± sqrt(r 2 - x 2 ), restricted domain – Implicit: • x 2 + y 2 = r 2 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 3 Computer Graphics WS07/08 – Splines

  4. Parametric curves • Separate function in each coordinate – 3D: f(t)= (x(t), y(t), z(t)) 4 Computer Graphics WS07/08 – Splines

  5. Monomials • Monomial basis – Simple basis: 1, t, t 2 , ... (t usually in [0 .. 1]) • Polynomial representation Degree (= Order – 1) ( ) ∑ n i A = = Coefficients ∈ R 3 P ( t ) x ( t ) y ( t ) z ( t ) t i = i 0 Monomials – Coefficients can be determined from a sufficient number of constraints (e.g. interpolation of given points) • Given (n+1) parameter values t i and points P i • Solution of a linear system in the A i − possible, but inconvenient • Matrix representation ⎡ ⎤ A A A x , n ´ y , n z , n ⎢ ⎥ [ ] A A A ( ) ⎢ ⎥ − − − − = = = , 1 , 1 , 1 x n y n z n 1 n n L ( ) ( ) ( ) ( ) ( ) A 1 P t x t y t z t T t t t ⎢ ⎥ M ⎢ ⎥ ⎢ ⎥ A A A ⎣ ⎦ x , 0 y , 0 z , 0 5 Computer Graphics WS07/08 – Splines

  6. Derivatives • Derivative = tangent vector – Polynomial of degree (n-1) ⎡ ⎤ A A A x , n ´ y , n z , n ⎢ ⎥ [ ] A A A ( ) ⎢ ⎥ − − − = = = − x , n 1 y , n 1 z , n 1 n 1 n- 1 L P ´( t ) x ´( t ) y ´( t ) z ´( t ) T ´( t ) A nt (n- 1 )t 1 0 ⎢ ⎥ M ⎢ ⎥ ⎢ ⎥ A A A ⎣ ⎦ x , 0 y , 0 z , 0 • Continuity and smoothness between parametric curves – C 0 = G 0 = same point – Parametric continuity C 1 • Tangent vectors are identical – Geometric continuity G 1 • Same direction of tangent vectors – Similar for higher derivatives 6 Computer Graphics WS07/08 – Splines

  7. 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

  8. Lagrange Interpolation • Interpolating basis functions – Lagrange polynomials for a set of parameters T={t 0 , ..., t n } − = ⎧ n t t 1 i j = ∏ = δ = j n n ⎨ L ( t ) , with L ( t ) − i i j ij ⎩ t t 0 otherwise = j o i j ≠ i j • Properties – Good for interpolation at given parameter values • At each t i : 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 ) L ( t ) P i i = i 0 8 Computer Graphics WS07/08 – Splines

  9. Lagrange Interpolation • Simple Linear Interpolation – T={t 0 , t 1 } − t t = 1 1 L ( t ) 1 1 1 L 0 L 1 − 0 t t 0 1 − t t = 1 0 L ( t ) − 1 t t 1 0 t 0 t 1 • Simple Quadratic Interpolation – T={t 0 , t 1, t 2 } 1 − − t t t t = 2 1 2 L 0 ) ( t − − t t t t 2 L 0 t 0 t 1 t 2 0 1 0 2 1 L 0 -1 9 Computer Graphics WS07/08 – Splines

  10. 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 10 Computer Graphics WS07/08 – Splines

  11. 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 11 Computer Graphics WS07/08 – Splines

  12. Linear Interpolation • Hat Functions and Linear Splines 1 y 2 y 3 T(t) -1 0 1 1 2 3 4 < − ⎧ 0 t 1 ⎪ + − ≤ < ⎪ 1 1 0 t t = ⎨ T (t) − ≤ < 1 t 0 t 1 ⎪ ⎪ ≥ ⎩ 0 t 1 1 2 3 4 = ∑ = − = + T ( t ) T ( t i ) P(t) P T ( t ) y T ( t ) y T ( t ) i i 2 2 3 3 i 12 Computer Graphics WS07/08 – Splines

  13. Hermite Interpolation • Hermite Basis (cubic) – Interpolation of position P and tangent P ´ information for t= {0, 1} 3 H 3 H 3 0 0 1 – Basis functions = − + 3 2 H ( t ) ( 1 t ) ( 1 2 t ) 3 H 0 1 = − 3 2 H ( t ) t ( 1 t ) 1 = − − 3 2 H ( t ) t ( 1 t ) 3 H 2 2 = − 3 2 H ( t ) ( 3 2 t ) t 3 13 Computer Graphics WS07/08 – Splines

  14. Hermite Interpolation • Properties of Hermite Basis Functions – H 0 (H 3 ) interpolates smoothly from 1 to 0 (1 to 0) – H 0 and H 3 have zero derivative at t= 0 and t= 1 3 3 H H 3 0 • No contribution to derivative (H 1 , H 2 ) – H 1 and H 2 are zero at t= 0 and t= 1 • No contribution to position (H 0 , H 3 ) 3 H – H 1 (H 2 ) has slope 1 at t= 0 (t= 1) 1 • Unit factor for specified derivative vector 3 H • Hermite polynomials 2 – P 0 , P` 1 are positions ∈ R 3 – P` 0 , P 1 are derivatives (tangent vectors) ∈ R 3 = + + + 3 3 3 3 P ( t ) P H ( t ) P ´ H ( t ) P ´ H ( t ) P H ( t ) 0 0 0 1 1 2 1 3 14 Computer Graphics WS07/08 – Splines

  15. Examples: Hermite Interpolation 15 Computer Graphics WS07/08 – Splines

  16. Matrix Representation • Matrix representation ⎡ ⎤ A A A x , n ´ y , n z , n ⎢ ⎥ [ ] A A A ⎢ ⎥ − − − = = x , n 1 y , n 1 z , n 1 3 2 L P ( t ) t t 1 ⎢ ⎥ M ⎢ ⎥ ⎢ ⎥ A A A ⎣ ⎦ x , 0 y , 0 z , 0 ⎡ ⎤ ⎡ ⎤ G G G M M M x , 3 y , 3 z , 3 11 12 13 ⎢ ⎥ ⎢ ⎥ [ ] O G G G M ⎢ ⎥ ⎢ ⎥ = x , 2 y , 2 z , 2 21 3 2 L t t 1 ⎢ ⎥ 1 4 2 4 4 3 4 ⎢ ⎥ G G G x , 1 y , 1 y , 1 ⎢ ⎥ ⎢ ⎥ T ⎢ ⎥ ⎣ ⎦ G G G ⎣ ⎦ , 0 , 0 , 0 1 4 4 4 4 2 4 4 4 4 3 x y z 1 4 4 4 2 4 4 4 3 Basis Matrix M (4x4) Geometry Matrix G (4x3) ⎡ ⎤ ⎡ ⎤ T M M M P 11 12 13 0 ⎢ ⎥ ⎢ ⎥ [ ] O T M ⎢ P ⎥ ⎢ ⎥ 21 3 2 1 L 1 t t ⎢ ⎥ ⎢ ⎥ T P ´ ⎢ ⎥ ⎢ ⎥ 0 ⎢ ⎥ T ⎣ ⎦ ⎣ ⎦ P ´ 1 4 4 4 4 2 4 4 4 4 3 1 2 3 1 1 4 4 4 4 4 4 4 2 4 4 4 M 4 4 4 4 3 G H H Basis Functions 16 Computer Graphics WS07/08 – Splines

  17. Matrix Representation • For cubic Hermite interpolation we obtain: ⎛ ⎞ = ⎛ ⎞ T T ( 0 0 0 1 ) M G 0 0 0 1 P P ⎜ ⎟ ⎜ ⎟ 0 H H 0 = ⎜ ⎟ ⎜ ⎟ T T 1 1 1 1 P ( 1 1 1 1 ) M G P = = 1 H H 1 or ⎜ ⎟ G M G ⎜ ⎟ ′ = H H H T T 0 0 1 0 P ´ ( 0 0 1 0 ) M G P ⎜ ⎟ ⎜ ⎟ 0 H H 0 ⎜ ⎟ ⎜ ⎟ ′ = T T ⎝ ⎠ ⎝ ⎠ P ´ ( 3 2 1 0 ) M G 3 2 1 0 P 1 H H 1 • 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 17 Computer Graphics WS07/08 – Splines

  18. 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(b 1 -b 0 ) and P ´ 1 = 3(b 3 -b 2 ) • Factor 3 due to derivative of t 3 ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ T T 1 0 0 0 b P ⎢ ⎥ 0 0 ⎢ ⎥ ⎢ ⎥ T T 0 0 0 1 ⎢ ⎥ b P ⎢ ⎥ ⎢ ⎥ = = = 1 1 G M G ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − H HB B T T 3 3 0 0 b P ´ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ 2 0 − ⎢ ⎥ ⎢ ⎥ T T ⎣ ⎦ 0 0 3 3 ⎣ ⎦ ⎣ ⎦ b P ´ 3 1 18 Computer Graphics WS07/08 – Splines

Recommend


More recommend