introduction to computer graphics modeling 1
play

Introduction to Computer Graphics Modeling (1) April 13, 2017 - PowerPoint PPT Presentation

Introduction to Computer Graphics Modeling (1) April 13, 2017 Kenshi Takayama Parametric curves X & Y coordinates defined by parameter t ( time) Example: Cycloid = sin = 1 cos


  1. Introduction to Computer Graphics – Modeling (1) – April 13, 2017 Kenshi Takayama

  2. Parametric curves • X & Y coordinates defined by parameter t ( ≅ time) • Example: Cycloid 𝑦 𝑢 = 𝑢 − sin 𝑢 𝑧 𝑢 = 1 − cos 𝑢 • Tangent (aka. derivative, gradient) vector: 𝑦 ′ 𝑢 , 𝑧 ′ 𝑢 • Polynomial curve: 𝑦 𝑢 = 𝑗 𝑏 𝑗 𝑢 𝑗 2

  3. Cubic Hermite curves x 𝑦 0 = 𝑦 0 • Cubic polynomial curve interpolating 𝑦 1 = 𝑦 1 derivative constraints at both ends ′ 𝑦′(0) = 𝑦 0 𝑦 ′ 1 = 𝑦 1 (Hermite interpolation) 0 1 t ′ • 4 constraints  4 DoF needed 𝑦 0 = 𝑏 0 = 𝑦 0  4 coefficients  cubic 𝑦 1 = 𝑏 0 + 𝑏 1 + 𝑏 2 + 𝑏 3 = 𝑦 1 𝑦 ′ 0 = 𝑏 1 ′ = 𝑦 0 • 𝑦 𝑢 = 𝑏 0 + 𝑏 1 𝑢 + 𝑏 2 𝑢 2 + 𝑏 3 𝑢 3 𝑦 ′ 1 = 𝑏 1 + 2 𝑏 2 + 3 𝑏 3 ′ = 𝑦 1 • 𝑦′ 𝑢 = 𝑏 1 + 2𝑏 2 𝑢 + 3𝑏 3 𝑢 2  𝑏 0 = 𝑦 0 • Coeffs determined by substituting ′ 𝑏 1 = 𝑦 0 ′ − 𝑦 1 constrained values & derivatives ′ 𝑏 2 = −3 𝑦 0 + 3 𝑦 1 − 2 𝑦 0 ′ + 𝑦 1 ′ 𝑏 3 = 2 𝑦 0 − 2 𝑦 1 + 𝑦 0 3

  4. Bezier curves • Input: 3 control points 𝑄 0 , 𝑄 𝑄 1 , 𝑄 2 1 • Coordinates of points in arbitrary domain (2D, 3D, ...) 𝑄 𝑢 = ? Eq. of Bezier curve 𝑄 2 • Output: Curve 𝑄 𝑢 satisfying t=1 𝑄 0 = 𝑄 0 𝑄 0 𝑄 𝑢 = 1 − 𝑢 𝑄 0 + 𝑢 𝑄 2 𝑄 1 = 𝑄 2 t=0 Eq. of line segment while being “pulled” by 𝑄 1 4

  5. 𝑄 1 Bezier curves Eq. of line 𝑢 𝑄 12 𝑢 1 − 𝑢 Eq. of line 1 − 𝑢 • 𝑄 01 𝑢 = 1 − 𝑢 𝑄 0 + 𝑢 𝑄 𝑄 01 𝑢 𝑢 1 − 𝑢 1 𝑄 012 𝑢 • 𝑄 12 𝑢 = 1 − 𝑢 𝑄 1 + 𝑢 𝑄 2 𝑄 2 • 𝑄 01 0 = 𝑄 0 𝑢 • 𝑄 12 1 = 𝑄 2 𝑄 0 • Idea: ”Interpolate the interpolation” As 𝑢 changes 0 → 1 , smoothly transition from 𝑄 01 to 𝑄 12 • 𝑄 012 𝑢 = 1 − 𝑢 𝑄 01 𝑢 + 𝑢 𝑄 12 𝑢 = 1 − 𝑢 1 − 𝑢 𝑄 0 + 𝑢 𝑄 1 + 𝑢 1 − 𝑢 𝑄 1 + 𝑢 𝑄 2 = 1 − 𝑢 2 𝑄 0 + 2𝑢 1 − 𝑢 𝑄 1 + 𝑢 2 𝑄 2 Quadratic Bezier curve 5

  6. 𝑄 1 Bezier curves • 𝑄 01 𝑢 = 1 − 𝑢 𝑄 0 + 𝑢 𝑄 1 • 𝑄 12 𝑢 = 1 − 𝑢 𝑄 1 + 𝑢 𝑄 2 𝑄 2 • 𝑄 01 0 = 𝑄 0 • 𝑄 12 1 = 𝑄 2 𝑄 0 • Idea: ”Interpolate the interpolation” As 𝑢 changes 0 → 1 , smoothly transition from 𝑄 01 to 𝑄 12 • 𝑄 012 𝑢 = 1 − 𝑢 𝑄 01 𝑢 + 𝑢 𝑄 12 𝑢 = 1 − 𝑢 1 − 𝑢 𝑄 0 + 𝑢 𝑄 1 + 𝑢 1 − 𝑢 𝑄 1 + 𝑢 𝑄 2 = 1 − 𝑢 2 𝑄 0 + 2𝑢 1 − 𝑢 𝑄 1 + 𝑢 2 𝑄 2 Quadratic Bezier curve 6

  7. Cubic Bezier curve Quad. Bezier 𝑄 123 𝑢 𝑄 2 𝑄 1 • Exact same idea applied to 4 points 𝑄 0 , 𝑄 1 , 𝑄 2 𝑄 3 : Quad. Bezier 1 − 𝑢 𝑄 012 𝑢 • As 𝑢 changes 0 → 1 , transition from 𝑄 012 to 𝑄 𝑄 0123 𝑢 123 𝑄 3 𝑢 𝑄 0 • 𝑄 0123 𝑢 = 1 − 𝑢 𝑄 012 𝑢 + 𝑢 𝑄 123 𝑢 = 1 − 𝑢 1 − 𝑢 2 𝑄 0 + 2𝑢 1 − 𝑢 𝑄 1 + 𝑢 2 𝑄 2 + 𝑢 1 − 𝑢 2 𝑄 1 + 2𝑢 1 − 𝑢 𝑄 2 + 𝑢 2 𝑄 3 1 + 3𝑢 2 1 − 𝑢 𝑄 2 + 𝑢 3 𝑄 3 = 1 − 𝑢 3 𝑄 0 + 3𝑢 1 − 𝑢 2 𝑄 Cubic Bezier curve 7

  8. Cubic Bezier curve 𝑄 2 𝑄 1 • Exact same idea applied to 4 points 𝑄 0 , 𝑄 1 , 𝑄 2 𝑄 3 : • As 𝑢 changes 0 → 1 , transition from 𝑄 012 to 𝑄 𝑄 0123 𝑢 123 𝑄 3 𝑄 0 • 𝑄 0123 𝑢 = 1 − 𝑢 𝑄 012 𝑢 + 𝑢 𝑄 123 𝑢 = 1 − 𝑢 1 − 𝑢 2 𝑄 0 + 2𝑢 1 − 𝑢 𝑄 1 + 𝑢 2 𝑄 2 + 𝑢 1 − 𝑢 2 𝑄 1 + 2𝑢 1 − 𝑢 𝑄 2 + 𝑢 2 𝑄 3 1 + 3𝑢 2 1 − 𝑢 𝑄 2 + 𝑢 3 𝑄 3 = 1 − 𝑢 3 𝑄 0 + 3𝑢 1 − 𝑢 2 𝑄 Cubic Bezier curve • Can easily control tangent at endpoints  ubiquitously used in CG 8

  9. n-th order Bezier curve • Input: n+1 control points 𝑄 0 , ⋯ , 𝑄 𝑜 𝑜 𝑜 C 𝑗 𝑢 𝑗 1 − 𝑢 𝑜−𝑗 𝑄 𝑗 𝑄 𝑢 = 𝑜 (𝑢) 𝑗=0 𝑐 𝑗 Bernstein basis function 1 − 𝑢 4 𝑄 0 1 − 𝑢 5 𝑄 0 + + Quartic (4 th ) Quintic (5 th ) 4𝑢 1 − 𝑢 3 𝑄 5𝑢 1 − 𝑢 4 𝑄 + + 1 1 6𝑢 2 1 − 𝑢 2 𝑄 2 + 10𝑢 2 1 − 𝑢 3 𝑄 2 + 4𝑢 3 1 − 𝑢 𝑄 3 10𝑢 3 1 − 𝑢 2 𝑄 3 + + 5𝑢 4 1 − 𝑢 𝑄 𝑢 4 𝑄 + 4 4 𝑢 5 𝑄 5 9

  10. Cubic Bezier curves & cubic Hermite curves • Cubic Bezier curve & its derivative: 1 + 3𝑢 2 1 − 𝑢 𝑄 2 + 𝑢 3 𝑄 3 • 𝑄 𝑢 = 1 − 𝑢 3 𝑄 0 + 3𝑢 1 − 𝑢 2 𝑄 • 𝑄 ′ (𝑢) = −3 1 − 𝑢 2 𝑄 0 + 3 1 − 𝑢 2 − 2𝑢(1 − 𝑢) 𝑄 1 + 3 2𝑢 1 − 𝑢 − 𝑢 2 𝑄 2 + 3𝑢 2 𝑄 3 • Derivatives at endpoints: 𝑄′(0) 1 • 𝑄 ′ 0 = −3𝑄 0 + 3𝑄 3 𝑄 ′ 0  𝑄 1 = 𝑄 0 + 1 𝑄 2 • 𝑄 ′ 1 = −3𝑄 2 + 3𝑄 3 1 3 𝑄 ′ 1  𝑄 2 = 𝑄 3 − 𝑄 1 𝑄 3 • Different ways of looking at cubic curves, 𝑄 0 𝑄′(1) essentially the same 10

  11. Evaluating Bezier curves • Method 1: Direct evaluation of polynomials • Simple & fast  , could be numerically unstable  • Method 2: de Casteljau’s algorithm • Directly after the recursive definition of Bezier curves • More computation steps  , numerically stable  • Also useful for splitting Bezier curves 11

  12. Drawing Bezier curves • In the end, everything is drawn as polyline • Main question: How to sample paramter t? • Method 1: Uniform sampling • Simple • Potentially insufficient sampling density • Method 2: Adaptive sampling • If control points deviate too much from straight line, split by de Casteljau’s algorithm 12

  13. Further control: Rational Bezier curve • Another view on Bezier curve: w 0 = w 2 = 1 “Weighted average” of control points • 𝑄 012 𝑢 = 1 − 𝑢 2 𝑄 0 + 2𝑢 1 − 𝑢 𝑄 1 + 𝑢 2 𝑄 2 = 𝜇 0 𝑢 𝑄 0 + 𝜇 1 𝑢 𝑄 1 + 𝜇 2 𝑢 𝑄 2 • Important property: partition of unity 𝜇 0 𝑢 + 𝜇 1 𝑢 + 𝜇 2 𝑢 = 1 ∀𝑢 • Multiply each 𝜇 𝑗 𝑢 by arbitrary coeff 𝑥 𝑗 : 𝜊 𝑗 𝑢 = 𝑥 𝑗 𝜇 𝑗 (𝑢) • Normalize to obtain new weights: ′ 𝑢 = 𝜊 𝑗 𝑢 𝜇 𝑗 Non-polynomial curve  can represent arcs etc. 𝑘 𝜊 𝑘 𝑢 13

  14. x 0 (t) x 1 (t) x 2 (t) x 3 (t) x 4 (t) Cubic splines x • Series of connected cubic curves • Piecewise-polynomial t 0 t 1 t 2 t 3 t 4 t 5 t • Share value & derivative at every transition of intervals (C 1 continuity) • Parameter range can be other than [0, 1] • Assumption: 𝑢 𝑙 < 𝑢 𝑙+1 • Given values as only input, we want to automatically set derivatives Curve tool in PowerPoint 14

  15. Cubic Catmull-Rom spline • Cubic function 𝑦 𝑙 (𝑢) for range 𝑢 𝑙 ≤ 𝑢 ≤ 𝑢 𝑙+1 is defined by adjacent constrained values 𝑦 𝑙−1 , 𝑦 𝑙 , 𝑦 𝑙+1 , 𝑦 𝑙+2 𝑦 𝑦 𝑙−1 𝑦 𝑙+1 𝑦 𝑙 (𝑢) 𝑦 𝑙+2 𝑦 𝑙 𝑢 𝑙−1 𝑢 𝑙 𝑢 𝑙+1 𝑢 𝑙+2 𝑢 15

  16. Cubic Catmull-Rom spline: Step 1 • As 𝑢 𝑙 → 𝑢 𝑙+1 , interpolate such that 𝑦 𝑙 → 𝑦 𝑙+1  Line 𝑢 − 𝑢 𝑙 𝑢 − 𝑢 𝑙 𝑚 𝑙 (𝑢) = 1 − 𝑦 𝑙 + 𝑦 𝑙+1 𝑢 𝑙+1 − 𝑢 𝑙 𝑢 𝑙+1 − 𝑢 𝑙 𝑦 𝑚 𝑙−1 (𝑢) 𝑚 𝑙 (𝑢) 𝑚 𝑙+1 (𝑢) 𝑢 𝑙−1 𝑢 𝑙 𝑢 𝑙+1 𝑢 𝑙+2 𝑢 16

  17. Cubic Catmull-Rom spline: Step 2 • As 𝑢 𝑙−1 → 𝑢 𝑙+1 , interpolate such that 𝑚 𝑙−1 → 𝑚 𝑙  Quadratic curve 𝑢 − 𝑢 𝑙−1 𝑢 − 𝑢 𝑙−1 𝑟 𝑙 (𝑢) = 1 − 𝑚 𝑙−1 (𝑢) + 𝑚 𝑙 (𝑢) 𝑢 𝑙+1 − 𝑢 𝑙−1 𝑢 𝑙+1 − 𝑢 𝑙−1 • Passes through 3 points 𝑢 𝑙−1 , 𝑦 𝑙−1 , 𝑢 𝑙 , 𝑦 𝑙 , 𝑢 𝑙+1 , 𝑦 𝑙+1 𝑦 𝑟 𝑙 (𝑢) 𝑟 𝑙+1 (𝑢) 𝑢 𝑙−1 𝑢 𝑙 𝑢 𝑙+1 𝑢 𝑙+2 𝑢 17

  18. Cubic Catmull-Rom spline: Step 3 • As 𝑢 𝑙 → 𝑢 𝑙+1 , interpolate such that 𝑟 𝑙 → 𝑟 𝑙+1  Cubic curve 𝑢 − 𝑢 𝑙 𝑢 − 𝑢 𝑙 𝑦 𝑙 𝑢 = 1 − 𝑟 𝑙 𝑢 + 𝑟 𝑙+1 (𝑢) 𝑢 𝑙+1 − 𝑢 𝑙 𝑢 𝑙+1 − 𝑢 𝑙 Summary: Derivative at each CP is defined by a quadratic 𝑦 • curve passing through its adjacent CPs Each interval is a cubic curve satisfying • derivative constraints at both ends 𝑦 𝑙 (𝑢) 𝑢 𝑙−1 𝑢 𝑙 𝑢 𝑙+1 𝑢 𝑙+2 𝑢 18

  19. Evaluating cubic Catmull-Rom spline 𝑄 𝑢 3 = 𝑄 3 𝑄 𝑢 1 = 𝑄 1 𝑄 𝑢 𝑢 1 ≤ 𝑢 ≤ 𝑢 2 𝑄 𝑢 2 = 𝑄 2 𝑄 𝑢 0 = 𝑄 0 A recursive evaluation algorithm for a class of Catmull-Rom splines [Barry,Colgman,SIGGRAPH88] 19

  20. Ways of setting parameter values 𝑢 𝑙 (aka. knot sequence) • Assume: 𝑢 0 = 0 • Uniform 𝑢 𝑙 = 𝑢 𝑙−1 + 1 • Chordal 𝑢 𝑙 = 𝑢 𝑙−1 + 𝑄 𝑙−1 − 𝑄 𝑙 • Centripetal 𝑢 𝑙 = 𝑢 𝑙−1 + 𝑄 𝑙−1 − 𝑄 𝑙 Parameterization of Catmull-Rom Curves [Yuksel,Schaefer,Keyser,CAD11] 20

  21. Application of cubic Catmull-Rom spline: Hair modeling Parameterization of Catmull-Rom Curves [Yuksel,Schaefer,Keyser,CAD11] 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend