parametric spline curves -...

19
computer graphics • parametric curves © 2009 fabio pellacini • 1 parametric spline curves computer graphics • parametric curves © 2009 fabio pellacini • 2 curves used in many contexts – fonts animation paths shape modeling different representation implicit curves parametric curves mostly used

Upload: others

Post on 11-May-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 1

parametric spline curves

computer graphics • parametric curves © 2009 fabio pellacini • 2

curves

•  used in many contexts –  fonts –  animation paths –  shape modeling

•  different representation –  implicit curves –  parametric curves

•  mostly used

Page 2: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 3

implicit representation for 2D curves

•  curves can be represented implicitly as

•  example: circle of radius r centered at origin

0),()( == yxff p

0222 =−+ ryx

computer graphics • parametric curves © 2009 fabio pellacini • 4

parametric representation for 2D curves

•  curves can be represented parametrically as

•  example: circle of radius r centered at origin

⎩⎨⎧

=

==

)()(

)(ufyufx

uy

xp

⎩⎨⎧

=

=

)sin()cos(uryurx

Page 3: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 5

parametric representation of splines

•  general parametric curve can be written as

•  goals when defining f –  smoothness –  predictable and local control –  efficiency

],0[)()( Nttft ∈=p

computer graphics • parametric curves © 2009 fabio pellacini • 6

parametric representation of splines

•  splines: piecewise parametric polynomials –  polynomials are smooth –  controlled by small number of local control points –  discontinuities at integer intervals

],0[)()( Nttft ∈=p

Page 4: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 7

splines - intuition

•  define segment by “blending” control points

•  join segments to form curve

computer graphics • parametric curves © 2009 fabio pellacini • 8

defining splines

•  pick segment interpolating function •  impose constraints to define segments

–  i.e. control points that define the spline

•  impose constraints to join segments together

Page 5: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 9

interpolating vs. approximating splines

•  interpolating –  pass through control points

•  approximating –  guided by control points

computer graphics • parametric curves © 2009 fabio pellacini • 10

smoothness

•  smoothness described by degree of continuity –  C0: same position at each side of joints –  C1: same tangent at each side of joints –  C2: same curvature at each side of joints –  Cn: n-th derivative defined at joints

Page 6: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 11

control

•  local control –  changing control points only affect locally the curve

•  easy to control

–  true for all splines

computer graphics • parametric curves © 2009 fabio pellacini • 12

control

•  convex hull property –  convex hull: smallest convex region enclosing all points

•  predictable behavior •  more efficient operations

–  only some splines

yes

no

Page 7: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 13

efficiency

•  affine invariance –  transforming the spline same as transforming controls –  efficient algorithms, esp. combined with convex hull –  true for all used splines

computer graphics • parametric curves © 2009 fabio pellacini • 14

piecewise linear splines

•  each segment is a linear function

•  impose endpoint constraints

]1,0[)( =+= ttt bap

⎩⎨⎧

=

−=⇒

⎩⎨⎧

=

=

0

01

1

0

)1()0(

pbppa

pppp

]1,0[)()( 010 ∈−+= ttt pppp

Page 8: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 15

point blending interpretation

•  can interpret as blending of points

•  blending functions do not depend on points –  different intervals only change control points

)1,0[)()()1()( 110010 ∈+=+−= ttbtbttt ppppp

computer graphics • parametric curves © 2009 fabio pellacini • 16

matrix notation

•  write blending functions more conveniently

[ ] ⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡−=

+−=

1

0

10

0111

1)(

)1()(

pp

p

ppp

tt

ttt

Page 9: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 17

joining line segments

•  impose C0 continuity at joints –  first segment

–  second segment

–  implies

•  general formula –  appropriately rename control points

⎩⎨⎧

=

=→ 0

10

00

00

)1()0(

)(pppp

p t

⎩⎨⎧

=

=→ 1

11

10

11

)1()0(

)(pppp

p t

10

01

10 )0()1( pppp =→=

)floor(],,0[)()()( 110 tkNtktbktbt kk =∈−+−= +ppp

computer graphics • parametric curves © 2009 fabio pellacini • 18

Hermite splines

•  each segment is a cubic polynomial function

•  impose endpoints and tangents constraints dcbap +++= tttt 23)(

⎪⎪⎩

⎪⎪⎨

=

=

=

=

1

0

1

0

')1('')0('

)1()0(

pppppppp

Page 10: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 19

Hermite splines

cbapdcbap

++=

+++=

ttttttt

23)(')(

2

23

0

0

1010

1010

'''233

''22

pdpc

ppppbppppa

=

=

−−+−=

++−=

p(0) = dp(1) = a + b + c + dʹ′ p (0) = cʹ′ p (1) = 3a + 2b + c

computer graphics • parametric curves © 2009 fabio pellacini • 20

Hermite

•  matrix formulation

•  blending functions

[ ]⎥⎥⎥⎥

⎢⎢⎢⎢

⎥⎥⎥⎥

⎢⎢⎢⎢

⎡−−−

=

1

0

1

0

23

''

0001010012332122

1)(

pppp

p tttt

Page 11: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 21

Bezier splines

•  Hermite splines has points and vectors controls –  would like to use just points –  insight: specify tangents as difference of points

•  choose appropriate scaling value, see later

computer graphics • parametric curves © 2009 fabio pellacini • 22

Bezier splines

[ ]⎥⎥⎥⎥

⎢⎢⎢⎢

⎥⎥⎥⎥

⎢⎢⎢⎢

−−

=

3

2

1

0

23

0001003303631331

1)(

qqqq

p tttt

)(3')(3'

231

010

31

00

qqpqqp

qpqp

−=

−=

=

=

Page 12: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 23

Bezier splines

•  blending functions

computer graphics • parametric curves © 2009 fabio pellacini • 24

piecewise cubic splines – smoothness

•  C1 at joints by imposing equal tangents –  Hermite: same tangents –  Bezier: collinear control points

•  geometric continuity if length of tangent differs

Page 13: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 25

piecewise cubic splines – control

•  local control –  comes from the formulation by segments –  for each segment, curve defined by 4 control points

•  convex hull –  when blending positions

∑=

=≥3

01)(and0)(

iii tbtb

computer graphics • parametric curves © 2009 fabio pellacini • 26

piecewise cubic splines – affine invariance

•  affine invariance –  affine is combination of linear and translation –  blending functions sum to 1

X(p(t)) = Mp(t) + t = M bi(t)pii= 0

3∑⎛ ⎝ ⎜

⎞ ⎠ ⎟ + t =

= bi(t)Mpii= 0

3∑ + bi(t)i= 0

3∑ t =

= bi(t)(Mpi + t) =i= 0

3∑ bi(t)X(pi)i= 0

3∑

Page 14: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 27

Bezier splines

•  widely used, especially in 2D –  primitive in PDF

•  represent C1 and C0 curves with corners •  easily add point at any position

computer graphics • parametric curves © 2009 fabio pellacini • 28

Catmull-Rom splines

•  interpolating spline –  no convex hull property

•  as Hermite, derivatives automatically determined –  using adjacent control points –  end tangent using either adding point or zers

Page 15: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 29

Catmull-Rom splines

( ) 2/' 11 −+ −= kkk ppp

computer graphics • parametric curves © 2009 fabio pellacini • 30

drawing splines

•  approximate with a sequence of line segments –  efficiency: fast evaluation, small number of segments –  guarantees on accuracy

•  approaches –  uniform subdivision in t (fast) –  recursive subdivision (small number of segments)

Page 16: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 31

uniform subdivision

•  evaluate spline at fixed t intervals –  can be done efficiently

computer graphics • parametric curves © 2009 fabio pellacini • 32

adaptive subdivision - Bezier

•  recursively subdivide spline •  until line segments approximate well curve

Page 17: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 33

De Casteljau algorithm - Bezier

•  recursively do –  connect midpoints of the control polygons –  connect midpoints of the new segments –  the midpoint of this last segment is on the curve –  and splits the curve in two Bezier segments

•  stop when control polygon is close to collinear

computer graphics • parametric curves © 2009 fabio pellacini • 34

B-Splines

•  would like C2 continuity at joints –  give up interpolation

•  impose 3 continuity constraints at joints

[ ]⎥⎥⎥⎥

⎢⎢⎢⎢

⎥⎥⎥⎥

⎢⎢⎢⎢

−−

=

+

+

2

1

1

23

0141030303631331

611)(

k

k

k

k

tttt

qqqq

p

Page 18: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 35

other splines

•  many other types

•  non-uniform B-splines –  discontinuities not evenly spaces

•  non-uniform rational B-splines (NURBS) –  ratios of non-uniform B-splines –  invariance under perspective –  can represent conic sections exactly –  often used in 3D

computer graphics • parametric curves © 2009 fabio pellacini • 36

spline equivalence

•  all splines seen so far are equivalent –  represented by 4x4 matrices

•  can convert control points from one to other –  algorithms can be based on the most efficient –  UIs can be based on the most user-friendly

Page 19: parametric spline curves - pellacini.di.uniroma1.itpellacini.di.uniroma1.it/teaching/graphics09/lectures/08_Parametric... · De Casteljau algorithm - Bezier • recursively do –

computer graphics • parametric curves © 2009 fabio pellacini • 37

2D vs. 3D splines

•  often use 2D splines in 3D –  by projecting onto a plane

•  3D parametric splines have same formulation –  just use 3D vectors vs. 2D ones