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

computer graphics
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Computer Graphics WS07/08 – Splines

Computer Graphics

  • Splines -

Hendrik Lensch

slide-2
SLIDE 2

Computer Graphics WS07/08 – Splines 2

Overview

  • Last Time

– Image-Based Rendering

  • Today

– Parametric Curves – Lagrange Interpolation – Hermite Splines – Bezier Splines – DeCasteljau Algorithm – Parameterization

slide-3
SLIDE 3

Computer Graphics WS07/08 – Splines 3

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

slide-4
SLIDE 4

Computer Graphics WS07/08 – Splines 4

Parametric curves

  • Separate function in each coordinate

– 3D: f(t)= (x(t), y(t), z(t))

slide-5
SLIDE 5

Computer Graphics WS07/08 – Splines 5

Monomials

  • Monomial basis

– Simple basis: 1, t, t2, ... (t usually in [0 .. 1])

  • Polynomial representation

– 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

( ) ∑

=

= =

n i i i A

t t z t y t x t P ) ( ) ( ) ( ) (

Monomials Degree (= Order – 1) Coefficients ∈R3

( )

[ ]

⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = = =

− − − − , , , 1 , 1 , 1 , , , ´ , 1

1 ) ( ) ( ) ( ) ( ) (

z y x n z n y n x n z n y n x n n

A A A A A A A A A t t t T t z t y t x t P M L A

slide-6
SLIDE 6

Computer Graphics WS07/08 – Splines 6

Derivatives

  • Derivative = tangent vector

– Polynomial of degree (n-1)

  • 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

( )

[ ]

⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = = =

− − − − , , , 1 , 1 , 1 , , , ´ , 1 1

1 1 ) ´( ) ´( ) ´( ) ´( ) ´(

z y x n z n y n x n z n y n x n- n

A A A A A A A A A )t (n- nt t T t z t y t x t P M L A

slide-7
SLIDE 7

Computer Graphics WS07/08 – Splines

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.

slide-8
SLIDE 8

Computer Graphics WS07/08 – Splines 8

Lagrange Interpolation

  • Interpolating basis functions

– Lagrange polynomials for a set of parameters T={t0, ..., tn}

  • 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

⎩ ⎨ ⎧ = = = − − =∏

≠ =

  • therwise

1 ) ( with , ) ( j i t L t t t t t L

ij j n i n j i

  • j

j i j n i

δ

=

=

n i i n i

P t L t P ) ( ) (

slide-9
SLIDE 9

Computer Graphics WS07/08 – Splines 9

Lagrange Interpolation

  • Simple Linear Interpolation

– T={t0, t1}

  • Simple Quadratic Interpolation

– T={t0, t1, t2}

1 1 1 1 1 1

) ( ) ( t t t t t L t t t t t L − − = − − =

t0 t1 1 L0

1

L1

1

2 2 1 1 2 0 )

( t t t t t t t t t L − − − − =

t0 t2 1 L0

1

L0

2

t1

  • 1
slide-10
SLIDE 10

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

slide-11
SLIDE 11

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

Segment 1 Segment 2 Segment 3 Segment 4 What Continuity ?

slide-12
SLIDE 12

Computer Graphics WS07/08 – Splines 12

Linear Interpolation

  • Hat Functions and Linear Splines

2 3 4 1 1

  • 1

1

) ( T y ) ( T y ) ( T P P(t)

3 3 2 2

t t t

i i

+ = =∑

) ( ) ( 1 1 1 1 1 1 (t) i t T t T t t t t t t T

i

− = ⎪ ⎪ ⎩ ⎪ ⎪ ⎨ ⎧ ≥ < ≤ < ≤ − − < − + =

2 3 4 1 y2 y3 T(t)

slide-13
SLIDE 13

Computer Graphics WS07/08 – Splines 13

Hermite Interpolation

  • Hermite Basis (cubic)

– Interpolation of position P and tangent P´ information for t= {0, 1} – Basis functions

2 3 3 2 3 2 2 3 1 2 3

) 2 3 ( ) ( ) 1 ( ) ( ) 1 ( ) ( ) 2 1 ( ) 1 ( ) ( t t t H t t t H t t t H t t t H − = − − = − = + − =

1

3

H

3 3

H

3 2

H

3 1

H

slide-14
SLIDE 14

Computer Graphics WS07/08 – Splines 14

Hermite Interpolation

  • Properties of Hermite Basis Functions

– H0 (H3) interpolates smoothly from 1 to 0 (1 to 0) – H0 and H3 have zero derivative at t= 0 and t= 1

  • No contribution to derivative (H1, H2)

– H1 and H2 are zero at t= 0 and t= 1

  • No contribution to position (H0, H3)

– H1 (H2) has slope 1 at t= 0 (t= 1)

  • Unit factor for specified derivative vector
  • Hermite polynomials

– P0, P`1 are positions ∈R3 – P`0, P1 are derivatives (tangent vectors) ∈R3

) ( ) ( ´ ) ( ´ ) ( ) (

3 3 1 3 2 1 3 1 3

t H P t H P t H P t H P t P + + + =

3

H

3 3

H

3 2

H

3 1

H

slide-15
SLIDE 15

Computer Graphics WS07/08 – Splines 15

Examples: Hermite Interpolation

slide-16
SLIDE 16

Computer Graphics WS07/08 – Splines 16

Matrix Representation

  • Matrix representation

[ ] [ ] [ ]

3 2 1 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 2 1 4 4 4 4 3 4 4 4 4 2 1 O L 4 4 4 3 4 4 4 2 1 4 4 4 4 3 4 4 4 4 2 1 O 4 4 3 4 4 2 1 L M L

H H

G T T T T M z y x y y x z y x z y x T z y x n z n y n x n z n y n x

P P P P M M M M t t G G G G G G G G G G G G M M M M t t A A A A A A A A A t t t P ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ =

− − − 1 1 Functions Basis 21 13 12 11 2 3 (4x3) G Matrix Geometry , , , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , (4x4) M Matrix Basis 21 13 12 11 2 3 , , , 1 , 1 , 1 , , , ´ , 2 3

´ ´ 1 1 1 ) (

slide-17
SLIDE 17

Computer Graphics WS07/08 – Splines 17

Matrix Representation

  • For cubic Hermite interpolation we obtain:
  • Solution:

– Two matrices must multiply to unit matrix

H H T H H T H H T H H T

P P P P G M G M G M G M ) 1 2 3 ( ´ ) 1 ( ´ ) 1 1 1 1 ( ) 1 (

1 1

= = = =

H H H T T T T

P P P P G M G ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = = ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ′ ′ 1 2 3 1 1 1 1 1 1

1 1

  • r

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − − − − = ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ =

1 1 1 2 3 3 1 1 2 2 1 2 3 1 1 1 1 1 1

1 H

M

slide-18
SLIDE 18

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(b1-b0) and P´1= 3(b3-b2)

  • Factor 3 due to derivative of t3

B HB T T T T T T T T H

G M b b b b P P P P G = ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − − = ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ =

3 2 1 1 1

3 3 3 3 1 1 ´ ´

slide-19
SLIDE 19

Computer Graphics WS07/08 – Splines 19

Basis transformation

  • Transformation

– P(t)=T MH GH = T MH (MHB GB) = T (MHMHB) GB = T MB GB

  • Bézier Curves & Basis Functionss

– Basis functions: Bernstein polynomials

⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − − − − = = 1 3 3 3 6 3 1 3 3 1

HB H B

M M M

i n i n i n i i n i

t t i n t B ions Basisfunct with b t B

− =

− ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = = ∑ ) 1 ( ) ( ) ( P(t)

3 3 2 2 1 2 3 3 3

1 3 1 3 1 ) ( P(t) b t

  • t)b

( t b

  • t)

t( b

  • t)

( b t B

i i i

+ + + = = ∑ =

3 B

B0

3

B1

3

B2

3

B3

3

slide-20
SLIDE 20

Computer Graphics WS07/08 – Splines 20

Properties: Bézier

  • Advantages:

– End point interpolation – Tangents explicitly specified – Smooth joints are simple

  • P3, P4, P5 collinear G1 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)
slide-21
SLIDE 21

Computer Graphics WS07/08 – Splines 21

DeCasteljau Algorithm

  • Direct evaluation of the basis functions

– Simple but expensive

  • Use recursion

– Recursive definition of the basis functions – Inserting this once yields: – with the new Bézier points given by the recursion

) ( ) 1 ( ) ( ) (

1 1 1

t B t t tB t B

n i n i n i − − −

− + =

∑ ∑

− = − =

= =

1 1 1

) ( ) ( ) ( ) (

n i n i i n i n i i

t B t b t B b t P

i i k i k i k i

b t b t b t t tb t b = − + =

− − +

) ( and ) ( ) 1 ( ) ( ) (

1 1 1

slide-22
SLIDE 22

Computer Graphics WS07/08 – Splines 22

DeCasteljau Algorithm

  • DeCasteljau-Algorithm:

– Recursive degree reduction of the Bezier curve by using the recursion formula for the Bernstein polynomials

  • Example:

– t= 0.5

) ( ) 1 ( ) ( ) (

1 1 1

t b t t tb t b

k i k i k i − − +

− + =

1 ) ( ) ( ) ( ) ( ) (

1 1 1

⋅ = = = =

∑ ∑

− = − =

t b t B t b t B b t P

n i n i n i i n i n i i

L

slide-23
SLIDE 23

Computer Graphics WS07/08 – Splines 23

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

Computer Graphics WS07/08 – Splines 24

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

slide-25
SLIDE 25

Computer Graphics WS07/08 – Splines 25

Matrix Representation

  • Catmull-Rom-Spline

– Piecewise polynomial curve – Four control points per segment – For n control points we obtain (n-3) polynomial segments

  • Application

– Smooth interpolation of a given sequence of points – Key frame animation, camera movement, etc. – Only G1-continuity – Control points should be equidistant in time

⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − − − − = =

+ + +

T T T T CR CR i

i i i i

P P P P T G T t P

3 2 1

2 1 1 1 4 5 2 1 3 3 1 2 1 ) ( M

__

slide-26
SLIDE 26

Computer Graphics WS07/08 – Splines 26

Choice of Parameterization

  • Problem

– Often only the control points are given – How to obtain a suitable parameterization ti ?

  • Example: Chord-Length Parameterization

– Arbitrary up to a constant factor

  • Warning

– Distances are not affine invariant ! – Shape of curves changes under transformations !!

= −

− = =

i j i i i

P P dist t t

1 1

) (

slide-27
SLIDE 27

Computer Graphics WS07/08 – Splines 27

Parameterization

  • Chord-Length versus uniform Parameterization

– Analog: Think P(t) as a moving object with mass that may

  • vershoot

Uniform Chord-Length

slide-28
SLIDE 28

Computer Graphics WS07/08 – Splines

B-Splines

  • Goal

– Spline curve with local control and high continuity

  • Given

– Degree: n – Control points: P0, ..., Pm (Control polygon, m ≥ n+1) – Knots: t0, ..., tm+n+1 (Knot vector, weakly monotonic) – The knot vector defines the parametric locations where segments join

  • B-Spline Curve

– Continuity:

  • Cn-1 at simple knots
  • Cn-k at knot with multiplicity k

i m i n i

P t N t P

=

= ) ( ) (

slide-29
SLIDE 29

Computer Graphics WS07/08 – Splines

B-Spline Basis Functions

  • Recursive Definition

) ( ) ( ) (

  • therwise

if 1 ) (

1 1 1 1 1 1 1

t N t t t t t N t t t t t N t t t t N

n i i n i n i n i i n i i n i i i i − + + + + + + − + +

− − − − − = ⎩ ⎨ ⎧ < < =

1 2 3 4 5 1 2 3 4 5 N0 N1 N2 N3 N4 N0

1

N1

1

N2

1

N3

1

Uniform Knot vector

slide-30
SLIDE 30

Computer Graphics WS07/08 – Splines

B-Spline Basis Functions

  • Recursive Definition

– Degree increases in every step – Support increases by one knot interval

slide-31
SLIDE 31

Computer Graphics WS07/08 – Splines

B-Spline Basis Functions

  • Uniform Knot Vector

– All knots at integer locations

  • UBS: Uniform B-Spline

– Example: cubic B-Splines

  • Local Support = Localized Changes

– Basis functions affect only (n+1) Spline segments – Changes are localized

n i n i

N B =

n i n i

d P =

Degree 2

slide-32
SLIDE 32

Computer Graphics WS07/08 – Splines

B-Spline Basis Functions

  • Convex Hull Property

– Spline segment lies in convex hull of (n+1) control points – (n+1) control points lie on a straight line curve touches this line – n control points coincide curve interpolates this point and is tangential to the control polygon

Degree 2

slide-33
SLIDE 33

Computer Graphics WS07/08 – Splines

Normalized Basis Functions

  • Basis Functions on an Interval

– Knots at beginning and end with multiplicity

  • NUBS: Non-uniform B-Splines

– Interpolation of end points and tangents there – Conversion to Bézier segments via knot insertion

slide-34
SLIDE 34

Computer Graphics WS07/08 – Splines

deBoor-Algorithm

  • Recursive Definition of Control Points

– Evaluation at t: tl < t < tl+1: i ∈ {l-n, ..., l}

  • Due to local support only affected by (n+1) control points
  • Properties

– Affine invariance – Stable numerical evaluation

  • All coefficients > 0

i i r i r i n i r i r i r i n i r i r i

P t P t P t t t t t P t t t t t P = − − + − − − =

− + + + + + − + + + +

) ( ) ( ) ( ) 1 ( ) (

1 1 1 1 1

n i n i

d t P = ) (