csce 441: keyframe animation/smooth curves (cont.) jinxiang chai
DESCRIPTION
Key-frame Interpolation Given parameter values at key frames, how to interpolate parameter values for inbetween frames. t θTRANSCRIPT
CSCE 441: Keyframe Animation/Smooth
Curves (Cont.)Jinxiang Chai
Key-frame Interpolation
• Given parameter values at key frames, how to interpolate parameter values for inbetween frames.
θ
t
Key-frame Interpolation
• Given parameter values at key frames, how to interpolate parameter values for inbetween frames.
t
θ
Key-frame Interpolation
• Given parameter values at key frames, how to interpolate parameter values for inbetween frames.
t
θ
Nonlinear interpolation
Review: Natural cubic cruves
)(23 tQdtctbta xxxxx
Review: Natural cubic cruves
)(23 tQdtctbta xxxxx
)(123 tQ
dcba
ttt x
x
x
x
x
Review: Natural cubic cruves
)(23 tQdtctbta xxxxx
)(123 tQ
dcba
ttt x
x
x
x
x
)()()()(
1111
4
3
2
1
424
34
323
33
222
32
121
31
tQtQtQtQ
dcba
tttttttttttt
x
x
x
x
x
x
x
x
)()()()(
1111
4
3
2
1
1
424
34
323
33
222
32
121
31
tQtQtQtQ
tttttttttttt
dcba
x
x
x
x
x
x
x
x
Review: Natural cubic curves
)()()()(
1111
11)(
4
3
2
1
1
424
34
323
33
222
32
121
31
2323
tQtQtQtQ
tttttttttttt
ttt
dcba
ttttQ
x
x
x
x
Properties:- Go through four control points
- not good for local control
Review: Hermite Curves
P1
R1 P4
R4
P1: start position
P4: end position
R1: start derivative
R4: end derivative
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
P1
R1 P4
R4
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
P1
R1 P4
R4
Herminte basis matrix
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
Herminte basis matrix
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
Hermite basis functions
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 20 40 60 80 100 1200
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.16
0 20 40 60 80 100 120-0.16
-0.14
-0.12
-0.1
-0.08
-0.06
-0.04
-0.02
0
basis function 1 basis function 2 basis function 3 basis function 4
Review: Hermite Curves
4
1
4
1
23
0001010012331122
1)(
RRpp
ttttQ
4
1
4
1
23232323 232132
RRPP
ttttttttt
P1
R1 P4
R4
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 20 40 60 80 100 1200
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.16
0 20 40 60 80 100 120-0.16
-0.14
-0.12
-0.1
-0.08
-0.06
-0.04
-0.02
0
)()2()32()132( 234
231
234
231 ttRtttRttPttP
*P1 *P4*R1 *R4+ + +=
Review: Bezier Curves
34
01
232
011
)(3)(3
vPvP
vvRvvR
Review: Bezier Curves
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
Review: Bezier Curves
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
3
2
1
0
3232323 33363133
vvvv
ttttttttt
Review: Bezier Curves
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
3
2
1
0
3232323 33363133
vvvv
ttttttttt
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 20 40 60 80 100 1200
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0 20 40 60 80 100 1200
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Review: Bezier Curves
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
33
232
231
230 )33()363()133( tvttvtttvtttv
3
2
1
0
3232323 33363133
vvvv
ttttttttt
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 20 40 60 80 100 1200
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0 20 40 60 80 100 1200
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0 20 40 60 80 100 1200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
*v0*v1 *v2 *v3+ + +=
• Cubic curves:
• Hermite curves:
• Bezier curves:
Review: Different basis functions
4
3
2
1
23
0001003303631331
1)(
PPPP
ttttQ
4
1
4
1
23
0001010012331122
1)(
RRPP
ttttQ
)()()()(
1111
11)(
4
3
2
1
1
424
34
323
33
222
32
121
31
2323
tQtQtQtQ
tttttttttttt
ttt
dcba
ttttQ
x
x
x
x
Complex curves
Suppose we want to draw or interpolate a more complex curve
Complex curves
• Suppose we want to draw or interpolate a more complex curve
How can we represent this curve?
Complex curves
• Suppose we want to draw a more complex curve
• Idea: we’ll splice together a curve from individual segments that are cubic Béziers
Complex curves
• Suppose we want to draw or interpolate a more complex curve
• Idea: we’ll splice together a curve from individual segments that are cubic Béziers
Splines
• A piecewise polynomial that has a locally very simple form, yet be globally flexible and smooth
Splines
• There are three nice properties of splines we’d like to have
- Continuity - Local control - Interpolation
Continuity
• C0: points coincide, velocities don’t
• C1: points and velocities coincide
• What’s C2? - points, velocities and accelerations coincide
Continuity
• Cubic curves are continuous and differentiable
• We only need to worry about the derivatives at the endpoints when two curves meet
Local control
• We’d like our spline to have local control - that is, have each control point affect some well-defined
neighborhood around that point
Local control
• We’d like our spline to have local control - that is, have each control point affect some well-defined
neighborhood around that point
Local control
• We’d like our spline to have local control - that is, have each control point affect some well-defined
neighborhood around that point
Interpolation• Bézier curves are approximating - The curve does not (necessarily) pass through
all the control points - Each point pulls the curve toward it, but other
points are pulling as well - the curve is always located within the convex
hull based on control points.
• Instead, we may prefer a spline that is interpolating
- That is, that always passes through every control point
B-splines
• We can join multiple Bezier curves to create B-splines
• Ensure C2 continuity when two curves meet
Derivatives at end points
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
Derivatives at end points
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
3
2
1
0
2
0001003303631331
0123)(
vvvv
tttQ
Derivatives at end points
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
3
2
1
0
2
0001003303631331
0123)(
vvvv
tttQ
3
2
1
0
0001003303631331
0026)(
vvvv
ttQ
Derivatives at end points
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
3
2
1
0
2
0001003303631331
0123)(
vvvv
tttQ
3
2
1
0
2
0001003303631331
0123)(
vvvv
tttQ
Derivatives at end points
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
3
2
1
0
2
0001003303631331
0123)(
vvvv
tttQ
3
2
1
0
0001003303631331
0026)(
vvvv
ttQ
3
2
1
0
2
0001003303631331
010*20*3)0(
vvvv
Q
)(3 01 vv
3
2
1
0
0001003303631331
0020*6)0(
vvvv
Q
)2(6 210 vvv
Derivatives at end points
3
2
1
0
23
0001003303631331
1)(
vvvv
ttttQ
3
2
1
0
2
0001003303631331
0123)(
vvvv
tttQ
3
2
1
0
0001003303631331
0026)(
vvvv
ttQ
)2(6)1(
)2(6)0(
)(3)1(
)(3)0(
123
210
23
01
vvvQ
vvvQ
vvQ
vvQ
Continuity in B splines
• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint
Continuity in B splines
• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint
)0()1( wv QQ
Continuity in B splines
• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint
)0()1(
)0()1(
)0()1(
wv
wv
wv
Continuity in B splines
• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint
)2(6)2(6)(3)(3
210123
1223
03
wwwvvvwwvv
wv
)0()1(
)0()1(
)0()1(
wv
wv
wv
Continuity in B splines
• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint
)2(6)2(6)(3)(3
210123
1223
03
wwwvvvwwvv
wv
Continuity in B splines
• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint
)2(6)2(6)(3)(3
210123
1223
03
wwwvvvwwvv
wv
2312
231
30
442
vvvwvvw
vw
Continuity in B splines
What does this derived equation mean geometrically?
- What is the relationship between a, b and c, if a = 2b - c? b is the middle point of a and c.
w2=v1+4v3-4v2
de Boor points• Instead of specifying the Bezier
control points, let’s specify the corners of the frames that forms a B-spline
• These points are called de Boor points and the frames are called A-frames
de Boor points
• What is the relationship between Bezier control points and de Boor points?
Verify this by yourself!
B spline basis matrix
Building complex splines
• Constraining a Bezier curve made of many segments to be C2 continuous is a lot of work
- for each new segment we have to add 3 new control point - only one of the control points is really free
• B-splines are easier (and C2) - First specify 4 vertices (de Boor points), then one per segment
B splines properties
√ Continuity
√ Local control
x Interpolation
Catmull-Rom splines
• If we are willing to sacrifice C2 continuity, we can get interpolation and local control.
• If we set each derivative to be a constant multiple of the vector between the previous and the next control points, we get a Catmull-Rom spline
Catmull-Rom splines
Catmull-Rom splines
)()1(
)()0(
)1()0(
24
13
3
2
ppQ
ppQ
pQpQ
)( 13 pp
The segment is controlled by p1,p2,p3,p4
)( 24 pp
0.5
Catmull-Rom splines
)()1(
)()0(
)1()0(
24
13
3
2
ppQ
ppQ
pQpQ
)( 13 pp
The segment is controlled by p1,p2,p3,p4
)( 24 pp
Catmull-Rom splines
The effect of t: how sharply the curve bends at the control points
Catmull-Rom splines
)()1(
)()0(
)1()0(
24
13
3
2
ppQ
ppQ
pQpQ
)( 13 pp
)( 24 pp
The segment is controlled by p1,p2,p3,p4
4
3
2
1
000001000010
)1()0()1()0(
pppp
QQQQ
Catmull-Rom splines
)( 13 pp
)( 24 pp
)1()0()1()0(
0001010012331122
1)( 23
QQQQ
ttttQ
From Hermite curves
Catmull-Rom splines
)( 13 pp
)( 24 pp
4
3
2
1
000001000010
)1()0()1()0(
pppp
QQQQ
)1()0()1()0(
0001010012331122
1)( 23
QQQQ
ttttQ
From Hermite curves
Catmull-Rom splines
)( 13 pp
)( 24 pp
4
3
2
1
000001000010
)1()0()1()0(
pppp
QQQQ
)1()0()1()0(
0001010012331122
1)( 23
QQQQ
ttttQ
4
3
2
1
23
000001000010
0001010012331122
1)(
pppp
ttttQ
From Hermite curves
Catmull-Rom splines
)( 13 pp
)( 24 pp
4
3
2
1
23
000001000010
0001010012331122
1)(
pppp
ttttQ
4
3
2
1
23
001000
233222
1
pppp
ttt
Catmull-Rom splines
)( 13 pp
)( 24 pp
4
3
2
1
23
000001000010
0001010012331122
1)(
pppp
ttttQ
4
3
2
1
23
001000
233222
1
pppp
ttt
Catmull-Rom splines
)( 13 pp
)( 24 pp
4
3
2
1
23
000001000010
0001010012331122
1)(
pppp
ttttQ
4
3
2
1
23
001000
233222
1
pppp
ttt
What do we miss?
Catmull-Rom splines
?
?
Catmull-Rom splines
)( 01 pp
)( 34 pp
Catmull-Rom splines
• Catmull-Rom splines have C1 continuity (not C2 continuity)
• Do not lie within the convex hull of their control points.
Catmull-Rom splines
• Catmull-Rom splines have C1 continuity (not C2 continuity)
• Do not lie within the convex hull of their control points.
Catmull-Rom splines properties
X Continuity (C2)
√ Local control
√ Interpolation
Outline• Process of keyframing• Key frame interpolation• Hermite and bezier curve• Splines• Speed control
Speed control
• Time warping function to control speed - positive - monotonic; you cannot reverse the time
s=f(t)
Speed control
• Simplest form is to have constant velocity along the path
s=f(t)
Speed control
• Assume that the motion slows down at the beginning and end of the motion curve
s=f(t)