linear methods for degree reduction of bézier curves with
TRANSCRIPT
Linear Methods for Degree Reduction of
Bezier Curves with Geometric Continuity
Stephen Mann and Abdallah Rababah
Degree 19 vs 8
• Least squares approximations
• Ends of curve (parametricvs geometric continuity)
• Linear vs non-linear solutions
Degree Reduction with Least Squares
• Want to minimize ∫ 1
0||BnPn −BmQm||2dt
Qi are variables to minimize, m < n
∂
∂Qk
∫ 1
0||BnPn −BmQm||2dt
= −2∫ 1
0(BnPn −BmQm)Bmk dt
= −2(∑∫ 1
0Bmk B
ni Pidt−
∑∫ 1
0Bmk B
mj Qjdt)
= −2(∑
mk,iPi −∑
m′k,jQj)
Degree Reduction with Least Squares
• Want to minimize ∫ 1
0||BnPn −BmQm||2dt
Qi are variables to minimize, m < n
∂
∂Qk
∫ 1
0||BnPn −BmQm||2dt
= −2∫ 1
0(BnPn −BmQm)Bmk dt
= −2(∑∫ 1
0Bmk B
ni Pidt−
∑∫ 1
0Bmk B
mj Qjdt)
= −2(∑
mk,iPi −∑
m′k,jQj)
Degree Reduction with Least Squares
• Want to minimize ∫ 1
0||BnPn −BmQm||2dt
Qi are variables to minimize, m < n
∂
∂Qk
∫ 1
0||BnPn −BmQm||2dt
= −2∫ 1
0(BnPn −BmQm)Bmk dt
= −2(∑∫ 1
0Bmk B
ni Pidt−
∑∫ 1
0Bmk B
mj Qjdt)
= −2(∑
mk,iPi −∑
m′k,jQj)
Degree Reduction with Least Squares
• Want to minimize ∫ 1
0||BnPn −BmQm||2dt
Qi are variables to minimize, m < n
∂
∂Qk
∫ 1
0||BnPn −BmQm||2dt
= −2∫ 1
0(BnPn −BmQm)Bmk dt
= −2(∑∫ 1
0Bmk B
ni Pidt−
∑∫ 1
0Bmk B
mj Qjdt)
= −2(∑
mk,iPi −∑
m′k,jQj)
Degree Reduction with Least Squares
• Want to minimize ∫ 1
0||BnPn −BmQm||2dt
Qi are variables to minimize, m < n
∂
∂Qk
∫ 1
0||BnPn −BmQm||2dt
= −2∫ 1
0(BnPn −BmQm)Bmk dt
= −2(∑∫ 1
0Bmk B
ni Pidt−
∑∫ 1
0Bmk B
mj Qjdt)
= −2(∑
mk,iPi −∑
m′k,jQj)∫ 10 B
mi (t)Bnj (t)dt =
(mi )(nj)
(m+n+1)(m+ni+j )
= mi,j
Degree Reduction with Least Squares
• Want to minimize ∫ 1
0||BnPn −BmQm||2dt
Qi are variables to minimize, m < n
∂
∂Qk
∫ 1
0||BnPn −BmQm||2dt
= −2∫ 1
0(BnPn −BmQm)Bmk dt
= −2(∑∫ 1
0Bmk B
ni Pidt−
∑∫ 1
0Bmk B
mj Qjdt)
= −2(∑
mk,iPi −∑
m′k,jQj)
Least Squares Solution
• We have m+ 1 equations of the form
−2(∑
mk,iPi −∑
m′k,jQj)
• Gather into matrices of m+ 1 control points, etc., and set to 0:
0 = (MmnP −MmmQ)
Q = M−1mmMmnP
• Bonus: Mmm is positive definite
• Extra bonus: Qjs are multivariate, but only need (m+ 1)× (m+ 1)system
and not d(m+ 1)× d(m+ 1) system
Least Squares Solution
• We have m+ 1 equations of the form
−2(∑
mk,iPi −∑
m′k,jQj)
• Gather into matrices of m+ 1 control points, etc., and set to 0:
0 = (MmnP −MmmQ)
Q = M−1mmMmnP
• Bonus: Mmm is positive definite
• Extra bonus: Qjs are multivariate, but only need (m+ 1)× (m+ 1)system
and not d(m+ 1)× d(m+ 1) system
Least Squares Solution
• We have m+ 1 equations of the form
−2(∑
mk,iPi −∑
m′k,jQj)
• Gather into matrices of m+ 1 control points, etc., and set to 0:
0 = (MmnP −MmmQ)
Q = M−1mmMmnP
• Bonus: Mmm is positive definite
• Extra bonus: Qjs are multivariate,
but only need (m+ 1)× (m+ 1) system
and not d(m+ 1)× d(m+ 1) system
(i.e., do not have to expand into coordinates)
Least Squares Solution
• We have m+ 1 equations of the form
−2(∑
mk,iPi −∑
m′k,jQj)
• Gather into matrices of m+ 1 control points, etc., and set to 0:
0 = (MmnP −MmmQ)
Q = M−1mmMmnP
• Bonus: Mmm is positive definite
• Extra bonus: Qjs are multivariate,
suggest d(m+ 1)× d(m+ 1) system
but only need (m+ 1)× (m+ 1) system
(i.e., do not have to expand into coordinates)
Examples
Degree 10 curve (from Lu-Wang paper)
Degree 3 Degree 4
Examples
Degree 10 curve (from Lu-Wang paper)
Degree 3 Degree 4
Continuity At Ends
• C0: Q0 = P0, Qm = Pn
• C1: Q1 = P0 + nm(P1 − P0), Qm−1 = Pn − n
m(Pn − Pn−1)
• Ck: (first k + 1 CPs), (last k + 1 CPs)
• Each level of continuity removes two variables,
and two fewer equations
Ck Solutions
• Equation changes to
0 = (MmnP −MmmQ) = (MmnP −McmmQ
c −MfmmQ
f)
where
– Qc are end points (set by continuity)
– Qf are free points
Mcmm,Mf
mm submatrices of Mmm
• Solution:
Qf = (Mfmm)−1(MmnP −Mc
mmQc)
Ck Solutions
• Equation changes to
0 = (MmnP −MmmQ) = (MmnP −McmmQ
c −MfmmQ
f)
where
– Qc are end points (set by continuity)
– Qf are free points
Mcmm,Mf
mm submatrices of Mmm
• Solution:
Qf = (Mfmm)−1(MmnP −Mc
mmQc)
C0, C1 Example
degree 4 C0, degree 4 C1, degree 4
Geometric Continuity
• Parametric continuity: equal derivatives
• If only care about geometry, then use geometric continuity
– G1: equal tangent lines
Q1 = P0 + δ0nm(P1 − P0)
Qm−1 = Pn − δ1nm(Pn − Pn−1)
δ0, δ1 > 0
– G2: equal curvature
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)δ2
0∆P20 +
n
m(m− 1)η0∆P0
Qm−2 = 2Qm−1 −Qm +n(n− 1)
m(m− 1)δ2
1∆P2m−2 +
n
m(m− 1)η1∆Pm−1
where ∆s are differences of control points
Lu-Wang G1
• Didn’t like δ0, δ1 > 0 constraint, so rewrote to
Q1 = P0 + δ20nm(P1 − P0)
Qm−1 = Pn − δ21nm(Pn − Pn−1)
• Iterative method:
1. Set delta0=delta1=1
2. Solve for Qs as for C1
3. Use Qs to solve for deltas
Quartic equations
4. Goto 2
• Extra condition to avoid δi = 0 or even δi small
∫ 10 ||BnPn −BmQm||2dt
Lu-Wang G2
• Modified G1 equations change G2 equations to
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)δ4
0∆P20 +
n
m(m− 1)η0∆P0
Qm−2 = 2Qm−1 −Qm +n(n− 1)
m(m− 1)δ4
1∆P2m−2 +
n
m(m− 1)η1∆Pm−1
• Iterative method:
1. Set delta0=delta1=1, eta0=eta1=0
2. Solve for Qs as for C2
3. Use Qs to solve for deltas, etas
Degree 8 equations
4. Goto 2
• Extra condition to avoid δi = 0 or even δi small
∫ 10 ||BnPn −BmQm||2dt
Linear G1 Method
• Observation: if you use original G1 equations,then δis linear in equations
Q1 = P0 + δ0nm(P1 − P0)
Qm−1 = Pn − δ1nm(Pn − Pn−1)
• Take derivatives w.r.t. Qk, δi
∫ 1
0||BnPn −BmQm||2dt
• Single system of equations linear in Qks, δis
− Have to expand Qk equations into coordinates
− Deal with δi < 0 cases
Linear G1 Method
• Observation: if you use original G1 equations,then δis linear in equations
Q1 = P0 + δ0nm(P1 − P0)
Qm−1 = Pn − δ1nm(Pn − Pn−1)
• Take derivatives w.r.t. Qk, δi
∫ 1
0||BnPn −BmQm||2dt
• Single system of equations linear in Qks, δis (no iteration)
− Have to expand Qk equations into coordinates
− Deal with δi < 0 cases
δi < 0
When δi < 0,
• New system of equations with δi = ε
ε related to minimum acceptable length of tangent
• Resolve new system of equations
• Possibly have to solve 3 times
• If both δi set to minimum, then C1 solution
G1 Example
Black: Degree 10 curve
Red: C1 quartic (L2 0.60)
Green: G1 quartic (L2 0.44)
Linear G2, G3 Methods
• G2 equations quadratic in δs:
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)δ2
0∆P20 +
n
m(m− 1)η0∆P0
• Instead, make C1/G2 by fixing δis to be 1
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)∆P2
0 +n
m(m− 1)η0∆P0
Now equations are linear in ηs
Don’t have to worry about δ < 0
Linear system to find C1/G2 approximation
• For G3, setting δi = 1 leads to linear systems with four unknowns
Q3 = 3Q2 − 3Q1 +Q0 +1
m(m− 1)(m− 2)[n∆p0ζ0 +
3n(n− 1)∆2p0η0 + n(n− 1)(n− 2)∆3p0]
Linear G2, G3 Methods
• G2 equations quadratic in δs:
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)δ2
0∆P20 +
n
m(m− 1)η0∆P0
• Instead, make C1/G2 by fixing δis to be 1
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)∆P2
0 +n
m(m− 1)η0∆P0
Now equations are linear in ηs
• For G3, setting δi = 1 leads to linear systems with four unknowns
Q3 = 3Q2 − 3Q1 +Q0 +1
m(m− 1)(m− 2)[n∆p0ζ0 +
3n(n− 1)∆2p0η0 + n(n− 1)(n− 2)∆3p0]
(Lu-Wang approach would require solving system of degree 12equations)
Linear G2, G3 Methods
• G2 equations quadratic in δs:
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)δ2
0∆P20 +
n
m(m− 1)η0∆P0
• Instead, make C1/G2 by fixing δis to be 1
Q2 = 2Q1 −Q0 +n(n− 1)
m(m− 1)∆P2
0 +n
m(m− 1)η0∆P0
Now equations are linear in ηs
• For G3, setting δi = 1 leads to linear systems with four unknowns
Q3 = 3Q2 − 3Q1 +Q0 +1
m(m− 1)(m− 2)[n∆p0ζ0 +
3n(n− 1)∆2p0η0 + n(n− 1)(n− 2)∆3p0]
(Lu-Wang approach would require solving system of degree 12equations)
Lu-Wang Example
Black: Degree 10 curveRed: C2 degree 6 (L2 0.037)Green: C1/G2 degree 6 (L2 0.022)Magenta: G2 degree 6 (L2 0.018)
Spiral Example
Degree 19 reduced to degree 8
Black: Degree 19 curveRed: C2 degree 8 (L2 0.037)Blue: C1/G2 degree 8 (L2 0.022)
Loop Example
Degree 13 reduced to degree 8
400
450
500
550
600
650
200 300 400 500 600 700
Blue: degree 13Red: C2 degree 8, L2=486
Green: C1/G2 degree 8, L2=58
Heart Example
Degree 13 reduced to degree 8
350
400
450
500
550
600
300 400 500 600 700
Blue: degree 13Red: C2 degree 8, L2=15.3
Green: C1/G2 degree 8, L2=6.5
Degree 55, C1/G3
Degree 55 reduced to degree 15
200
300
400
500
600
700
0 200 400 600 800 1000 1200 1400
Blue: degree 55Red: C3 degree 15, L2=35
Green: C1/G3 degree 15, L2=9.2
Numerics
• Mmm positive definite, but condition number large
For m = 15 condition number is 108
For m = 30 condition number is 1016
• Octave techniques to solve linear system
– inverse — invert the matrix
– backslash — solve linear system without inverting
Occasionally caused Octave to crash
– LUP (Gaussian elimination with pivoting)[l,u,p]=lu(a); u\l\(p*b)
Worked for degr. 55 reduced to degr. 54 (L∞ of 10−6,10−9)
(32 orders of magnitude in Mmm entries)
Numerics
• Mmm positive definite, but condition number large
For m = 15 condition number is 108
For m = 30 condition number is 1016
• Octave techniques to solve linear system
– inverse — invert the matrix inverse(a)*b
– backslash — solve linear system without inverting a\bOccasionally caused Octave to crash
– LUP (Gaussian elimination with pivoting)[l,u,p]=lu(a); u\l\(p*b)
Worked for degr. 55 reduced to degr. 54 (L∞ of 10−6,10−9)
(32 orders of magnitude in Mmm entries)
Numerics
• Mmm positive definite, but condition number large
For m = 15 condition number is 108
For m = 30 condition number is 1016
• Octave techniques to solve linear system
– inverse — invert the matrix inverse(a)*b
– backslash — solve linear system without inverting a\bOccasionally caused Octave to crash
– LUP (Gaussian elimination with pivoting)[l,u,p]=lu(a); u\l\(p*b)
Worked for degr. 55 reduced to degr. 54 (L∞ of 10−6,10−9)
(32 orders of magnitude in Mmm entries)
Numerics
• Mmm positive definite, but condition number large
For m = 15 condition number is 108
For m = 30 condition number is 1016
• Octave techniques to solve linear system
– inverse — invert the matrix inverse(a)*b
– backslash — solve linear system without inverting a\bOccasionally caused Octave to crash
– LUP (Gaussian elimination with pivoting)[l,u,p]=lu(a); u\l\(p*b)
Worked for degr. 55 reduced to degr. 54 (L∞ of 10−6,10−9)
(32 orders of magnitude in Mmm entries)
Octave: inverse vs LUP
Degree 55 curve, reduce to degree m, G1 at ends
m
inverse
LUP
log1
0(L2
)
-6
-5
-4
-3
-2
-1
0
1
2
15 20 25 30 35 40 45 50
• Numerics mostly a non-issue since we want to reduce to lowdegrees.
Summary
• Degree reduce Bezier curves
– G1, C1/G2, C1/G3 continuity
– Linear methods
– Good numerics
Question?