You are on page 1of 35

Topics in Computer Graphics Chap 7: Polynomial Curve Constructions

fall, 2011

University of Seoul School of Computer Science Minho Kim

Table of contents
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Motivation

Given n points in 2D/3D,

Interpolation: nd a (polynomial) curve that passes through the data exactly.


Aitkens algorithm (7.1) Lagrange polynomials (7.2) The Vandermonde approach (7.3) The Newton form and forward differencing (7.11)

Approximation: nd a (polynomial) curve that goes through the data closely in a reasonable way.

Least squares approximation (7.8) Smoothing equations (7.9)

Normal/tangent data in addition to position data.


Cubic/quintic Hermite interpolation (7.5&7.6) Point-normal interpolation (7.7)

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Aitkens Algorithm

Problem: Given points tpi un 0 with corresponding i parameter values tti un 0 , nd a curve pptq such that i ppti q  pi , i  0, . . . , n.

Aitkens Algorithm (contd)


1. Base case: Let p1 ptq  i

ti1 t t ti pi pi1 , ti1 ti ti1 ti

i  0, . . . , n 1.

2. Let pn1 ptq is a polynomial of degree n 1 that 0 interpolates p0 , . . . , pn1 and pn1 ptq is one that 1 interpolates p1 , . . . , pn . 3. Then pn ptq  0

p1 ptq is a line segment for ti t ti1 . i p1 ptq interpolates pi and pi1 : p1 pti q  pi and i i p1 pti1 q  pi1 . i

tn t n1 n p ptq tt tt0 p1 1ptq tn t0 0 0 n

is a polynomial curve of degree n and interpolates p0 , . . . , pn .

Aitkens Algorithm (contd)


With p0 ptq : pi , the interpolating curve pn ptq is dened 0 i recursively as pr pt q  i t ti r1 t ir t r 1 pi ptq p ptq, tir ti tir ti i1

r  1, . . . , n i  0, . . . , n r.

Properties

Afne invariance Linear precision No convex hull property Is it possible for a smooth interpolating curve has a convex hull property? No variation diminishing property Does not answer if such polynomial curve is unique. Not a closed form

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Lagrange Polynomials
The interpolating curve is given by pptq  where Ln i
n

ptq are Lagrange polynomials dened as n j 0 pt tj q n nj$i Li ptq : j 0 pti tj q


j i

i 0

pi Ln ptq i

Lagrange polynomials are cardinal: Ln ptj q  i,j i

where i,j is the Kronecker delta. tLnptqun0 form a basis of all polynomials of degree n i i Interpolating polynomial (of degree n) is unique
n i 0

Ln ptq  1ptq i

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

The Vandermonde Approach

What is the monomial form pn pt q  of the interpolating polynomial?


n j 0

aj tj

The Vandermonde Approach (contd)


1. pn pt0 q  p0

 a0 a1t0 antn 0 pn pt1 q  p1  a0 a1 t1 an tn 1  a0 a1tn antn n


( (
. . .

pn ptn q  pn

p0 1 t0 tn a0 n "p1 0 "1 t1 t0 0 "a1 0 10" 0 " 0 " 2. " . 0  " . . . p  Ta . ) !. . .. . 0 " . 0 . )! . ) !. . . . . pn 1 tn tn an n n 3. If ttj uj 0 are distinct, det T $ 0. (Why?) det T is the Vandermonde of the interpolation problem 4. Solution: a  T 1 p

Generalized Vandermonde
For some basis tFjn ptqun0 , (e.g. Bernstein basis) the j interpolating polynomial is expressed as p pt q 
n n j 0

cj Fjn ptq

and the coefcients tcj un0 can be found as j

c1 F n pt0 q F n pt0 q F n pt0 q n "c2 0 "F0n pt1 q F1n pt1 q Fn pt1 q0 n 1 0 " .. 0  " 0 .. " 0 " . . 0 .. . . ) !.) ! . . . . n n n cn F0 ptn q F1 ptn q Fn ptn q

(1

p0 " p1 0 ".0 ".0 !.) pn

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Limits of Lagrange Interpolation

Small change of input results in large change in output


The process is ill-conditioned. Polynomial interpolation is not shape preserving. Runge phenomonen for construction (solving dense linear system) for evaluation (for high n)

Expensive to solve

Piecewise schemes are better! (e.g. spline interpolation)

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Cubic Hermite Interpolation


Find the cubic polynomial that interpolates the following: pp0 q  p0
9 9

E3 pp0q  m0 R3 pp1q  m1 R3 pp1q  p1 E3 ,


3 j 0 3 bj Bj ptq

Easier to work with Bezier form ppt q 

1. b0 2.
9

 p0 and b3  p1 pp0q  3b0  m0 and pp1q  3b2  m1 1 b1  p0 3 m0 and b2  b1 1 m1 3


9

Cubic Hermite Interpolation: Cardinal Form


ppt q 

3 p0 B 0

ptq

p0

1 1 3 3 3 m0 B1 ptq p1 m1 B2 ptqp1 B3 ptq 3 3

pptq  p0H03ptq m0H13ptq m1H23ptq p1H33ptq


3 3 3 H0 ptq  B0 ptq B1 ptq 1 3 3 H1 ptq  B1 ptq 3 1 3 3 H2 ptq  B2 ptq 3 3 3 3 H3 ptq  B2 ptq B3 ptq

Cubic Hermite Interpolation: Cardinal Form

3 H0 p0q  1 3 H1 p0q  0 3 H2 p0q  0 3 H3 p0q  0

d 3 dt H0 d 3 dt H1 d 3 dt H2 d 3 dt H3

p0 q  0 p0 q  1 p0 q  0 p0 q  0

d 3 dt H0 d 3 dt H1 d 3 dt H2 d 3 dt H3

p1 q  0 p1 q  0 p1 q  1 p1 q  0

3 H0 p1q  0 3 H1 p1q  0 3 H2 p1q  0 3 H3 p1q  1

3 3 H0 ptq H3 ptq  1ptq (Why?)

Not invariant under afne domain transformations Not symmetric

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Least Squares Approximation


P 1 number of data points can be interpolated by a polynomial of degree n if d P .

What if n P ? approximation required

How to measure the closeness of the approximating curve and the data points? least squares approximation: To nd a polynomial curve xptq that minimizes f pc0 , . . . , cn q 
P j 0

xptj q pj

Least Squares Approximation (contd)


1. The approximating curve is expressed as
n n xptq  c0 C0 ptq cn Cn ptq n for some basis tCj un0 . j

2. Assuming xptq interpolates all the points tpj uP0 , we get a j linear system C n pt0 q " 0 .. ! .
n C0

.. .

pt P q

n C n pt 0 q c0 p0 . 0" . 0  " . 0 . )! . ) ! . ) . . . n Cn

ptP q

MC  P

cn

pP

where M

RpP 1qpn1q, C Rpn1q3, P RpP 1q3,


Linear systems for each component underdetermined (no solution in general)

Least Squares Approximation (contd)


3. Can be converted to a solvable linear system by multiplying M T : MT MC  MT P

M T M is always invertible. (Why?) The solution minimizes f p c0 , . . . , cn q  (Why?) The solution satises
P

xpt q p

j

j 0

ff fcd  0, k

 0, . . . , n, d  1, 2, 3.

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Smoothing Equations

Minimizing the least square error does not guarantee a good curve. (Fig 7.8) We want a curve that does not wiggle much. (How?) If the control polygon behaves nicely, then so does the curve.

How to minimizes wiggling (of the polygon)? minimize the 2nd differences 2 bi b0 2b1 b2 . . .

0 0

bn2 2bn1 bn

SB  0

Smoothing Equations (contd)

Combined with the least squares problem,

 &

M P B S 0

 &

Balancing the error and shape

p1 qM
S

&

p1 qP B 0

&

01

Larger for noisier data

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

Designing with Bezier Curves


What if we want to move a point on the curve to change the shape? Given a Bezier curve xptq 
n i 0 n bi Bi ptq,

if we change a point xptq to y, how should we change tbi u to tbi u such that the curve passes through y at t  t? y

n i 0

n bi Bi ptq

Assume b0 and bn are unchanged. Underdetermined: 1 equation and n 1 unknowns

Designing with Bezier Curves (contd)


1.

n B1 ptq

$ " b..1 0 n n n Bn1 ptq ! . )  yb0 B0 ptqbn Bn ptq : z bn1 AB  z

2. Assume all the points b1 , . . . , bn1 move along (unknown) c direction: B  B AT c AB  AB AAT c z AB  AAT c 3. Since AAT is a scalar, with a : AAT c 1 1 p y x q B  B a AT p y x q . a

Outline
Aitkens Algorithm Lagrange Polynomials The Vandermonde Approach Limits of Lagrange Interpolation Cubic Hermite Interpolation Quintic Hermite Interpolation Point-Normal Interpolation Least Squares Approximation Smoothing Equations Designing with Bezier Curves The Newton Form and Forward Differencing

The Newton Form of Interpolating Polynomial


For equally spaced parameter intervals: ti1 For cubic case, pptq p0

 ti h

where

1 1 pt t0qp0 2!h2 pt t0qpt t1q2p0 h 1 pt t0qpt t1qpt t2q3p0 3!h3 and 0 pj

i pj : i1 pj 1 i1 pj

 pj .

With g : 1{h, p0 p1 p2 p3 gp0 gp1 gp2 g 2 2 p0 g 2 2 p1 g 3 3 p0

Fast Evaluation for Plotting

p0 p1 p2 p3 p4 p5 . . . gp0 gp1 gp2 gp3 gp4 . . .

Efcient way to evaluate ppt2 hq, ppt2 2hq, . . .


g 2 2 p0 g 2 2 p1 g 2 2 p2 g 2 2 p3 . . .

g 3 3 p0 g 3 3 p1 g 3 3 p2 . . .

tg3pj u are all equal. (Why?)


From right to left g 2 2 p2

 g33p1 g22p1 gp3  g22p2 gp2 p4  gp3 p3


qi j

In general, with qi : g i i pj , j

and pj

 q0 . j

 qij11 qij1,

i  2, 1, 0

Fast for Plotting (contd)

No multiplication involved! (after start-up phase) extremely fast Given a polynomial in cubic Bezier form, Roundoff error is accumulated The curve may deviates more and more...
1. Compute initial four points. 2. Evaluate sequence of points and plot using line segments.

You might also like