You are on page 1of 111

Chap 3

Interpolating Values
Animation(U), Chap 3, Interpolating Values 1
2
Outline
Interpolating/approximating curves
Controlling the motion of a point along a curve
Interpolation of orientation
Working with paths

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
3
Interpolation between key frames
Parameters to be interpolated
Position of an object
Normal
Joint angle between two joints
Transparency attribute of an object

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
4
Interpolation between key frames
Interpolation between frames is not trivial
Appropriate interpolating function
Parameterization of the function
Maintain the desired control of the interpolated values
over time
Example
(-5,0,0) at frame 22, (5,0,0) art frame 67
Stop at frame 22 and accelerate to reach a max speed by
frame 34
Start to decelerate at frame 50 and come to a stop at
frame 67
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
5
Interpolation between key frames
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
desired result undesired result
Need a smooth interpolation with user control

Interpolation between key frames
Solution
Generate a space curve
Distribute points evenly along curve
Speed control: vary points temporally
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 6
A
B
C
D
Time = 0
Time = 10
Time = 35
Time = 60
7
Interpolation functions
Interpolation vs. approximation




Interpolation
Hermite, Catmull-Rom
approximation
Bezier, B-spline


Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
8
Interpolation functions
Complexity => computational efficiency
Polynomials
Lower than cubic
No inflection point, may not fit smoothly to some data points
Higher than cubic
Doesnt provide any significant advantages, costly to evaluate
Piecewise cubic
Provides sufficient smoothness
Allows enough flexibility to satisfy constraints such as end-
point position and tangents






Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
9
Interpolation functions
Continuity within a curve
Zero-order
First order (tangential)
Suffices for most animation applications
Second order
Important when dealing with time-distance curve
Continuity between curve segments
Hermite, Catmull-Rom, cubic Bezier provide first
order continuity between segments






Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
10
Interpolation functions
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
CS, NCTU, J. H. Chuang 11
Continuity
none
position
(0th order)
tangent
(1st order)
curvature
(2nd order)
At junction
of two
circular arcs
Animation(U), Chap 3, Interpolating Values
12
Interpolation functions
Global vs. local control






Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
CS, NCTU, J. H. Chuang 13
Types of Curve Representation
Explicit y = f(x)
Good for generate points
For each input, there is a unique output
Implicit f(x,y) = 0
Good for testing if a point is on a curve
Bad for generating a sequence of points
Parametric x = f(u), y = g(u)
Good for generating a sequence of points
Can be used for multi-valued function of x
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 14
Example: Representing Unit Circle
Cannot be represented explicitly as a function
of x

Implicit form:
f(x,y)=x
2
+y
2
=1

Parametric form:
x=cos(u), y=sin(u), 0<u<2














u














f<0
f>0
f=0
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 15
More on 3-D Parametric Curves
Parametric form: P(u) = (P
x
(u), P
y
(u), P
z
(u))
x = P
x
(u), y = P
y
(u), z = P
z
(u)
Space-curve
P = P(u) 0.0 <=u<=1.0
u=1/3
u=2/3
u=0.0
u=1.0
Animation(U), Chap 3, Interpolating Values
Polynomial Interpolation
An n-th degree polynomial fits a curve to n+1
points
Example: fit a second degree curve to three points
y(x)= a x
2
+ b x + c
points to be interpolated
(x
1
, y
1
), (x
2
, y
2
), (x
3
, y
3
)
solve for coefficients (a, b, c):
3 linear equations, 3 unknowns
called Lagrange Interpolation
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 16
Polynomial Interpolation (cont.)
Result is a curve that is too wiggly, change to
any control point affects entire curve
(nonlocal) this method is poor
We usually want the curve to be as smooth as
possible
minimize the wiggles
high-degree polynomials are bad
Higher degree, higher the wiggles
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 17
CS, NCTU, J. H. Chuang 18
Composite Segments
Divide a curve into multiple segments
Represent each in a parametric form
Maintain continuity between segments
position
Tangent (C1-continuity vs. G1-continuity)
curvature
P
1
(u) P
2
(u) P
3
(u)
P
n
(u)
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 19
Splines: Piecewise Polynomials
A spline is a piecewise polynomial - many low
degree polynomials are used to interpolate
(pass through) the control points
Cubic polynomials are the most common
lowest order polynomials that interpolate two
points and allow the gradient at each point to be
defined - C1 continuity is possible
Higher or lower degrees are possible, of course
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 20
A Linear Piecewise Polynomial
The simple form for interpolating two points.
p1
p2
Each segment is of the form: (this is a
vector equation)
u
0 1
1
Two basis (blending) functions
u
2 1 ) 1 ( ) ( p u up u p + =
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 21
Hermite Curvescubic polynomial for two points


Hermite interpolation requires
Endpoint positions
derivatives at endpoints


To create a composite curve, use the end of one as the
beginning of the other and share the tangent vector
Hermite Interpolation
) 0 ( ' P
control points/knots
d cu bu au u P + + + =
2 3
) (
) 0 ( P
) 1 ( ' P
) 1 ( P
)) ( ), ( ), ( ( ) ( u P u P u P u P
z y x
=
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 22
Hermite Curve Formation
Cubic polynomial and its derivative



Given P
x
(0), P
x
(1), P
x
(0), P
x
(1), solve for a, b, c, d
4 equations are given for 4 unknowns


x x x x x
d u c u b u a u P + + + =
2 3
) (
x x x x
c u b u a u P + + = 2 3 ) (
2 '
x x
d P = ) 0 (
x x x x x
d c b a P + + + = ) 1 (
x x
c P = ) 0 (
'
x x x x
c b a P + + = 2 3 ) 1 (
'
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 23
Hermite Curve Formation (cont.)
Problem: solve for a, b, c, d




Solution:
) 0 (
) 0 (
) 1 ( ) 0 ( 2 )) 0 ( ) 1 ( ( 3
) 1 ( ) 0 ( )) 1 ( ) 0 ( ( 2
'
' '
' '
x x
x x
x x x x x
x x x x x
P d
P c
P P P P b
P P P P a
=
=
=
+ + =
x x
d P = ) 0 (
x x x x x
d c b a P + + + = ) 1 (
x x
c P = ) 0 (
'
x x x x
c b a P + + = 2 3 ) 1 (
'
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 24
Hermite Curves in Matrix Form
ith segment in
composite curves
d cu bu au u P + + + =
2 3
) (
MB U u P
T
= ) (
parameter the is ] 1 , , , [
2 3
u u u U
T
=
matrix t coefficien the is M
n informatio geometric the is B
(
(
(
(



=
0 0 0 1
0 1 0 0
1 2 3 3
1 1 2 2
M
(
(
(
(

=
) 1 (
) 0 (
) 1 (
) 0 (
B
'
'
x
x
x
x
P
P
P
P
(
(
(
(

=
+
+
'
1
'
1
B
i
i
i
i
P
P
P
P
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 25
Blending Functions of Hermite Splines
Each cubic Hermite spline is a linear combination of
4 blending functions
geometric information
(
(
(
(

(
(
(
(
(

+
+
+
=
2
1
2
1
2 3
2 3
2 3
2 3
'
'
2
3 2
1 3 2
) (
p
p
p
p
u u
u u u
u u
u u
u p
B M U u P
T
) ( =
Animation(U), Chap 3, Interpolating Values
Composite Hermite Curve
Continuity between connected segments is
ensured by using ending tangent vector of one
segment as the beginning tangent vector of the
next.
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 26
Bezier Curves
Similar to Hermite Curve
Instead of endpoints and tangents, four control
points are given
points P1 and P4 are on the curve
points P2 and P3 are used to control the shape
p
1
= P1, p
2
= P4,
p
1
' = 3(P2-P1), p
2
' = 3(P4 - P3)
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 27
| |
(
(
(
(

(
(
(
(



=
4
3
2
1
0 0 0 1
0 0 3 3
0 3 6 3
1 3 3 1
1 ) (
2 3
P
P
P
P
u u u u p
Bezier Curves
Another representation
Blend the control point position using Bernstein polynomials
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 28
)! ( !
!
) , (
) 1 ( ) , ( ) (
s polynomial Bernstein are ) ( where
) ( ) (
,
,
0
,
k n k
n
k n C
u u k n C u B
u B
P u B u p
k n k
n k
n k
n
k
k n k

=
=
=

CS, NCTU, J. H. Chuang 29


Bezier Curves
Animation(U), Chap 3, Interpolating Values
Composite Bezier Curves
How to control the continuity between
adjacent Bezier segment?
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 30
De Casteljau Construction of Bezier
Curves
How to derive a point on a Bezier curve?
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 31
CS, NCTU, J. H. Chuang 32
Bezier Curves (cont.)
Variant of the Hermite spline
basis matrix derived from the Hermite basis (or
from scratch)
Gives more uniform control knobs (series of
points) than Hermite
Scale factor (3) is chosen to make velocity
approximately constant
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 33
Catmull-Rom Splines
With Hermite splines, the designer must arrange
for consecutive tangents to be collinear, to get C
1

continuity. Similar for Bezier. This gets tedious.

Catmull-Rom: an interpolating cubic spline with
built-in C
1
continuity.

Compared to Hermite/Bezier: fewer control
points required, but less freedom.

Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 34
Catmull-Rom Splines (cont.)
Given n control points in 3-D: p
1
, p
2
, , p
n
,
Tangent at p
i
given by s(p
i+1
p
i-1
) for i=2..n-1, for
some s.
Curve between p
i
and p
i+1
is determined by p
i-1
, p
i
,
p
i+1
, p
i+2.

Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 35
Catmull-Rom Splines (cont.)
Given n control points in 3-D: p
1
, p
2
, , p
n
,
Tangent at p
i
given by s(p
i+1
p
i-1
) for i=2..n-1, for
some s
Curve between p
i
and p
i+1
is determined by p
i-1
, p
i
,
p
i+1
, p
i+2

What about endpoint tangents? (several good
answers: extrapolate, or use extra control points p
0
,
p
n+1
)
Now we have positions and tangents at each knot
a Hermite specification.
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 36
Catmull-Rom Spline Matrix
Derived similarly to Hermite and Bezier
s is the tension parameter; typically s=1/2

(
(
(
(

(
(
(
(



=
=
+
+

2
1
1
0 0 2 0
0 1 0 1
1 4 5 2
1 3 3 1
) (
, 2 / 1 When
i
i
i
i
T
P
P
P
P
U u p
s
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 37
Catmull-Rom Spline
What about endpoint tangents?
Provided by users
Several good answers: extrapolate, or use extra
control points p
0
, p
n+1


Animation(U), Chap 3, Interpolating Values
) 2 (
2
1

) )) ( ((
2
1
0 2 1
0 1 2 1
'
0
P P P
P P P P P
=
=
CS, NCTU, J. H. Chuang 38
Catmull-Rom Spline
Example
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 39
Catmull-Rom Spline
Drawback
An internal tangent is not dependent on the
position of the internal point relative to its two
neighbors
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 41
Splines and Other Interpolation Forms
See Computer Graphics textbooks
Review
Appendix B.4 in Parent

Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 42
Now What?
We have key frames or points
We have a way to specify the space curve
Now we need to specify velocity to traverse
the curve


Speed Curves
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 43
Speed Control
The speed of tracing a curve needs to be under the
direct control of the animator
Varying u at a constant rate will not necessarily
generate P(u) at a constant speed.

Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 44
Generally, equally spaced samples in
parameter space are not equally spaced along
the curve
Non-uniformity in Parametrization
A
B
C
D
Time = 0
Time = 10
Time = 35
Time = 60
) ( ) (
1 2 1 2
u s u s u u =
}
+ + = du u P u P u P u s
z y x
2 2 2
) ( ) ( ) ( ) (
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 45
Arc Length Reparameterization
To ensure a constant speed for the interpolated
value, the curve has to be parameterized by arc
length (for most applications)
Computing arc length
Analytic method (many curves do not have, e.g., B-
splines)
Numeric methods
Table and differencing
Gaussian quadrature
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 46
Arc Length Reparameterization
Space curve vs. time-distance function
Relates time to the distance traveled along the
curve, i.e.,
Relates time to the arc length along the curve


Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 47
Arc Length Reparameterization
Given a space curve with arc length
parameterization
Allow movement along the curve at a constant speed by
stepping at equal arc length intervals
Allows acceleration and deceleration along the curve by
controlling the distance traveled in a given time interval
Problems
Given a parametric curve and two parameter values u
1
and
u
2
, find arclength(u
1
,u
2
)
Given an arc length s, and parameter value u
1
, find u
2
such
that arclength(u
1
,u
2
) = s






Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 48
Arc Length Reparameterization
Converting a space curve P(u) to a curve with
arc-length parameterization
Find s=S(u), and u=S
-1
(s)=U(s)
P*(s)=P(U(s))
Analytic arc-length parameterization is
difficult or impossible for most curves, e.g., B-
spline curve cannot be parameterized with arc
length.
Approximate arc-length parameterization





Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 49
Forward Differencing
Sample the curve at small intervals of the parameter
Compute the distance between samples
Build a table of arc length for the curve
u Arc Length
0.0 0.00
0.1 0.08
0.2 0.19
0.3 0.32
0.4 0.45

Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 50
Arc Length Reparameterization Using
Forward Differencing
Given a parameter u, find the arc length
Find the entry in the table closest to this u
Or take the u before and after it and interpolate arc
length linearly
u Arc Length
0.0 0.00
0.1 0.08
0.2 0.19
0.3 0.32
0.4 0.45

Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 51
Arc Length Reparameterization Using
Forward Differencing
Given an arc length s and a parameter u
1
, find
the parametric value u
2
such that
arclength(u
1
, u
2
)=s
Find the entry in the table
closest to this u using
binary search
Or take the u before and after
it and interpolate linearly
u Arc Length
0.0 0.00
0.1 0.08
0.2 0.19
0.3 0.32
0.4 0.45

Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 52
Arc Length Reparameterization Using
Forward Differencing
Easy to implement, intuitive, and fast
Introduce errors
Super-sampling in forming table
1000 equally spaced parameter values + 1000 ebtries in
each interval
Better interpolation
Adaptive forward differencing
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 53
Arc Length Reparameterization Using
Adaptive forward differencing
Animation(U), Chap 3, Interpolating Values
Arc Length Reparameterization Using
Numerical Integral
Arc length integral


Simpsons and trapezoidal integration using evenly
spaced intervals
Gaussian quadrature using unevenly spaced
intervals
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 54
}
+ + = du u P u P u P u s
z y x
2 2 2
) ( ) ( ) ( ) (
Speed Control
Given a arc-length parameterized space curve,
how to control the speed at which the curve is
traced?
By a speed-control functions that relate an equally
spaced time interval to arc length
Input time t, output arc length: s=S(t)
Linear function: constant speed control
Most common: ease-in/ease-out
Smooth motion from stopped position, accelerate, reach a max
velocity, and then decelerate to a stop position

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 55
Speed Control Function
Relates an equally spaced time interval to arc
length
Input time t, output arc length: s=S(t)
Normalized arc length parameter

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 56
s=ease(t)

Start at 0,
slowly increase
in value and gain
speed until the
middle value and
then decelerate as
it approaches to 1.
CS, NCTU, J. H. Chuang 57
Constant Velocity Speed Curve






Moving at 1 m/s if meters and seconds are the units
Too simple to be what we want
Animation(U), Chap 3, Interpolating Values
Distance Time Function
and Speed Control
We have a space curve p=P(u) and a
speed control function s=S(t).
For a given t, s=S(t)
Find the corresponding value u=U(s) by looking
up an arc length table for a given s
A point on the space curve with parameter u
p=P(U(S(t)))

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 58
CS, NCTU, J. H. Chuang 59
Speed Control
u Arc Length
0.0 0.00
0.1 0.08
0.2 0.19
0.3 0.32
0.4 0.45

t*
s*
u*
) (
*
u P
Speed Control Curve
Arc Length Table
Animation(U), Chap 3, Interpolating Values
Distance Time Function
Assumptions on distance time function
The entire arc length of the curve is to be traversed
during the given total time
Additional optional assumptions
The function should be monotonic in t
The function should be continuous

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 60
CS, NCTU, J. H. Chuang 61
Ease-in/Ease-out
Most useful and most common ways to control
motion along a curve
(distance)
Time
Arc length
Equally spaced samples in time specify arc length required for that frame
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 62
Ease-in/Ease-out
Sine Interpolation
-1
1
t/2
t/2
Time
Arc Length
2 2
), sin(
t
o
t
o s s
1 0 ,
2
1
)
2
( sin
2
1
) ( ease s s + = = t t t s
t
t
Animation(U), Chap 3, Interpolating Values
Ease-in/Ease-out
Sine Interpolation
The speed of s w.r.t. t is never constant over an
interval but rather is always accelerating or
decelerating.

Zero derivatives at t=0 and t=1 indicating
smooth accelerating and deceleration at end
points.

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 63
CS, NCTU, J. H. Chuang 64
Ease-in/Ease-out
Piecing Curves Together for Ease In/Out
Time
Linear segment
Arc Length
Sinusoidal segments
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 65
Ease-in/Ease-out
Piecing Curves Together for Ease In/Out
Animation(U), Chap 3, Interpolating Values
CS, NCTU, J. H. Chuang 66
Ease-in/Ease-out
Integrating to avoid the sine function
acceleration
time
t
1
t
2
A
D
velocity
time
t
1
t
2
v
arc length
time
V
1
= V
2
A*t
1
= - D*(1-t
2
)
Find v such that area = 1
Animation(U), Chap 3, Interpolating Values
Ease-in/Ease-out
Integrating to avoid the sine function
To avoid the transcendental function
evaluation while providing a constant speed
interval between ease-in and ease-out intervals
Acceleration-time curve
Velocity-time curve
Velocity-time curve is defined by integral of the
acceleration-time curve
Distance-time curve is defined by integral of the
velocity-time curve
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 67
Ease-in/Ease-out
Integrating to avoid the sine function
In ease-in/ease-out function
Velocity starts out at 0 and ends at 0
V
1
= V
2
inplies A*t
1
= - D*(1-t
2
)


Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 68
Ease-in/Ease-out
Integrating to avoid the sine function
Total distance = 1 implies
1 = V
0
t + V
0
(t
2
-t
1
)+1/2 V
0
(1-t
2
)
Users specifies any two of three variables t
1
, t
2
, and V
0
,
and the system can solve for the third


Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 69
Ease-in/Ease-out
Integrating to avoid the sine function
The result is Parabolic ease-in/ease-out
More flexible than the sinusoidal ease-in/ease-out

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 70
CS, NCTU, J. H. Chuang 71
Videos
Bunny (Blue Sky Studios, 1998)
Animation(U), Chap 3, Interpolating Values
Review - Quaternions
Similar to axis-angle representations
4-tuple of real numbers
q=(s, x, y, z) or [s, v]s is a scalar; v is a vector
The quaternion for rotating an angle about an
axis (an axis-angle rotation):

Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang 72
u
X
Y
Z
a=(a
x
, a
y
, a
z
)
If a is unit length, then q will be also
(

=
=
) , , ( )
2
sin( ),
2
cos(
)) , , ( , ( Rot
z y x
z y x
a a a
a a a q
u u
u
Review - Quaternions
Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang 73
If a is unit length, then q will be also
( )
1 1
2
sin
2
cos
2
sin
2
cos
2
sin
2
cos
2
sin
2
sin
2
sin
2
cos
2 2
2
2 2
2 2 2 2 2
2 2 2 2 2 2 2
2
3
2
2
2
1
2
0
= =
+ = + =
+ + + =
+ + + =
+ + + =
u u u u
u u
u u u u
a
q
z y x
z y x
a a a
a a a
q q q q
Review - Quaternions
Rotating some angle around an axis is the same as
rotating the negative angle around the negated axis

Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang 74
q z y x
z y x
=
(

=

) , , )(
2
sin( ),
2
cos( Rot
) , , ( ,
u u
u
75
Review - Quaternion Math
Addition


Multiplication


Multiplication is associative but not commutative

Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
| | | | | |
2 1 2 1 2 2 1 1
, , , v v s s v s v s + + = +
| || | | |
2 1 1 2 2 1 2 1 2 1 2 2 1 1
, , , v v v s v s v v s s v s v s + + =
1 2 2 1
q q q q =
3 2 1 3 2 1
) ( ) ( q q q q q q =
76
Review - Quaternion Math (cont.)
Multiplicative identity: [1, 0,0,0]

Inverse

Normalization for unit quaternion


2 2 2 2
z y x s q + + + =
| | 0 , 0 , 0 , 1
1
=

qq
Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
q
q
q =

2 2 2 2
z y x s q + + + =
| | q q = 0 , 0 , 0 , 1
| |
2
1
,
q
v s
q

=

| | 0 , 0 , 0 , 1
1
=

qq
q
q
q =

77
Review
Rotating Vectors Using Quaternion
A point in space, v, is represented as [0, v]
To rotate a vector v using quaternion q
Represent the vector as v = [0, v]
Represent the rotation as a quaternion q
Using quaternion multiplication


The proof isnt that hard
Note that the result v always has zero scalar value






Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
1
) ( '

= = qvq v Rot v
q
Review - Compose Rotations
Rotating a vector v by first quaternion p
followed by a quaternion q is like rotation
using qp

Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang 78
) (
) ( ) (
) ( )) ( (
1
1 1
1
v Rot
qp v qp
q qpvp
pvp Rot v Rot Rot
qp
q p q
=
=
=
=

Review - Compose Rotations


To rotate a vector v by quaternion q followed
by its inverse quaternion q
-1


Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang 79
v
q qvq q
qvq Rot v Rot Rot
q
q
q
=
=
=


1 1
1
) ( )) ( (
1 1
80
Review - Quaternion Interpolation
A quaternion is a point on a 4D unit sphere
Unit quaternion: q=(s,x,y,z), ||q|| = 1
Form a subspace: a 4D sphere
Interpolating quaternion means moving between two
points on the 4D unit sphere
A unit quaternion at each step another point
on the 4D unit sphere
Move with constant angular velocity
along the greatest circle between the
two points on the 4D unit sphere


Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
81
Review - Linear Interpolation
Linear interpolation generates unequal spacing
of points after projecting to circle

Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
82
Want equal increment along arc connecting two
quaternion on the spherical surface
Spherical linear interpolation (slerp)






Normalize to regain unit quaternion
Review
Spherical Linear Interpolation (slerp)
Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
) ( cos and 1 to 0 from goes where
sin
) sin(
sin
) ) 1 sin((
) , , (
2 1
1
2 1 2 1
q q u
q
u
q
u
u q q slerp
=
+

u
u
u
u
u
83
Review
Spherical Linear Interpolation (slerp)
Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
2 1 2 1
1
2 1
2 1
sin
) sin(
sin
) ) 1 sin((
) , , (
give to
,
, 1
: given for solve can We
Let
q
u
q
u
u q q slerp
u q q
q q
q
q q q
u
u
u
u
u
u
| o
+

=
=
=
=
+ =
84
Review
Spherical Linear Interpolation (slerp)
2
q
1
q
2
q
0
2 1
> q q
Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
85
Review
Spherical Linear Interpolation (slerp)
Recall that q and q represent same rotation
What is the difference between:
Slerp(u, q
1
, q
2
) and Slerp(u, q
1
, -q
2
) ?
One of these will travel less than 90 degrees while
the other will travel more than 90 degrees across
the sphere
This corresponds to rotating the short way or the
long way
Usually, we want to take the short way, so we
negate one of them if their dot product is < 0

Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
86
Review
Spherical Linear Interpolation (slerp)
Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang
If we have an intermediate position q2, the
interpolation from q
1
-->q
2
-->q
3
will not
necessarily follow the same path as the
interpolation from q
1
to q
3
.
87
Interpolating a Series of Quaternions
As linear interpolation in Euclidean space, we
can have first order discontinuity problem
when interpolating a series of orientations.


Need a cubic curve interpolation to maintain first order
continuity in Euclidean space
Similarly, slerp can have 1st order discontinuity
We also need a cubic curve interpolation in 4D
spherical space for 1st order continuity

Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
Interpolating a Series of Quaternions
Interpolated points [, p
n-1
, p
n
, p
n+1
, .] in 3D
Between each pair of points, two control
points will be constructed. e.g., For p
n

a
n
: the one intermediate after p
n
b
n
: the one immediately before p
n



Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 88
p
n
+(p
n
-p
n-1
)
Take average
Interpolating a Series of Quaternions
Interpolated points [, p
n-1
, p
n
, p
n+1
, .] in 3D
Between each pair of points, two control
points will be constructed. e.g., For p
n

a
n
: the one intermediate after p
n
b
n
: the one immediately before p
n



Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 89
b
n =
p
n
+(p
n
-a
n
)
Interpolating a Series of Quaternions
Interpolated points [, p
n-1
, p
n
, p
n+1
, .] in 3D
End conditions




Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 90
Interpolating a Series of Quaternions
Interpolated points [, p
n-1
, p
n
, p
n+1
, .] in 3D
Between any 2 interpolated points p
n
and p
n+1
,
a cubic Bezier curve segment is defined by p
n
,
a
n
, b
n+1
, and p
n+1





Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 91
Interpolating a Series of Quaternions
How to evaluate a point on Bezier curve?
De Casteljau Construction
Constructing Bezier curve by multiple linear
interpolation
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 92
u=1/3
p(1/3)
Interpolating a Series of Quaternions
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 93
Animation: See
http://en.wikipedia.org/wiki/File:Bezier_3_big.gif
Interpolating a Series of Quaternions
Bezier interpolation on 4D sphere?
How are control points generated?
How are cubic Beziers defined?

Control points are automatically generated as it
is not intuitive to manually adjust them on a 4D
sphere

Derive Bezier curve points by iteratively
subdivision s on p
n
, a
n
, b
n+1
, and p
n+1


Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 94
95
1
1
1
'
'
) , ' ( sec
+
+
+
+
+
=
n n
n n
n n
q q
q q
q q t Bi
Interpolating a Series of Quaternions
Connecting Segments on 4D Sphere
Automatically generating interior (spherical)
control points
q
n-1
q
n
q
n+1
q
n


a
n
1. Double the arc
2. Bisect the span
1 1 1
'
) ( 2 ) , (

= =
n n n n n n n
q q q q q q double q
b
n
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
) , (
n n n
q a double b =
96
1 + n
q
n
q
Interpolating a Series of Quaternions
De Casteljau Construction on 4D Sphere

p
1
= slerp(q
n
, a
n
,
1
3
)
p
2
= slerp(a
n
,b
n+1
,
1
3
)
p
3
= slerp(b
n+1
,q
n+1
,
1
3
)
p
12
= slerp( p
1
, p
2
,
1
3
)
p
23
= slerp( p
2
, p
3
,
1
3
)
p = slerp( p
12
, p
23
,
1
3
)
u=1/3
P(1/3)
n
a
1 + n
b
1
p
2
p
3
p
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang
Path Following
Issues about path following
Arc length parameterization and speed control
Changing the orientation
Smoothing a path
Path along a surface
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 97
Orientation Along a Curve
A local coordinate system (u, v, w) is defined
for an object to be animated
Position along the path P(s), denoted as POS
w-axis: the direction the object is facing
v-axis: up vector
u-axis: perpendicular to w and v
(u, v, w): a right-handed coordinate system
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 98
Orientation Along a Curve
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 99
Orientation Along a Curve
Frenet Frame
Frenet frame: a moving coordinate system
determined by curve tangent and curvature
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 100
w u v
s P s P u
s P w
=
=
=
) ( ' ) ( "
) ( '
Orientation Along a Curve
Frenet Frame
Problems
No concept of up vector
Is undefined in segments that has no curvature;
i.e., P(u)=0
Can be dealt with by interpolating a Frenet frame from
the Frenet frames at segments boundary, which differ
by only a rotation around w
A discontinuity in the curvature vector
Frenet frame has a discontinuous jump in orientation
Resulting motions are usually too extreme and not
natural looking
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 101
Orientation Along a Curve
Frenet Frame
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 102
Orientation Along a Curve
Frenet Frame
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 103
Orientation Along a Curve
Camera Path Following
COI: center of interest
A fixed point in the scene
Center point of an object in the scene
Points along the path itself
Points on a separate path in the scene
Points on the interpolation between points in the
scene
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 104
w u v
w u
w
=
=
=
y_axis
POS COI
w u v
w u
s P s C w
=
=
=
y_axis
) ( ) (
w u v
s P s U w u
s P s C w
=
=
=
)) ( ) ( (
) ( ) (
Smoothing a Path
with Linear Interpolation
Two points on either sides of a point are
averaged, and this point is averaged with the
original point.
Repeated application
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 105
1 1
1 1
4
1
2
1
4
1
2
2
'
+
+
+ + =
+
+
=
i i i
i i
i
i
P P P
P P
P
P
Smoothing a Path
with Linear Interpolation
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 106
Smoothing a Path
with Cubic Interpolation
Four points on either sides of a point are fitted
by a cubic curve, and the midpoint of the curve
is averaged with the original point.
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 107
d c b a P P
d c b a P P
d c b a P P
d P P
d cu bu au u P
i
i
i
i
+ + + = =
+ + + = =
+ + + = =
= =
+ + + =
+
+

) 1 (
4
3
16
9
64
27
) 4 / 3 (
4
1
16
1
64
1
) 4 / 1 (
) 0 (
) (
2
1
1
2
2 3
Smoothing a Path
with Cubic Interpolation
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 108
Smoothing a Path
with Cubic Interpolation
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 109
Determine a Path on a Surface
If one object is to move across the surface of
another object, we need to specify a path
across the surface.
Given start and destination points
Find a shortest path between the points expensive
Determine a plane that contain two points and is
generally perpendicular to the surface (averaged normal
of two points)
Intersection of the plane with the surface (mesh)
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 110
Determine a Path on a Surface
Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 111
Determine a Path on a Parametric
Surface
Given start and destination points on parametric
domain
Define the straight line connecting two points in the
parametric space
The curve on the surface corresponding to this line


Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang 112

You might also like