Curves and Interpolation

Curves and Interpolation
Dr. Scott Schaefer
1
Smooth Curves

How do we create smooth curves?
2/61
Smooth Curves

How do we create smooth curves?

Parametric curves with polynomials
p(t )  x(t ), y(t )
3/61
Smooth Curves

Controlling the shape of the curve
x(t )  a  bt  ct  dt
2
3
y(t )  e  ft  gt  ht
2
3
4/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  t  t
2
3
5/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  3  t  t  t
2
3
6/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  t  t
2
3
7/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  t  t
2
3
8/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  t  t
2
3
9/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  3t  t
2
3
10/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  t  t
2
3
11/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  t  t
2
3
12/61
Smooth Curves

Controlling the shape of the curve
x(t )  t
y (t )  1  t  t  t
2
3
Power-basis coefficients not intuitive
for controlling shape of curve!!!
13/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
t
14/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
1
t t2
 c0 
 
 c1 
... t n  c2   y (t )
 

c 
 n

t
15/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
 c0 
 
 c1 
1 t t 2 ... t n  c2   y (t )
 

c 
basis
 n


t
16/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
 c0 
 
 c1 
1 t t 2 ... t n  c2   y (t )
 

c 
coefficients
 n


t
17/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
1 t 0

1 t1

 
1 t
n

t0
2
t1
2

tn
2
 c0   y0 
... t0    
 c
 y1 
n  1
... t1    
 c2    y2 
  
   
n 
... t n    
 cn   y n 
n
t
18/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
1 t 0

1 t1

 
1 t
n

t0
2
t1
2

tn
2
 c0   y0 
... t0    
 c
 y1 
n  1
... t1    
 c2    y2 
  
   
n 
... t n    
 cn   y n 
n
t
Vandermonde matrix
19/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
1

1
1

1

0  c0   3 
   
1 1 1  c1   1 
 



2 4 8 c2
3
   
3 9 27  c3   1 
0 0
t
20/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y (t )  c0  c1t  c2t 2  c3t 3
y
 c0   3 
  

 c1    20 3 
c    6 
 2 

 c   1 
 3  3 
t
21/61
Interpolation

Find a polynomial y(t) such that y(ti)=yi
y
Intuitive control of curve using
“control points”!!!
t
22/61
Interpolation
Perform interpolation for each component
separately
 Combine result to obtain parametric curve

y
p(t )  x(t ), y(t )
x
23/61
Interpolation
Perform interpolation for each component
separately
 Combine result to obtain parametric curve

y
p(t )  x(t ), y(t )
x
24/61
Interpolation
Perform interpolation for each component
separately
 Combine result to obtain parametric curve

y
p(t )  x(t ), y(t )
x
25/61
Generalized Vandermonde Matrices

Assume different basis functions fi(t)
y(t )   ci f i (t )
i
 f 0 (t0 )

 f 0 (t1 )
 

 f (t )
 0 n
f1 (t0 )
f 2 (t0 ) ...
f1 (t1 )
f 2 (t1 ) ...

f1 (t n )


f 2 (t n ) ...
 c0   y0 
f n (t0 )    
 c1   y1 
f n (t1 )    
c2  y 2

    
     
f n (t n )    
 cn   y n 
26/61
LaGrange Polynomials

Explicit form for interpolating polynomial!
Li (t )  
j i
(t  t j )
(ti  t j )
27/61
LaGrange Polynomials

Explicit form for interpolating polynomial!
Li (t )  
j i
(t  t j )
(ti  t j )
1
0.8
0.6
0.4
0.2
1.5
2
2.5
3
3.5
4
-0.2
28/61
LaGrange Polynomials

Explicit form for interpolating polynomial!
Li (t )  
j i
(t  t j )
(ti  t j )
1
0.8
0.6
0.4
0.2
1.5
2
2.5
3
3.5
4
-0.2
29/61
LaGrange Polynomials

Explicit form for interpolating polynomial!
Li (t )  
j i
(t  t j )
(ti  t j )
1
0.8
0.6
0.4
0.2
1.5
2
2.5
3
3.5
4
-0.2
30/61
LaGrange Polynomials

Explicit form for interpolating polynomial!
Li (t )  
j i
(t  t j )
(ti  t j )
1
0.8
0.6
0.4
0.2
1.5
2
2.5
3
3.5
4
-0.2
31/61
LaGrange Polynomials

Explicit form for interpolating polynomial!
Li (t )  
j i
(t  t j )
(ti  t j )
n
y (t )   yi Li (t )
i 0
32/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
y
y1
y0
0
1
2
3
t
33/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
y
y1
f (t )
y0
0
1
2
3
t
34/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
y1
f (t )
g (t )
y2
y0
0
1
2
3
t
35/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
(2  t ) f (t )  t g (t )
h(t ) 
2
y1
h(t )
y2
y0
0
1
2
3
t
36/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
(2  t ) f (t )  t g (t )
h(t ) 
2
y1
h(t )
y2
y0
0
1
2
(2  1) f (1)  1 g (1)
h(1) 
2
3
t
37/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
(2  t ) f (t )  t g (t )
h(t ) 
2
y1
h(t )
y2
y0
0
1
2
y1  y1
h(1) 
 y1
2
3
t
38/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
(2  t ) f (t )  t g (t )
h(t ) 
2
y1
h(t )
y2
y0
0
1
2
(2  0) f (0)  0 g (0)
h(0) 
2
3
t
39/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
(2  t ) f (t )  t g (t )
h(t ) 
2
y1
h(t )
y2
y0
0
1
2
2 y0
h ( 0) 
 y0
2
3
t
40/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
(2  t ) f (t )  t g (t )
h(t ) 
2
y1
h(t )
y2
y0
0
1
2
(2  2) f (2)  2 g (2)
h(2) 
2
3
t
41/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
f (t )  (1  t ) y0  t y1
g (t )  (2  t ) y1  (t 1) y2
y
(2  t ) f (t )  t g (t )
h(t ) 
2
y1
h(t )
y2
y0
0
1
2
2 y2
h ( 2) 
 y2
2
3
t
42/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
y
y1
y3
h(t )
y2
y0
0
1
2
3
t
43/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
y
y1
y2
y0
0
y3
1
2
k (t )
3
t
44/61
Neville’s Algorithm

Identical to matrix method but uses a
geometric construction
(3  t )h(t )  t k (t )
m(t ) 
3
y
y1
y3
m(t )
y2
y0
0
1
2
3
t
45/61
Neville’s Algorithm
t1  t
t1  t0
y0
y01 (t )
t  t0
t1  t0
t2  t
t 2  t1
y1
y12 (t )
y23 (t )
t  t1
t 2  t1
t3  t
t3  t 2
y2
t  t2
t3  t 2
y3
46/61
Neville’s Algorithm
t2  t
t 2  t0
t1  t
t1  t0
y0
y01 (t )
y012 (t )
t  t0
t1  t0
t  t0
t 2  t0
t2  t
t 2  t1
y1
t3  t
t3  t1
y12 (t )
y123 (t )
t  t1
t3  t1
y23 (t )
t  t1
t 2  t1
t3  t
t3  t 2
y2
t  t2
t3  t 2
y3
47/61
Neville’s Algorithm
y0123 (t )
t3  t
t3  t 0
t2  t
t 2  t0
t1  t
t1  t0
y0
y01 (t )
y012 (t )
t  t0
t1  t0
t  t0
t3  t 0
t  t0
t 2  t0
t2  t
t 2  t1
y1
t3  t
t3  t1
y12 (t )
y123 (t )
t  t1
t3  t1
y23 (t )
t  t1
t 2  t1
t3  t
t3  t 2
y2
t  t2
t3  t 2
y3
48/61
Neville’s Algorithm

Claim: The polynomial produced by Neville’s
algorithm is unique
49/61
Neville’s Algorithm


Claim: The polynomial produced by Neville’s
algorithm is unique
Proof: Assume that there are two degree n
polynomials a(t )  b(t ) such that
a(ti)=b(ti)=yi for i=0…n.
50/61
Neville’s Algorithm


Claim: The polynomial produced by Neville’s
algorithm is unique
Proof: Assume that there are two degree n
polynomials a(t )  b(t ) such that
a(ti)=b(ti)=yi for i=0…n.
c(t)=a(t)-b(t) is also a polynomial of degree n
51/61
Neville’s Algorithm


Claim: The polynomial produced by Neville’s
algorithm is unique
Proof: Assume that there are two degree n
polynomials a(t )  b(t ) such that
a(ti)=b(ti)=yi for i=0…n.
c(t)=a(t)-b(t) is also a polynomial of degree n
c(t) has n+1 roots at each of the ti
52/61
Neville’s Algorithm


Claim: The polynomial produced by Neville’s
algorithm is unique
Proof: Assume that there are two degree n
polynomials a(t )  b(t ) such that
a(ti)=b(ti)=yi for i=0…n.
c(t)=a(t)-b(t) is also a polynomial of degree n
c(t) has n+1 roots at each of the ti
Polynomials of degree n can have at most n
roots!
53/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i
54/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i







f 0 (t0 )
f1 (t0 )
(1)
f1 (t0 )
f 0 (t1 )
(1)
f 0 (t1 )
f 0 (t0 )
f 2 (t0 )
(1)
f 2 (t0 )
(1)
f1 (t1 )
(1)
f 2 (t1 )
f1 (t1 )
f 2 (t1 )
(1)
f 3 (t0 )  c0   y0 
   (1) 
(1)
f 3 (t0 )  c1   y0 
  (1) 
(1)



f 3 (t1 ) c2
y1
  





f 3 (t1 )  c3   y1 
55/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i
 1 t0

0 1

0 1
1 t
1

t0
2
2t0
2t1
t1
2
3
t0  c0   y0 
   (1) 
2
3t0  c1   y0 
  (1) 
2 

3t1  c2   y1 
3
t1  c3   y1 
56/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i
 c0   1 t0
  
 c1   0 1
c   0 1
 2 
c  1 t
 3 
1
t0
2
2t0
2t1
t1
2
t0 

2
3t0 
2 
3t1 
3
t1 
3
1
 y0 
 (1) 
 y0 
 y (1) 
 1 
 y 
 1 
57/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i
y (t )  1 t t
2
 c0 
 
c
3  1
t    1 t t 2
c
 2
c 
 3
 1 t0

1
3 0
t 
0 1
1 t
1

t0
2
2t0
2t1
t1
2
t0 

2
3t0 
2 
3t1 
3
t1 
3
1
 y0 
 (1) 
 y0 
 y (1) 
 1 
 y 
 1 
58/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i
 H 0 3   (t  1) 2 (1  2t ) 
 3 

2
 H1   (t  1) t 
 3 

2
(
t

1
)
t
H
 2  

 H 3   (3  2t )t 2 

 3  
59/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i
60/61
Hermite Interpolation
Find a polynomial y(t) that interpolates yi,
(m )
(1)
(2)
yi , yi , …, yi
 Always a unique y(t) of degree n  1   mi

i
i
61/61