cs 445 / 645 introduction to computer graphics lecture 22 hermite splines lecture 22 hermite splines
TRANSCRIPT
CS 445 / 645Introduction to Computer Graphics
Lecture 22Lecture 22
Hermite SplinesHermite Splines
Lecture 22Lecture 22
Hermite SplinesHermite Splines
ACM Elections
Should take 15 minutesShould take 15 minutes
Taking place now in OLS 120Taking place now in OLS 120
Hurry BackHurry Back
I’m showing movies that you can watch after class I’m showing movies that you can watch after class today (or some other day)today (or some other day)
Should take 15 minutesShould take 15 minutes
Taking place now in OLS 120Taking place now in OLS 120
Hurry BackHurry Back
I’m showing movies that you can watch after class I’m showing movies that you can watch after class today (or some other day)today (or some other day)
Splines – Old School
Representations of Curves
Problems with series of points used to model a Problems with series of points used to model a curvecurve• Piecewise linear - Does not accurately model a smooth linePiecewise linear - Does not accurately model a smooth line
• It’s tediousIt’s tedious
• Expensive to manipulate curve because all points must be Expensive to manipulate curve because all points must be repositionedrepositioned
Instead, model curve as piecewise-polynomialInstead, model curve as piecewise-polynomial• x = x(t), y = y(t), z = z(t) x = x(t), y = y(t), z = z(t)
– where x(), y(), z() are polynomials where x(), y(), z() are polynomials
Problems with series of points used to model a Problems with series of points used to model a curvecurve• Piecewise linear - Does not accurately model a smooth linePiecewise linear - Does not accurately model a smooth line
• It’s tediousIt’s tedious
• Expensive to manipulate curve because all points must be Expensive to manipulate curve because all points must be repositionedrepositioned
Instead, model curve as piecewise-polynomialInstead, model curve as piecewise-polynomial• x = x(t), y = y(t), z = z(t) x = x(t), y = y(t), z = z(t)
– where x(), y(), z() are polynomials where x(), y(), z() are polynomials
Specifying Curves (hyperlink)
Control PointsControl Points• A set of points that influence the A set of points that influence the
curve’s shapecurve’s shape
KnotsKnots• Control points that lie on the curveControl points that lie on the curve
Interpolating SplinesInterpolating Splines• Curves that pass through the control Curves that pass through the control
points (knots)points (knots)
Approximating SplinesApproximating Splines• Control points merely influence shapeControl points merely influence shape
Control PointsControl Points• A set of points that influence the A set of points that influence the
curve’s shapecurve’s shape
KnotsKnots• Control points that lie on the curveControl points that lie on the curve
Interpolating SplinesInterpolating Splines• Curves that pass through the control Curves that pass through the control
points (knots)points (knots)
Approximating SplinesApproximating Splines• Control points merely influence shapeControl points merely influence shape
Parametric Curves
Very flexible representationVery flexible representation
They are not required to be functionsThey are not required to be functions
• They can be multivalued with respect to any dimensionThey can be multivalued with respect to any dimension
Very flexible representationVery flexible representation
They are not required to be functionsThey are not required to be functions
• They can be multivalued with respect to any dimensionThey can be multivalued with respect to any dimension
Cubic Polynomials
x(t) = ax(t) = axxtt33 + b + bxxtt22 + c + cxxt + dt + dxx
• Similarly for y(t) and z(t)Similarly for y(t) and z(t)
Let t: (0 <= t <= 1)Let t: (0 <= t <= 1)
Let T = [tLet T = [t33 t t22 t 1] t 1]
Coefficient Matrix CCoefficient Matrix C
Curve: Q(t) = T*CCurve: Q(t) = T*C
x(t) = ax(t) = axxtt33 + b + bxxtt22 + c + cxxt + dt + dxx
• Similarly for y(t) and z(t)Similarly for y(t) and z(t)
Let t: (0 <= t <= 1)Let t: (0 <= t <= 1)
Let T = [tLet T = [t33 t t22 t 1] t 1]
Coefficient Matrix CCoefficient Matrix C
Curve: Q(t) = T*CCurve: Q(t) = T*C
z
z
y
y
x
x
zyx
zyx
d
c
d
c
d
c
bbb
aaa
ttt 123
Parametric Curves
How do we find the tangent to a curve?How do we find the tangent to a curve?
• If f(x) = xIf f(x) = x22 – 4 – 4
– tangent at (x=3) is f’(x) = 2 (x) – 4 = 2 (3) - 4tangent at (x=3) is f’(x) = 2 (x) – 4 = 2 (3) - 4
How do we find the tangent to a curve?How do we find the tangent to a curve?
• If f(x) = xIf f(x) = x22 – 4 – 4
– tangent at (x=3) is f’(x) = 2 (x) – 4 = 2 (3) - 4tangent at (x=3) is f’(x) = 2 (x) – 4 = 2 (3) - 4
Derivative of Q(t) is the tangent vector at t:Derivative of Q(t) is the tangent vector at t:
• d/dt Q(t) = Q’(t) = d/dt T * C = [3td/dt Q(t) = Q’(t) = d/dt T * C = [3t22 2t 1 0] * C 2t 1 0] * C
Derivative of Q(t) is the tangent vector at t:Derivative of Q(t) is the tangent vector at t:
• d/dt Q(t) = Q’(t) = d/dt T * C = [3td/dt Q(t) = Q’(t) = d/dt T * C = [3t22 2t 1 0] * C 2t 1 0] * C
Piecewise Curve Segments
One curve constructed by connecting many smaller One curve constructed by connecting many smaller segments end-to-endsegments end-to-end
Continuity describes the jointContinuity describes the joint
• CC11 is tangent continuity (velocity) is tangent continuity (velocity)
• CC22 is 2 is 2ndnd derivative continuity (acceleration) derivative continuity (acceleration)
One curve constructed by connecting many smaller One curve constructed by connecting many smaller segments end-to-endsegments end-to-end
Continuity describes the jointContinuity describes the joint
• CC11 is tangent continuity (velocity) is tangent continuity (velocity)
• CC22 is 2 is 2ndnd derivative continuity (acceleration) derivative continuity (acceleration)
Continuity of Curves
If direction (but not necessarily magnitude) of tangent If direction (but not necessarily magnitude) of tangent matchesmatches• GG11 geometric continuity geometric continuity
• The tangent value at the end of one curve is proportional to the The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curvetangent value of the beginning of the next curve
Matching direction and magnitude of dMatching direction and magnitude of dnn / dt / dtnn
– CCnn continous continous
If direction (but not necessarily magnitude) of tangent If direction (but not necessarily magnitude) of tangent matchesmatches• GG11 geometric continuity geometric continuity
• The tangent value at the end of one curve is proportional to the The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curvetangent value of the beginning of the next curve
Matching direction and magnitude of dMatching direction and magnitude of dnn / dt / dtnn
– CCnn continous continous
Parametric Cubic Curves
In order to assure CIn order to assure C22 continuity, curves must be of continuity, curves must be of
at least degree 3at least degree 3
Here is the parametric definition of a cubic Here is the parametric definition of a cubic (degree 3) spline in two dimensions(degree 3) spline in two dimensions
How do we extend it to three dimensions?How do we extend it to three dimensions?
In order to assure CIn order to assure C22 continuity, curves must be of continuity, curves must be of
at least degree 3at least degree 3
Here is the parametric definition of a cubic Here is the parametric definition of a cubic (degree 3) spline in two dimensions(degree 3) spline in two dimensions
How do we extend it to three dimensions?How do we extend it to three dimensions?
Parametric Cubic Splines
Can represent this as a matrix tooCan represent this as a matrix tooCan represent this as a matrix tooCan represent this as a matrix too
Coefficients
So how do we select the coefficients?So how do we select the coefficients?
• [a[axx b bxx c cxx d dxx] and [a] and [ayy b byy c cyy d dyy] must satisfy the constraints ] must satisfy the constraints
defined by the knots and the continuity conditionsdefined by the knots and the continuity conditions
So how do we select the coefficients?So how do we select the coefficients?
• [a[axx b bxx c cxx d dxx] and [a] and [ayy b byy c cyy d dyy] must satisfy the constraints ] must satisfy the constraints
defined by the knots and the continuity conditionsdefined by the knots and the continuity conditions
Parametric Curves
Difficult to conceptualize curve as Difficult to conceptualize curve as x(t) = ax(t) = axxtt33 + b + bxxtt22 + c + cxxt + dt + dxx
(artists don’t think in terms of coefficients of cubics)(artists don’t think in terms of coefficients of cubics)
Instead, define curve as weighted combination of 4 well-Instead, define curve as weighted combination of 4 well-defined cubic polynomialsdefined cubic polynomials(wait a second! Artists don’t think this way either!)(wait a second! Artists don’t think this way either!)
Each curve type defines different cubic polynomials and Each curve type defines different cubic polynomials and weighting schemesweighting schemes
Difficult to conceptualize curve as Difficult to conceptualize curve as x(t) = ax(t) = axxtt33 + b + bxxtt22 + c + cxxt + dt + dxx
(artists don’t think in terms of coefficients of cubics)(artists don’t think in terms of coefficients of cubics)
Instead, define curve as weighted combination of 4 well-Instead, define curve as weighted combination of 4 well-defined cubic polynomialsdefined cubic polynomials(wait a second! Artists don’t think this way either!)(wait a second! Artists don’t think this way either!)
Each curve type defines different cubic polynomials and Each curve type defines different cubic polynomials and weighting schemesweighting schemes
Parametric Curves
HermiteHermite – two endpoints and two endpoint – two endpoints and two endpoint tangent vectorstangent vectors
BezierBezier - two endpoints and two other points that - two endpoints and two other points that define the endpoint tangent vectorsdefine the endpoint tangent vectors
SplinesSplines – four control points – four control points • C1 and C2 continuity at the join pointsC1 and C2 continuity at the join points
• Come close to their control points, but not guaranteed to Come close to their control points, but not guaranteed to touch themtouch them
Examples of SplinesExamples of Splines
HermiteHermite – two endpoints and two endpoint – two endpoints and two endpoint tangent vectorstangent vectors
BezierBezier - two endpoints and two other points that - two endpoints and two other points that define the endpoint tangent vectorsdefine the endpoint tangent vectors
SplinesSplines – four control points – four control points • C1 and C2 continuity at the join pointsC1 and C2 continuity at the join points
• Come close to their control points, but not guaranteed to Come close to their control points, but not guaranteed to touch themtouch them
Examples of SplinesExamples of Splines
Hermite Cubic Splines
An example of knot and continuity constraintsAn example of knot and continuity constraintsAn example of knot and continuity constraintsAn example of knot and continuity constraints
Hermite Cubic Splines
One cubic curve for each dimensionOne cubic curve for each dimension
A curve constrained to x/y-plane has two curves:A curve constrained to x/y-plane has two curves:
One cubic curve for each dimensionOne cubic curve for each dimension
A curve constrained to x/y-plane has two curves:A curve constrained to x/y-plane has two curves:
d
c
b
a
ttt
dctbtattf x
1
)(
23
23
h
g
f
e
ttt
hgtftettf y
1
)(
23
23
Hermite Cubic Splines
A 2-D Hermite Cubic Spline is defined by eight A 2-D Hermite Cubic Spline is defined by eight parameters: a, b, c, d, e, f, g, hparameters: a, b, c, d, e, f, g, h
How do we convert the intuitive endpoint constraints into How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters?these (relatively) unintuitive eight parameters?
We know:We know:• (x, y) position at t = 0, p(x, y) position at t = 0, p11
• (x, y) position at t = 1, p(x, y) position at t = 1, p22
• (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt
• (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt
A 2-D Hermite Cubic Spline is defined by eight A 2-D Hermite Cubic Spline is defined by eight parameters: a, b, c, d, e, f, g, hparameters: a, b, c, d, e, f, g, h
How do we convert the intuitive endpoint constraints into How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters?these (relatively) unintuitive eight parameters?
We know:We know:• (x, y) position at t = 0, p(x, y) position at t = 0, p11
• (x, y) position at t = 1, p(x, y) position at t = 1, p22
• (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt
• (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt
Hermite Cubic Spline
We know:We know:
• (x, y) position at t = 0, p(x, y) position at t = 0, p11
We know:We know:
• (x, y) position at t = 0, p(x, y) position at t = 0, p11
xpdf
d
c
b
adcbaf
x
x
1
23
23
)0(
1000
000)0(
yphf
h
g
f
ehgfef
y
y
1
23
23
)0(
1000
000)0(
Hermite Cubic Spline
We know:We know:
• (x, y) position at t = 1, p(x, y) position at t = 1, p22
We know:We know:
• (x, y) position at t = 1, p(x, y) position at t = 1, p22
xpdcbaf
d
c
b
adcbaf
x
x
2
23
23
)1(
1111
111)1(
yphgfef
h
g
f
ehgfef
y
y
2
23
23
)1(
1111
111)1(
Hermite Cubic Splines
So far we have four equations, but we have eight So far we have four equations, but we have eight unknownsunknowns
Use the derivativesUse the derivatives
So far we have four equations, but we have eight So far we have four equations, but we have eight unknownsunknowns
Use the derivativesUse the derivatives
d
c
b
a
tttf
cbtattf
dctbtattf
x
x
x
0123)(
23)(
)(
2
2
23
h
g
f
e
tttf
gftettf
hgtftettf
y
y
y
0123)(
23)(
)(
2
2
23
Hermite Cubic Spline
We know:We know:
• (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt
We know:We know:
• (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt
dtdp
cf
d
c
b
acbaf
xx
x
1
2
2
)0(
010203
0203)0(
dtdp
gf
h
g
f
egfef
y
y
y
1
2
2
)0(
010203
0203)0(
Hermite Cubic Spline
We know:We know:
• (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt
We know:We know:
• (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt
dtdp
cbaf
d
c
b
acbaf
xx
x
1
2
2
23)1(
011213
1213)1(
dtdp
gfef
h
g
f
egfef
y
y
y
1
2
2
23)1(
011213
1213)1(
Hermite Specification
Matrix equation for Hermite CurveMatrix equation for Hermite CurveMatrix equation for Hermite CurveMatrix equation for Hermite Curve
t = 0
t = 1
t = 0
t = 1
t3 t2 t1 t0
p1
p2
r p1
r p2
dtdp
dtdp
p
p
dtdp
dtdpp
p
h
g
f
e
d
c
b
a
y
y
y
y
x
x
x
x
2
1
2
1
1
1
2
1
0123
0100
1111
1000
Solve Hermite Matrix
h
g
f
e
d
c
b
a
dtdp
dtdp
p
p
dtdp
dtdpp
p
y
y
y
y
x
x
x
x
2
1
2
1
1
1
2
11
0123
0100
1111
1000
Spline and Geometry Matrices
h
g
f
e
d
c
b
a
dtdp
dtdp
p
p
dtdp
dtdpp
p
y
y
y
y
x
x
x
x
2
1
2
1
1
1
2
1
0001
0100
1233
1122
MHermite GHermite
Resulting Hermite Spline Equation
Demonstration
HermiteHermite
Sample Hermite Curves
Blending Functions
By multiplying first two matrices in lower-left By multiplying first two matrices in lower-left equation, you have four functions of ‘t’ that equation, you have four functions of ‘t’ that blend the four control parametersblend the four control parameters
These are blendingThese are blendingfunctionsfunctions
By multiplying first two matrices in lower-left By multiplying first two matrices in lower-left equation, you have four functions of ‘t’ that equation, you have four functions of ‘t’ that blend the four control parametersblend the four control parameters
These are blendingThese are blendingfunctionsfunctions
Hermite Blending Functions
If you plot the If you plot the blending blending functions on functions on the parameter the parameter ‘t’‘t’
If you plot the If you plot the blending blending functions on functions on the parameter the parameter ‘t’‘t’
Hermite Blending Functions
Remember, eachRemember, eachblending functionblending functionreflects influencereflects influenceof Pof P11, P, P22, , PP11, , PP22
on spline’s shapeon spline’s shape
Remember, eachRemember, eachblending functionblending functionreflects influencereflects influenceof Pof P11, P, P22, , PP11, , PP22
on spline’s shapeon spline’s shape