1 dr. scott schaefer smooth curves. 2/109 smooth curves interpolation interpolation through linear...
TRANSCRIPT
1
Dr. Scott Schaefer
Smooth Curves
2/109
Smooth Curves
Interpolation Interpolation through Linear AlgebraLagrange interpolation
Bezier curves B-spline curves
3/109
Smooth Curves
How do we create smooth curves?
4/109
Smooth Curves
How do we create smooth curves?
Parametric curves with polynomials
)(),()( tytxtp
5/109
Smooth Curves
Controlling the shape of the curve
32
32
)(
)(
htgtftety
dtctbtatx
6/109
Smooth Curves
Controlling the shape of the curve
321)(
)(
tttty
ttx
7/109
Smooth Curves
Controlling the shape of the curve
323)(
)(
tttty
ttx
8/109
Smooth Curves
Controlling the shape of the curve
321)(
)(
tttty
ttx
9/109
Smooth Curves
Controlling the shape of the curve
321)(
)(
tttty
ttx
10/109
Smooth Curves
Controlling the shape of the curve
321)(
)(
tttty
ttx
11/109
Smooth Curves
Controlling the shape of the curve
3231)(
)(
tttty
ttx
12/109
Smooth Curves
Controlling the shape of the curve
321)(
)(
tttty
ttx
13/109
Smooth Curves
Controlling the shape of the curve
321)(
)(
tttty
ttx
14/109
Smooth Curves
Controlling the shape of the curve
321)(
)(
tttty
ttx
Power-basis coefficients not intuitive for controlling shape of curve!!!
15/109
Interpolation
Find a polynomial that passes through specified values
y
t
32)( dtctbtaty
0 1 2 3
16/109
Interpolation
Find a polynomial that passes through specified values
y
t
32)( dtctbtaty 3)0( ay
1)1( dcbay3842)2( dcbay12793)3( dcbay
0 1 2 3
17/109
Interpolation
Find a polynomial that passes through specified values
y
t
32)( dtctbtaty
1
3
1
3
27931
8421
1111
0001
d
c
b
a
0 1 2 3
18/109
Interpolation
Find a polynomial that passes through specified values
y
t
32)( dtctbtaty
31
320
6
3
d
c
b
a
0 1 2 3
19/109
Interpolation
Find a polynomial that passes through specified values
y
t
Intuitive control of curve using “control points”!!!
0 1 2 3
20/109
Interpolation
Perform interpolation for each component separately
Combine result to obtain parametric curve
y
x
)(),()( tytxtp
21/109
Interpolation
Perform interpolation for each component separately
Combine result to obtain parametric curve
y
x
)(),()( tytxtp
22/109
Interpolation
Perform interpolation for each component separately
Combine result to obtain parametric curve
y
x
)(),()( tytxtp
23/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
24/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
)(tf
10)1()( ytyttf
25/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
)(tf
10)1()( ytyttf
2y)(tg
21 )1()2()( ytyttg
26/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
10)1()( ytyttf
2y
)(th
21 )1()2()( ytyttg
2
)()()2()(
tgttftth
27/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
10)1()( ytyttf
2y
)(th
21 )1()2()( ytyttg
2
)()()2()(
tgttftth
2
)1(1)1()12()1(
gfh
28/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
10)1()( ytyttf
2y
)(th
21 )1()2()( ytyttg
2
)()()2()(
tgttftth
111
2)1( y
yyh
29/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
10)1()( ytyttf
2y
)(th
21 )1()2()( ytyttg
2
)()()2()(
tgttftth
2
)0(0)0()02()0(
gfh
30/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
10)1()( ytyttf
2y
)(th
21 )1()2()( ytyttg
2
)()()2()(
tgttftth
00
2
2)0( y
yh
31/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
10)1()( ytyttf
2y
)(th
21 )1()2()( ytyttg
2
)()()2()(
tgttftth
2
)2(2)2()22()2(
gfh
32/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
10)1()( ytyttf
2y
)(th
21 )1()2()( ytyttg
2
)()()2()(
tgttftth
22
2
2)2( y
yh
33/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
2y
)(th3y
34/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
2y )(tk
3y
35/109
Lagrange Interpolation
Identical to matrix method but uses a geometric construction
y
t0 1 2 3
0y
1y
2y
)(tm3y
3
)()()3()(
tktthttm
36/109
Uniform Lagrange Interpolation
Base Case Linear interpolation between two points
Inductive Step Assume we have points yi, …, yn+1+i
Build interpolating polynomials f(t), g(t) of degree n for yi, …, yn+i and yi+1, …, yn+1+i
h(t) interpolates all points yi, …, yn+1+i and is of degree n+1
Moreover, h(t) is unique
1
)()()()1()(
n
tgittftinth
37/109
Lagrange Evaluation Pseudocode
Lagrange(pts, i, t)
n = length(pts)-2
if n is 0
return pts[0](i+1-t)+pts[1](t-i)
f=Lagrange(pts without last element, i, t)
g=Lagrange(pts without first element, i+1, t)
return ((n+1+i-t)f+(t-i)g)/(n+1)
38/109
Problems with Interpolation
39/109
Problems with Interpolation
40/109
Bezier Curves
Polynomial curves that seek to approximate rather than to interpolate
41/109
Bernstein Polynomials
Degree 1: (1-t), t Degree 2: (1-t)2, 2(1-t)t, t2
Degree 3: (1-t)3, 3(1-t)2t, 3(1-t)t2, t3
42/109
Bernstein Polynomials
Degree 1: (1-t), t Degree 2: (1-t)2, 2(1-t)t, t2
Degree 3: (1-t)3, 3(1-t)2t, 3(1-t)t2, t3
Degree 4: (1-t)4, 4(1-t)3t, 6(1-t)2t2, 4(1-t)t3,t4
43/109
Bernstein Polynomials
Degree 1: (1-t), t Degree 2: (1-t)2, 2(1-t)t, t2
Degree 3: (1-t)3, 3(1-t)2t, 3(1-t)t2, t3
Degree 4: (1-t)4, 4(1-t)3t, 6(1-t)2t2, 4(1-t)t3,t4
Degree 5: (1-t)5, 5(1-t)4t, 10(1-t)3t2, 10(1-t)2t3 ,5(1-t)t4,t5
… Degree n: for
iin tti
n
)1( ni 0
44/109
Bezier Curves
n
ii
iin ptti
ntp
0
)1()(
45/109
Bezier Curves
n
ii
iin ptti
ntp
0
)1()(
)1,0()1,1()1(3)0,1()1(3)0,0()1()( 3223 tttttttp
46/109
Bezier Curves
n
ii
iin ptti
ntp
0
)1()(
))23(,)1(3()( 2tttttp
47/109
Bezier Curve Properties
Interpolate end-points
n
ii
iin ptti
ntp
0
)1()(
48/109
Bezier Curve Properties
Interpolate end-points
00
0)01()0( ppi
np
n
ii
iin
49/109
Bezier Curve Properties
Interpolate end-points
n
n
ii
iin ppi
np
0
1)11()1(
50/109
Bezier Curve Properties
Interpolate end-points
n
n
ii
iin ppi
np
0
1)11()1(
51/109
Bezier Curve Properties
Interpolate end-points Tangent at end-points in direction of first/last
edge
n
ii
iin ptti
ntp
0
)1()(
52/109
Bezier Curve Properties
Interpolate end-points Tangent at end-points in direction of first/last
edge
n
i
iiniini
n
ii
iin ttinttipinptti
ntt
tp
0
11
0
)1)(()1()1()(
53/109
Bezier Curve Properties
Interpolate end-points Tangent at end-points in direction of first/last
edge
)()0(
01 ppnt
p
)()1(
1
nn ppn
t
p
54/109
Bezier Curve Properties
Interpolate end-points Tangent at end-points in direction of first/last
edge Curve lies within the convex hull of the
control points
55/109
Convex Hull
The smallest convex set containing all points pi
56/109
Convex Hull
The smallest convex set containing all points pi
57/109
Bezier Curve Properties
Interpolate end-points Tangent at end-points in direction of first/last
edge Curve lies within the convex hull of the
control points Bezier Lagrange
58/109
Pyramid Algorithms for Bezier Curves Polynomials aren’t pretty Is there an easier way to evaluate the
equation of a Bezier curve?
n
ii
iin ptti
ntp
0
)1()(
59/109
Pyramid Algorithms forBezier Curves
0p 1p 2p 3p
21)1( ptpt 10)1( ptpt 32)1( ptpt
t1 t1 t1t tt
60/109
Pyramid Algorithms forBezier Curves
0p 1p 2p 3p
22
102 )1(2)1( ptpttpt
t1 t1 t1t tt
t1 t t1 t
32
212 )1(2)1( ptpttpt
61/109
Pyramid Algorithms forBezier Curves
0p 1p 2p 3p
t1 t1 t1t tt
t1 t t1 t
33
22
12
03 )1(3)1(3)1( ptpttpttpt
t1 t
62/109
Bezier Evaluation Pseudocode
Bezier(pts, t)
if ( length(pts) is 1)
return pts[0]
newPts={}
For ( i = 0, i < length(pts) – 1, i++ )
Add to newPts (1-t)pts[i] + t pts[i+1]
return Bezier ( newPts, t )
63/109
Subdividing Bezier Curves
Given a single Bezier curve, construct two smaller Bezier curves whose union is exactly the original curve
64/109
Subdividing Bezier Curves
Given a single Bezier curve, construct two smaller Bezier curves whose union is exactly the original curve
65/109
Subdividing Bezier Curves
Given a single Bezier curve, construct two smaller Bezier curves whose union is exactly the original curve
66/109
Subdividing Bezier Curves
Given a single Bezier curve, construct two smaller Bezier curves whose union is exactly the original curve
67/109
Subdividing Bezier Curves
Given a single Bezier curve, construct two smaller Bezier curves whose union is exactly the original curve
68/109
Subdividing Bezier Curves
0p 1p 2p 3p
t1 t1 t1t tt
t1 t t1 t
t1 tControl points for left curve!!!
69/109
Subdividing Bezier Curves
0p 1p 2p 3p
t1 t1 t1t tt
t1 t t1 t
t1 t Control points for right curve!!!
70/109
Subdividing Bezier Curves
0p 1p 2p 3p
21
21
21
21
21
21
21
21
21
21
21
21
121
021 pp 22
112
1 pp 321
221 pp
241
121
041 ppp 34
122
114
1 ppp
381
283
183
081 pppp
71/109
Adaptive Rendering of Bezier Curves
If control polygon is close to a line, draw the control polygon
If not, subdivide and recur on subdivided pieces
72/109
Adaptive Rendering of Bezier Curves
If control polygon is close to a line, draw the control polygon
If not, subdivide and recur on subdivided pieces
73/109
Adaptive Rendering of Bezier Curves
If control polygon is close to a line, draw the control polygon
If not, subdivide and recur on subdivided pieces
74/109
Adaptive Rendering of Bezier Curves
If control polygon is close to a line, draw the control polygon
If not, subdivide and recur on subdivided pieces
75/109
Adaptive Rendering of Bezier Curves
If control polygon is close to a line, draw the control polygon
If not, subdivide and recur on subdivided pieces
76/109
Adaptive Rendering of Bezier Curves
If control polygon is close to a line, draw the control polygon
If not, subdivide and recur on subdivided pieces
77/109
Applications: Intersection
Given two Bezier curves, determine if and where they intersect
78/109
Applications: Intersection
Check if convex hulls intersect If not, return no intersection If both convex hulls can be approximated
with a straight line, intersect lines and return intersection
Otherwise subdivide and recur on subdivided pieces
79/109
Applications: Intersection
80/109
Applications: Intersection
81/109
Applications: Intersection
82/109
Applications: Intersection
83/109
Applications: Intersection
84/109
Applications: Intersection
85/109
Applications: Intersection
86/109
Applications: Intersection
87/109
Applications: Intersection
88/109
Applications: Intersection
89/109
Applications: Intersection
90/109
Application: Font Rendering
91/109
Application: Font Rendering
92/109
Problems with Bezier Curves
More control points means higher degree Moving one control point affects the entire
curve
93/109
Problems with Bezier Curves
More control points means higher degree Moving one control point affects the entire
curve
94/109
B-spline Curves
Not a single polynomial, but lots of polynomials that meet together smoothly
Local control
95/109
B-spline Curves
Not a single polynomial, but lots of polynomials that meet together smoothly
Local control
96/109
Rendering B-spline Curves
Lane-Reisenfeld subdivision algorithm
Linearly subdivide the curve by inserting the midpoint on each edge
Perform averaging by replacing each edge by its midpoint d times
Subdivide the curve repeatedly
97/109
Rendering B-spline Curves
0p 1p 2p210 pp
221 pp
232 pp
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
98/109
Rendering B-spline Curves
99/109
Rendering B-spline Curves
100/109
Rendering B-spline Curves
101/109
Rendering B-spline Curves
102/109
Rendering B-spline Curves
103/109
Rendering B-spline Curves
104/109
Rendering B-spline Curves
105/109
Rendering B-spline Curves
106/109
B-spline Properties
Curve lies within convex hull of control points
Variation Diminishing: Curve wiggles no more than control polygon
Influence of one control point is bounded Degree of curve increases by one with each
averaging step Smoothness increases by one with each
averaging step
107/109
B-spline Curve Example
108/109
B-spline Curve Example
109/109
B-spline Curve Example