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

introduction to computer graphics modeling 1
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Introduction to Computer Graphics – Modeling (1) –

April 13, 2017 Kenshi Takayama

slide-2
SLIDE 2

Parametric curves

  • X & Y coordinates defined by parameter t (≅ time)
  • Example: Cycloid

𝑦 𝑢 = 𝑢 − sin 𝑢 𝑧 𝑢 = 1 − cos 𝑢

  • Tangent (aka. derivative, gradient) vector: 𝑦′ 𝑢 , 𝑧′ 𝑢
  • Polynomial curve: 𝑦 𝑢 = 𝑗 𝑏𝑗𝑢𝑗

2

slide-3
SLIDE 3

Cubic Hermite curves

  • Cubic polynomial curve interpolating

derivative constraints at both ends (Hermite interpolation)

  • 4 constraints  4 DoF needed

 4 coefficients  cubic

  • 𝑦 𝑢 = 𝑏0 + 𝑏1𝑢 + 𝑏2𝑢2 + 𝑏3𝑢3
  • 𝑦′ 𝑢 = 𝑏1 + 2𝑏2𝑢 + 3𝑏3𝑢2
  • Coeffs determined by substituting

constrained values & derivatives

3

𝑦 0 = 𝑦0 𝑦 1 = 𝑦1 𝑦′(0) = 𝑦0

𝑦′ 1 = 𝑦1

𝑦 0 = 𝑏0 = 𝑦0 𝑦 1 = 𝑏0 + 𝑏1 + 𝑏2 + 𝑏3 = 𝑦1 𝑦′ 0 = 𝑏1 = 𝑦0

𝑦′ 1 = 𝑏1 + 2 𝑏2 + 3 𝑏3 = 𝑦1

 𝑏0 = 𝑦0 𝑏1 = 𝑦0

𝑏2 = −3 𝑦0 + 3 𝑦1 − 2 𝑦0

′ − 𝑦1 ′

𝑏3 = 2 𝑦0 − 2 𝑦1 + 𝑦0

′ + 𝑦1 ′ t x 1

slide-4
SLIDE 4

Bezier curves

  • Input: 3 control points 𝑄0, 𝑄

1, 𝑄2

  • Coordinates of points in

arbitrary domain (2D, 3D, ...)

  • Output: Curve 𝑄 𝑢 satisfying

𝑄 0 = 𝑄0 𝑄 1 = 𝑄2 while being “pulled” by 𝑄

1

4

𝑄 𝑢 = 1 − 𝑢 𝑄0 + 𝑢 𝑄2 𝑄 𝑢 = ? 𝑄

1

𝑄2 𝑄0

t=0 t=1

  • Eq. of line segment
  • Eq. of Bezier curve
slide-5
SLIDE 5

Bezier curves

  • 𝑄01 𝑢 = 1 − 𝑢 𝑄0 + 𝑢 𝑄

1

  • 𝑄

12 𝑢 = 1 − 𝑢 𝑄 1 + 𝑢 𝑄2

  • 𝑄01 0 = 𝑄0
  • 𝑄

12 1 = 𝑄2

  • 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

5

𝑄

1

𝑄2 𝑄0 𝑄

12 𝑢 𝑢 𝑢 𝑢 1 − 𝑢 1 − 𝑢

𝑄01 𝑢 𝑄012 𝑢

1 − 𝑢 Quadratic Bezier curve

  • Eq. of line
  • Eq. of line
slide-6
SLIDE 6

Bezier curves

  • 𝑄01 𝑢 = 1 − 𝑢 𝑄0 + 𝑢 𝑄

1

  • 𝑄

12 𝑢 = 1 − 𝑢 𝑄 1 + 𝑢 𝑄2

  • 𝑄01 0 = 𝑄0
  • 𝑄

12 1 = 𝑄2

  • 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

6

𝑄

1

𝑄2 𝑄0

Quadratic Bezier curve

slide-7
SLIDE 7
  • Exact same idea applied to 4 points 𝑄0, 𝑄

1, 𝑄2 𝑄3:

  • As 𝑢 changes 0 → 1, transition from 𝑄012 to 𝑄

123

  • 𝑄0123 𝑢 = 1 − 𝑢 𝑄012 𝑢 + 𝑢 𝑄

123 𝑢

= 1 − 𝑢

1 − 𝑢 2𝑄0 + 2𝑢 1 − 𝑢 𝑄

1 + 𝑢2𝑄2 + 𝑢

1 − 𝑢 2𝑄

1 + 2𝑢 1 − 𝑢 𝑄2 + 𝑢2𝑄 3

= 1 − 𝑢 3𝑄0 + 3𝑢 1 − 𝑢 2𝑄

1 + 3𝑢2 1 − 𝑢 𝑄2 + 𝑢3𝑄3

Cubic Bezier curve

7

𝑄

123 𝑢

𝑄012 𝑢 𝑄0123 𝑢

𝑢 1 − 𝑢

𝑄

1

𝑄3 𝑄0 𝑄2

Cubic Bezier curve

  • Quad. Bezier
  • Quad. Bezier
slide-8
SLIDE 8
  • Exact same idea applied to 4 points 𝑄0, 𝑄

1, 𝑄2 𝑄3:

  • As 𝑢 changes 0 → 1, transition from 𝑄012 to 𝑄

123

  • 𝑄0123 𝑢 = 1 − 𝑢 𝑄012 𝑢 + 𝑢 𝑄

123 𝑢

= 1 − 𝑢

1 − 𝑢 2𝑄0 + 2𝑢 1 − 𝑢 𝑄

1 + 𝑢2𝑄2 + 𝑢

1 − 𝑢 2𝑄

1 + 2𝑢 1 − 𝑢 𝑄2 + 𝑢2𝑄 3

= 1 − 𝑢 3𝑄0 + 3𝑢 1 − 𝑢 2𝑄

1 + 3𝑢2 1 − 𝑢 𝑄2 + 𝑢3𝑄3

  • Can easily control tangent at endpoints  ubiquitously used in CG

Cubic Bezier curve

8

𝑄

1

𝑄3 𝑄0 𝑄2 𝑄0123 𝑢

Cubic Bezier curve

slide-9
SLIDE 9

n-th order Bezier curve

  • Input: n+1 control points 𝑄0, ⋯ , 𝑄

𝑜

𝑄 𝑢 =

𝑗=0 𝑜 𝑜C𝑗 𝑢𝑗 1 − 𝑢 𝑜−𝑗 𝑄𝑗

9

𝑐𝑗

𝑜(𝑢)

Bernstein basis function

1 − 𝑢 4𝑄0 + 4𝑢 1 − 𝑢 3𝑄

1

+ 6𝑢2 1 − 𝑢 2𝑄2 + 4𝑢3 1 − 𝑢 𝑄3 + 𝑢4𝑄

4

1 − 𝑢 5𝑄0 + 5𝑢 1 − 𝑢 4𝑄

1

+ 10𝑢2 1 − 𝑢 3𝑄2 + 10𝑢3 1 − 𝑢 2𝑄3 + 5𝑢4 1 − 𝑢 𝑄

4

+ 𝑢5𝑄5

Quartic (4th) Quintic (5th)

slide-10
SLIDE 10

Cubic Bezier curves & cubic Hermite curves

  • Cubic Bezier curve & its derivative:
  • 𝑄 𝑢 = 1 − 𝑢 3𝑄0 + 3𝑢 1 − 𝑢 2𝑄

1 + 3𝑢2 1 − 𝑢 𝑄2 + 𝑢3𝑄3

  • 𝑄′(𝑢) = −3 1 − 𝑢 2𝑄0 + 3 1 − 𝑢 2 − 2𝑢(1 − 𝑢) 𝑄

1 + 3 2𝑢 1 − 𝑢 − 𝑢2 𝑄2 + 3𝑢2𝑄3

  • Derivatives at endpoints:
  • 𝑄′ 0 = −3𝑄0 + 3𝑄

1

 𝑄

1 = 𝑄0 + 1 3 𝑄′ 0

  • 𝑄′ 1 = −3𝑄2 + 3𝑄3

 𝑄2 = 𝑄3 −

1 3 𝑄′ 1

  • Different ways of looking at cubic curves,

essentially the same

10

𝑄

1

𝑄3 𝑄0 𝑄2

𝑄′(0) 𝑄′(1)

slide-11
SLIDE 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

slide-12
SLIDE 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

slide-13
SLIDE 13

Further control: Rational Bezier curve

  • Another view on Bezier curve:

“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:

𝜇𝑗

′ 𝑢 = 𝜊𝑗 𝑢 𝑘 𝜊𝑘 𝑢

13

w0 = w2 = 1

Non-polynomial curve  can represent arcs etc.

slide-14
SLIDE 14

Cubic splines

  • Series of connected cubic curves
  • Piecewise-polynomial
  • Share value & derivative at every transition
  • f intervals (C1 continuity)
  • Parameter range can be other than [0, 1]
  • Assumption: 𝑢𝑙 < 𝑢𝑙+1
  • Given values as only input,

we want to automatically set derivatives

14

t x t0 t1 t2 t3 t4 t5 x0(t) x1(t) x2(t) x3(t) x4(t) Curve tool in PowerPoint

slide-15
SLIDE 15

Cubic Catmull-Rom spline

  • Cubic function 𝑦𝑙(𝑢) for range 𝑢𝑙 ≤ 𝑢 ≤ 𝑢𝑙+1 is defined by

adjacent constrained values 𝑦𝑙−1, 𝑦𝑙, 𝑦𝑙+1, 𝑦𝑙+2

15

𝑢𝑙−1 𝑢𝑙 𝑢𝑙+1 𝑢𝑙+2 𝑢 𝑦 𝑦𝑙 𝑦𝑙−1 𝑦𝑙+1 𝑦𝑙+2 𝑦𝑙(𝑢)

slide-16
SLIDE 16

Cubic Catmull-Rom spline: Step 1

  • As 𝑢𝑙 → 𝑢𝑙+1, interpolate such that 𝑦𝑙 → 𝑦𝑙+1  Line

𝑚𝑙(𝑢) = 1 − 𝑢 − 𝑢𝑙 𝑢𝑙+1 − 𝑢𝑙 𝑦𝑙 + 𝑢 − 𝑢𝑙 𝑢𝑙+1 − 𝑢𝑙 𝑦𝑙+1

16

𝑢𝑙−1 𝑢𝑙 𝑢𝑙+1 𝑢𝑙+2 𝑢 𝑦 𝑚𝑙−1(𝑢) 𝑚𝑙(𝑢) 𝑚𝑙+1(𝑢)

slide-17
SLIDE 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

17

𝑢𝑙−1 𝑢𝑙 𝑢𝑙+1 𝑢𝑙+2 𝑢 𝑦 𝑟𝑙(𝑢) 𝑟𝑙+1(𝑢)

slide-18
SLIDE 18

Cubic Catmull-Rom spline: Step 3

  • As 𝑢𝑙 → 𝑢𝑙+1, interpolate such that 𝑟𝑙 → 𝑟𝑙+1  Cubic curve

𝑦𝑙 𝑢 = 1 − 𝑢 − 𝑢𝑙 𝑢𝑙+1 − 𝑢𝑙 𝑟𝑙 𝑢 + 𝑢 − 𝑢𝑙 𝑢𝑙+1 − 𝑢𝑙 𝑟𝑙+1(𝑢)

18

𝑢𝑙−1 𝑢𝑙 𝑢𝑙+1 𝑢𝑙+2 𝑢 𝑦 𝑦𝑙(𝑢)

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

slide-19
SLIDE 19

Evaluating cubic Catmull-Rom spline

19

A recursive evaluation algorithm for a class of Catmull-Rom splines [Barry,Colgman,SIGGRAPH88]

𝑄 𝑢0 = 𝑄0 𝑄 𝑢1 = 𝑄

1

𝑄 𝑢2 = 𝑄2 𝑄 𝑢3 = 𝑄3 𝑄 𝑢 𝑢1 ≤ 𝑢 ≤ 𝑢2

slide-20
SLIDE 20

Ways of setting parameter values 𝑢𝑙 (aka. knot sequence)

  • Assume: 𝑢0 = 0
  • Uniform

𝑢𝑙 = 𝑢𝑙−1 + 1

  • Chordal

𝑢𝑙 = 𝑢𝑙−1 + 𝑄𝑙−1 − 𝑄𝑙

  • Centripetal

𝑢𝑙 = 𝑢𝑙−1 + 𝑄𝑙−1 − 𝑄𝑙

20

Parameterization of Catmull-Rom Curves [Yuksel,Schaefer,Keyser,CAD11]

slide-21
SLIDE 21

Application of cubic Catmull-Rom spline: Hair modeling

21

Parameterization of Catmull-Rom Curves [Yuksel,Schaefer,Keyser,CAD11]

slide-22
SLIDE 22

B-spline

  • Another way of defining polynomial spline
  • Represent curve as sum of basis functions
  • Cubic basis is the most commonly used
  • Deeply related to subdivision surfaces

 Next lecture

  • Non-Uniform Rational B-Spline
  • Non-Uniform = varying spacing of knots (𝑢𝑙)
  • Rational = arbitrary weights for CPs
  • (Complex stuff, not covered)
  • Cool Flash demo:

http://geometrie.foretnik.net/files/NURBS-en.swf

22

slide-23
SLIDE 23

Parametric surfaces

  • One parameter  Curve 𝑄(𝑢)
  • Two parameters  Surface 𝑄 𝑡, 𝑢
  • Cubic Bezier surface:
  • Input: 4×4=16 control points 𝑄𝑗𝑘

𝑄 𝑡, 𝑢 =

𝑗=0 3 𝑘=0 3

𝑐𝑗

3 𝑡 𝑐 𝑘 3 𝑢 𝑄𝑗𝑘

23

Bernstein basis functions 𝑐0

3 𝑢 = 1 − 𝑢 3

𝑐1

3 𝑢 = 3𝑢 1 − 𝑢 2

𝑐2

3 𝑢 = 3𝑢2(1 − 𝑢)

𝑐3

3 𝑢 = 𝑢3

slide-24
SLIDE 24

3D modeling using parametric surface patches

  • Pros
  • Can compactly represent smooth surfaces
  • Can accurately represent spheres, cones, etc
  • Cons
  • Hard to design nice layout of patches
  • Hard to maintain continuity across patches
  • Often used for designing man-made objects

consisting of simple parts

24

slide-25
SLIDE 25

Pointers

  • http://en.wikipedia.org/wiki/Bezier_curve
  • http://antigrain.com/research/adaptive_bezier/
  • https://groups.google.com/forum/#!topic/comp.graphics.algorithms/2

FypAv29dG4

  • http://en.wikipedia.org/wiki/Cubic_Hermite_spline
  • http://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_splin

e

25