Least Squares Curve Generation, Rational Representations, Splines

advertisement
Least Squares Curves, Rational
Representations, Splines and
Continuity
Dr. Scott Schaefer
1
Degree Reduction

Given a set of coefficients b̂i for a Bezier
curve of degree n+1, find the best set of
coefficients of a Bezier curve bi of degree n
that approximate that curve
2/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
3/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
n 1
 bˆ0 


 bˆ1 

  n2
  
 bˆ 
 n 1 
 1

i
1  n 1
 0

 0

0  b0 



i
0 0  b1 
n 1
  0   
 
0 0 1  bn 
0
0
4/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
bˆ  Mb
5/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
M T bˆ  M T Mb
6/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
M
T
M

1
M T bˆ  b
7/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
M

T
M

1
M T bˆ  b
Problem: end-points are not interpolated
b0  bˆ0 bn  bˆn1
8/72
Least Squares Optimization
Ax  b
9/72
Least Squares Optimization
min  Ax  b   Ax  b 
T
x
10/72
Least Squares Optimization
min  Ax  b   Ax  b 
T
x
F ( x)  x A Ax  2 x A b  b b
T
T
T
T
T
11/72
Least Squares Optimization
min  Ax  b   Ax  b 
T
x
F ( x)  x A Ax  2 x A b  b b
T
T
T
T
T
F ( x)
T
T
 2 A Ax  2 A b  0
x
12/72
Least Squares Optimization
min  Ax  b   Ax  b 
T
x
F ( x)  x A Ax  2 x A b  b b
T
T
T
T
T
F ( x)
T
T
 2 A Ax  2 A b  0
x
A Ax  A b
T
T
13/72
Least Squares Optimization
min  Ax  b   Ax  b 
T
x
F ( x)  x A Ax  2 x A b  b b
T
T
T
T
T
F ( x)
T
T
 2 A Ax  2 A b  0
x


x A A
T
1
T
Ab
14/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
T
Ab
15/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
T
Ab
Mvi  vi i
16/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
T
Ab
Mvi  vi i
 12
1
8
0

1
2
3
4
1
2
0 1 1





1
8 1  11
1
1  
1
 
2  
17/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
T
Ab
Mvi  vi i
 12
1
8
0

1
2
3
4
1
2
0   1   1





1
1
8  0    0 
2



1 
1
2  1 
18/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
T
Ab
Mvi  vi i
 12
1
8
0

1
2
3
4
1
2
0  2   2 





1
1
8   1    1
4



1 
2
2  2 
19/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
T
Ab
MV V
20/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
T
Ab
MV V
 12
1
8
0

1
2
3
4
1
2
0 1  1 2  1  1 2  1 0 0 







1
1
1
0

1

1
0

1
0
0
 

8 
2
 1 1 2  0 0 1 
1 
1
1
2
 

2 
4
21/72
The PseudoInverse


What happens when A A isn’t invertible?


x A A
T
1
M  VV



0

1
2
1
8

1
T
1
2
3
4
1
2
T
Ab
1
0  1  1 2  1 0 0 1  1 2 
 



1
1
0  1 0 2 0 1 0  1
8   1
1 1 2  0 0 1 1 1 2 
1



2
4 
1
22/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
M  VV
M
1
T
Ab
1
?
23/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A
T
1
M  VV
M
1
1
T
Ab
1
 V V
1
24/72
The PseudoInverse


What happens when A A isn’t invertible?


x A A
M



0

1
2
1
8

1
T
1
2
3
4
1
2
1
1
T
1
1
T
Ab
 V V
1
0
1  1 2  1 0 0 1  1 2 





1
 1 0  1 0 2 0 1 0  1
8
1 1 2  0 0 4 1 1 2 
1




2
1
25/72
The PseudoInverse


What happens when A A isn’t invertible?


x A A
M
 14
1
8
1
4

1
T
1
2
3
4
1
2
1
4
1
8
1
4
1
T
1
1
T
Ab
 V V
1
1  1 2  1  1 2  1 0 0 


 

1 0  1  1 0  1 0 0 0 
1 1 2  1 1 2  0 0 1 
 

4

26/72
The PseudoInverse


What happens when A A isn’t invertible?


x A A
M





1
4
1
8
1
4

1
T
1
2
3
4
1
2
1
4
1
8
1
4
1
T
1
1
T
Ab
 V V
1
 1  1 2  1 0 0 1  1 2 
 



  1 0  1 0 0 0 1 0  1
 1 1 2  0 0 1 1 1 2 


4 
 
1
27/72
The PseudoInverse



1
T
What happens when A A isn’t invertible?


x A A

T
1

Ab
M  V V





1
4
1
8
1
4
1
2
3
4
1
2
1
4
1
8
1
4

T
1
 1  1 2  1 0 0 1  1 2 
 



  1 0  1 0 0 0 1 0  1
 1 1 2  0 0 4 1 1 2 



 
1
28/72
Constrained Least Squares Optimization
min  Ax  b   Ax  b  subject to Cx  d
T
x
29/72
Constrained Least Squares Optimization
min  Ax  b   Ax  b  subject to Cx  d
T
x
Solution
Constraint Space
Error Function F(x)
30/72
Constrained Least Squares Optimization
min  Ax  b   Ax  b  subject to Cx  d
T
x
G ( x)  x C  d
T
T
T
G ( x)
T
C 
x
31/72
Constrained Least Squares Optimization
min  Ax  b   Ax  b  subject to Cx  d
T
x
A Ax  A b  C 
T
T
T
32/72
Constrained Least Squares Optimization
min  Ax  b   Ax  b  subject to Cx  d
T
x
A Ax  C   A b
T
T
T
33/72
Constrained Least Squares Optimization
min  Ax  b   Ax  b  subject to Cx  d
T
x
A Ax  C   A b
T
T
T
 A A C  x   A b 

   

 C
   d 
0

  

T
T
T
34/72
Constrained Least Squares Optimization
min  Ax  b   Ax  b  subject to Cx  d
T
x
A Ax  C   A b
T
T
T
1
 x   A A C   A b
 

   
  d 

C
0
  
 

T
T
T
35/72
Least Squares Curves
n
F (t )   ci C (t )
i 0
n
i
{( t0 , p0 ),..., (tm , pm )} where m  n  1
36/72
Least Squares Curves
n
F (t )   ci C (t )
n
i
i 0
{( t0 , p0 ),..., (tm , pm )} where m  n  1
 C (t0 ) ... C (t0 )  c0   p0 


  

       
 
 C n (t ) ... C n (t )  c   p T 
n m  n 
 0 m
 m 
n
0
n
n
T
37/72
Least Squares Curves
n
F (t )   ci C (t )
n
i
i 0
{( t0 , p0 ),..., (tm , pm )} where m  n  1
 C (t0 ) ... C (t0 )  c0   p0 


  

       
 
 C n (t ) ... C n (t )  c   p T 
n m  n 
 0 m
 m 
n
0
T
n
n
A
x
b
38/72
Least Squares Curves
n
F (t )   ci C (t )
i 0
n
i
{( t0 , p0 ),..., (tm , pm )} where m  n  1
1
x  ( A A) A b
T
T
39/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
M

T
M

1
M T bˆ  b
Problem: end-points are not interpolated
b0  bˆ0 bn  bˆn1
40/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
M T bˆ  M T Mb
 1 0  0   bˆ0 
d
b  
Cb  
 bˆ 
0

0
1

  n 1 
41/72
Degree Reduction
n
n 1
i 0
i 0
n
n 1
i
i




b
B
(
t
)

b
1


b
B
i i
 i n1 i 1 n1 i (t )
M T bˆ  M T Mb
 1 0  0   bˆ0 
d
b  
Cb  
 bˆ 
0

0
1

  n 1 
MTM

 C

C  b   M T bˆ 

   
0     d 
T
42/72
Rational Curves

Curves defined in a higher dimensional space
that are “projected” down
p  {x, y, w}
x y
projected p  { , }
w w
typically written as p  {wx, wy, w}
43/72
Rational Curves

Curves defined in a higher dimensional space
that are “projected” down
 i 0
p(t )   n n
  wi Bi (t )
 i 0
n
n
 wi xi Bi ( t )
n
n
 wi yi Bi ( t )
i 0
n
n
 wi Bi ( t )
i 0




44/72
Rational Curves

Curves defined in a higher dimensional space
that are “projected” down
 i 0
p(t )   n n
  wi Bi (t )
 i 0
n
n
 wi xi Bi ( t )
n
n
 wi yi Bi ( t )
i 0
n
n
 wi Bi ( t )
i 0




1
1
1
45/72
Rational Curves

Curves defined in a higher dimensional space
that are “projected” down
 i 0
p(t )   n n
  wi Bi (t )
 i 0
n
n
 wi xi Bi ( t )
n
n
 wi yi Bi ( t )
i 0
n
n
 wi Bi ( t )
i 0




2
1
1
46/72
Why Rational Curves?

Conics
( x(t ), y (t )) 

1t 2
1 t 2
, 12tt 2

47/72
Why Rational Curves?

Conics
( x(t ), y (t )) 
x(t )  y(t ) 
2
2
   
1t 2
1t 2
2

2t 2
1 t 2
1t 2
1 t 2

, 12tt 2

1 2t 2 t 4
1 2t 2 t 4

4t 2
1 2t 2  t 4
1
48/72
Why Rational Curves?

Conics
( x(t ), y (t )) 

1t 2
1 t 2
, 12tt 2

49/72
Why Rational Curves?

Conics
( x(t ), y (t )) 

1t 2
1 t 2
, 12tt 2

50/72
Derivatives of Rational Curves
n 1
p ' (t ) 
n1
 ( wi 1 ( xi 1 , yi 1 )  wi ( xi , yi )) Bi
i 0
n 1
n 1
 ( wi 1  wi ) Bi
i 0
(t )
(t )
51/72
Derivatives of Rational Curves
n(t )
p(t ) 
w(t )
52/72
Derivatives of Rational Curves
w(t )n' (t )  n(t ) w' (t )
p' (t ) 
w(t ) 2
53/72
Derivatives of Rational Curves
n' (t ) n(t ) w' (t )
p' (t ) 

w(t ) w(t ) w(t )
n1
p' (t ) 
n  ( wi 1 ( xi 1 , yi 1 )  wi ( xi , yi )) Bin1 ( t )
i 0
n
n
 wi Bi ( t )
i 0
n

n
 wi ( xi , yi ) Bi ( t )
i 0
n
n
 wi Bi ( t )
i 0
n1
n  ( wi 1  wi ) Bin1 ( t )
i 0
n
n
 wi Bi ( t )
i 0
54/72
Splines and Continuity
 Ck
continuity: n  k
lim p ( n) (u)  lim p ( n) (u)
u t
u t
55/72
Splines and Continuity
 Ck
continuity: n  k
lim p ( n) (u)  lim p ( n) (u)
u t
u t
C0
56/72
Splines and Continuity
 Ck
continuity: n  k
lim p ( n) (u)  lim p ( n) (u)
u t
u t
C1
57/72
Splines and Continuity
 Ck
continuity: n  k
lim p ( n) (u)  lim p ( n) (u)
u t
u t
C2
58/72
Splines and Continuity
 Ck
continuity: n  k
lim p ( n) (u)  lim p ( n) (u)
u t
u t
C3
59/72
Splines and Continuity

Assume two Bezier curves with control
points p0,…,pn and q0,…,qm
60/72
Splines and Continuity

Assume two Bezier curves with control
points p0,…,pn and q0,…,qm

C0: pn=q0
61/72
Splines and Continuity

Assume two Bezier curves with control
points p0,…,pn and q0,…,qm
C0: pn=q0
 C1: n(pn-pn-1)=m(q1-q0)

62/72
Splines and Continuity

Assume two Bezier curves with control
points p0,…,pn and q0,…,qm
C0: pn=q0
 C1: n(pn-pn-1)=m(q1-q0)
 C2: n(n-1)(pn-2pn-1+pn-2)=m(m-1)(q0-2q1+q2)
…

63/72
Splines and Continuity

Geometric Continuity
 A curve is Gk if there exists a
reparametrization such that the curve is Ck
64/72
Splines and Continuity

Geometric Continuity
 A curve is Gk if there exists a
reparametrization such that the curve is Ck
C1
65/72
Splines and Continuity

Geometric Continuity
 A curve is Gk if there exists a
reparametrization such that the curve is Ck
G1
66/72
Problems with Bezier Curves
More control points means higher degree
 Moving one control point affects the entire
curve

67/72
Problems with Bezier Curves
More control points means higher degree
 Moving one control point affects the entire
curve

68/72
Problems with Bezier Curves
More control points means higher degree
 Moving one control point affects the entire
curve

Solution: Use lots of Bezier
curves and maintain Ck
continuity!!!
69/72
Problems with Bezier Curves
More control points means higher degree
 Moving one control point affects the entire
curve

Solution: Use lots of Bezier
curves and maintain Ck
continuity!!!
Difficult to keep track of all
the constraints. 
70/72
B-spline Curves
Not a single polynomial, but lots of
polynomials that meet together smoothly
 Local control

71/72
B-spline Curves
Not a single polynomial, but lots of
polynomials that meet together smoothly
 Local control

72/72
Download