March 1, 2009Dr. Muhammed Al-Mulhem1 ICS 415 Computer Graphics Hermite Splines Dr. Muhammed...
-
Upload
braxton-pridmore -
Category
Documents
-
view
224 -
download
0
Transcript of March 1, 2009Dr. Muhammed Al-Mulhem1 ICS 415 Computer Graphics Hermite Splines Dr. Muhammed...
March 1, 2009 Dr. Muhammed Al-Mulhem 1
ICS 415Computer Graphics
Hermite Splines
Dr. Muhammed Al-MulhemDr. Muhammed Al-Mulhem
March 1, 2009March 1, 2009
Dr. Muhammed Al-MulhemDr. Muhammed Al-Mulhem
March 1, 2009March 1, 2009
March 1, 2009 Dr. Muhammed Al-Mulhem 2
Spline
• A spline is a a flexible strip used to produce a A spline is a a flexible strip used to produce a smooth curve through a set of points.smooth curve through a set of points.
• A spline is a a flexible strip used to produce a A spline is a a flexible strip used to produce a smooth curve through a set of points.smooth curve through a set of points.
March 1, 2009 Dr. Muhammed Al-Mulhem 3
Representations of Curves
• A curve can be represented using:
– A sequence of points.
– A piecewise polynomial functions.
• A spline curve refers to any composite curve formed with polynomial sections.
• A curve can be represented using:
– A sequence of points.
– A piecewise polynomial functions.
• A spline curve refers to any composite curve formed with polynomial sections.
March 1, 2009 Dr. Muhammed Al-Mulhem 4
Specifying Curves
• A spline curve is specified as follows:
– Giving a set of coordinate positions, called control Points, which indicate the general shape of the curve.
– These points are then fitted with piecewise polynomial functions in one of two ways:
Interpolation
Approximation
• A spline curve is specified as follows:
– Giving a set of coordinate positions, called control Points, which indicate the general shape of the curve.
– These points are then fitted with piecewise polynomial functions in one of two ways:
Interpolation
Approximation
March 1, 2009 Dr. Muhammed Al-Mulhem 5
Specifying Curves
• Interpolation:
– When polynomial sections are fitted so that all the control points are on the curve, the resulting curve is said to interpolate the set of control points.
• Interpolation:
– When polynomial sections are fitted so that all the control points are on the curve, the resulting curve is said to interpolate the set of control points.
March 1, 2009 Dr. Muhammed Al-Mulhem 6
Specifying Curves
• Approximation
– When polynomial sections are fitted so that some or all the control points are not on the curve , the resulting curve is said to approximate the set of control points.
• Approximation
– When polynomial sections are fitted so that some or all the control points are not on the curve , the resulting curve is said to approximate the set of control points.
March 1, 2009 Dr. Muhammed Al-Mulhem 7
Parametric Continuity
• To ensure a smooth transition from one section of a piecewise parametric spline to the next, we impose various continuity conditions at the connection points.
• If each section of a spline curve is described with a set of parametric coordinate function of the form
x = x(u), y= y(u), z = z(u), u1 <= u <= u2
• We set parametric continuity by matching the parametric derivatives of adjoining curve sections at their common boundary.
• To ensure a smooth transition from one section of a piecewise parametric spline to the next, we impose various continuity conditions at the connection points.
• If each section of a spline curve is described with a set of parametric coordinate function of the form
x = x(u), y= y(u), z = z(u), u1 <= u <= u2
• We set parametric continuity by matching the parametric derivatives of adjoining curve sections at their common boundary.
March 1, 2009 Dr. Muhammed Al-Mulhem 8
Parametric Continuity
• Various continuity conditions:
• C0 continuity (Zero-order parametric continuity):
– Means simply that curves meet. That is, the values of x, y, and z evaluated at u2 for the first curve section are
equal, respectively, to the values of x, y, and z evaluated at u1 of the next curve section.
• Various continuity conditions:
• C0 continuity (Zero-order parametric continuity):
– Means simply that curves meet. That is, the values of x, y, and z evaluated at u2 for the first curve section are
equal, respectively, to the values of x, y, and z evaluated at u1 of the next curve section.
March 1, 2009 Dr. Muhammed Al-Mulhem 9
Parametric Continuity
• C1 continuity (First-order parametric continuity):
– Means that is the first parametric derivatives (tangent line) of the coordinate functions (above equations in slide 7) for two successive curve sections are equal at their joining point.
• C1 continuity (First-order parametric continuity):
– Means that is the first parametric derivatives (tangent line) of the coordinate functions (above equations in slide 7) for two successive curve sections are equal at their joining point.
March 1, 2009 Dr. Muhammed Al-Mulhem 10
Parametric Continuity
• C2 continuity (Second-order parametric continuity):
– Means that both the first and second parametric derivatives of the two curve sections are the same at the intersection.
• Higher order parametric continuity conditions are defined similarly.
• C2 continuity (Second-order parametric continuity):
– Means that both the first and second parametric derivatives of the two curve sections are the same at the intersection.
• Higher order parametric continuity conditions are defined similarly.
March 1, 2009 Dr. Muhammed Al-Mulhem 11
Parametric Continuity
March 1, 2009 Dr. Muhammed Al-Mulhem 12
Parametric Continuity
March 1, 2009 Dr. Muhammed Al-Mulhem 13
Cubic Spline
• Cubic spline requires less calculations and storage space, and more stable than higher-order polynomials.
• Given a set of control points, cubic interpolation splines are obtained by fitting the input points with a piecewise cubic polynomial curve that passes through every control point.
• Cubic spline requires less calculations and storage space, and more stable than higher-order polynomials.
• Given a set of control points, cubic interpolation splines are obtained by fitting the input points with a piecewise cubic polynomial curve that passes through every control point.
March 1, 2009 Dr. Muhammed Al-Mulhem 14
Cubic Polynomials
• A parametric cubic polynomial that is to be fitted between each pair of control points with the following equations:
x(t) = axt3 + bxt2 + cxt + dx
y(t) = axt3 + bxt2 + cxt + dx
z(t) = axt3 + bxt2 + cxt + dx
0 <= t <= 1
• A parametric cubic polynomial that is to be fitted between each pair of control points with the following equations:
x(t) = axt3 + bxt2 + cxt + dx
y(t) = axt3 + bxt2 + cxt + dx
z(t) = axt3 + bxt2 + cxt + dx
0 <= t <= 1
March 1, 2009 Dr. Muhammed Al-Mulhem 15
Cubic Polynomials
Let T = [t3 t2 t 1]
Coefficient Matrix C
The the cuve Q(t) can be represented as:
Q(t) = T*C
Let T = [t3 t2 t 1]
Coefficient Matrix C
The the cuve Q(t) can be represented as:
Q(t) = T*C
z
z
y
y
x
x
zyx
zyx
d
c
d
c
d
c
bbb
aaa
ttt 123
March 1, 2009 Dr. Muhammed Al-Mulhem 16
Parametric CurvesHow do we find the tangent to a
curve?
• If f(x) = x2 -4
– tangent at (x=3) is
f’(x) = 2x - 4 = 2(3) - 4 = 2
How do we find the tangent to a curve?
• If f(x) = x2 -4
– tangent at (x=3) is
f’(x) = 2x - 4 = 2(3) - 4 = 2
Derivative of Q(t) is the tangent vector at t:Derivative of Q(t) is the tangent vector at t:
CttCTt
tQtQt
0123)(')( 2
March 1, 2009 Dr. Muhammed Al-Mulhem 17
Piecewise Curve Segments
One curve constructed by connecting many smaller segments end-to-end
• Must have rules for how the segments are joined
Continuity describes the joint
• Parametric continuity
• Geometric continuity
One curve constructed by connecting many smaller segments end-to-end
• Must have rules for how the segments are joined
Continuity describes the joint
• Parametric continuity
• Geometric continuity
March 1, 2009 Dr. Muhammed Al-Mulhem 18
Parametric Continuity
• CC11 is tangent continuity (velocity) is tangent continuity (velocity)
• CC22 is 2 is 2ndnd derivative continuity (acceleration) derivative continuity (acceleration)
• Matching direction and magnitude of dMatching direction and magnitude of dnn / dt / dtnn
CCnn continous continous
• CC11 is tangent continuity (velocity) is tangent continuity (velocity)
• CC22 is 2 is 2ndnd derivative continuity (acceleration) derivative continuity (acceleration)
• Matching direction and magnitude of dMatching direction and magnitude of dnn / dt / dtnn
CCnn continous continous
March 1, 2009 Dr. Muhammed Al-Mulhem 19
Geometric Continuity
• Requires the parametric dervatives of the two sections are prportional to each other at their common boundary, instead of requiring equality.
• If positions match• G0 geometric continuity
• If direction (but not necessarily magnitude) of tangent matches
• G1 geometric continuity
• The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curve
• Requires the parametric dervatives of the two sections are prportional to each other at their common boundary, instead of requiring equality.
• If positions match• G0 geometric continuity
• If direction (but not necessarily magnitude) of tangent matches
• G1 geometric continuity
• The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curve
March 1, 2009 Dr. Muhammed Al-Mulhem 20
Parametric Cubic Curves
• In order to assure C2 continuity, curves must be of
at least degree 3
• Here is the parametric definition of a cubic (degree 3) spline in two dimensions
• How do we extend it to three dimensions?
• In order to assure C2 continuity, curves must be of
at least degree 3
• Here is the parametric definition of a cubic (degree 3) spline in two dimensions
• How do we extend it to three dimensions?
March 1, 2009 Dr. Muhammed Al-Mulhem 21
Parametric Cubic Splines
Can represent this as a matrix.Can represent this as a matrix.
March 1, 2009 Dr. Muhammed Al-Mulhem 22
Coefficients
So how do we select the coefficients?
• The coefficients [ax bx cx dx] and [ay by cy dy] must satisfy the
constraints defined by the continuity conditions
So how do we select the coefficients?
• The coefficients [ax bx cx dx] and [ay by cy dy] must satisfy the
constraints defined by the continuity conditions
March 1, 2009 Dr. Muhammed Al-Mulhem 23
Parametric Curves
• There are many splines developed, some of these are:
–Hermite
–Bezier
• There are many splines developed, some of these are:
–Hermite
–Bezier
March 1, 2009 Dr. Muhammed Al-Mulhem 24
Hermite Splines
• A Hermite spline is an interpolating cubic polynomial with a specified tangent at each control point.
• It can be adjusted locally because each curve section is only dependent on its endpoint constraints.
• A Hermite spline is an interpolating cubic polynomial with a specified tangent at each control point.
• It can be adjusted locally because each curve section is only dependent on its endpoint constraints.
March 1, 2009 Dr. Muhammed Al-Mulhem 25
Hermite Cubic Splines
• One cubic curve for each dimension.
• A curve constrained to x/y-plane has two curves.
• One cubic curve for each dimension.
• 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
March 1, 2009 Dr. Muhammed Al-Mulhem 26
Hermite Cubic Splines• A 2-D Hermite Cubic Spline is defined by eight parameters:
a, b, c, d, e, f, g, h
• How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters?
• 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 parameters: a, b, c, d, e, f, g, h
• How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters?
• 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
March 1, 2009 Dr. Muhammed Al-Mulhem 27
Hermite Cubic Spline
We know:
• (x, y) position at t = 0, p1
We know:
• (x, y) position at t = 0, p1
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(
March 1, 2009 Dr. Muhammed Al-Mulhem 28
Hermite Cubic Spline
We know:
• (x, y) position at t = 1, p2
We know:
• (x, y) position at t = 1, p2
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(
March 1, 2009 Dr. Muhammed Al-Mulhem 29
Hermite Cubic Splines
• So far we have four equations, but we have eight unknowns
• Use the derivatives
• So far we have four equations, but we have eight unknowns
• Use 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
March 1, 2009 Dr. Muhammed Al-Mulhem 30
Hermite Cubic Spline
We know:
• (x, y) derivative at t = 0, dp/dt
We know:
• (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(
March 1, 2009 Dr. Muhammed Al-Mulhem 31
Hermite Cubic Spline
We know:
• (x, y) derivative at t = 1, dp/dt
We know:
• (x, y) derivative at t = 1, dp/dt
dtdp
cbaf
d
c
b
acbaf
xx
x
2
2
2
23)1(
011213
1213)1(
dtdp
gfef
h
g
f
egfef
y
y
y
2
2
2
23)1(
011213
1213)1(
March 1, 2009 Dr. Muhammed Al-Mulhem 32
Hermite Specification
• Matrix equation for Hermite Curve• Matrix 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
2
1
2
1
0123
0100
1111
1000
March 1, 2009 Dr. Muhammed Al-Mulhem 33
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
2
1
2
11
0123
0100
1111
1000
March 1, 2009 Dr. Muhammed Al-Mulhem 34
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
2
1
2
1
0001
0100
1233
1122
MHermite GHermite
March 1, 2009 Dr. Muhammed Al-Mulhem 35
Resulting Hermite Spline Equation
March 1, 2009 Dr. Muhammed Al-Mulhem 36
Sample Hermite Curves
March 1, 2009 Dr. Muhammed Al-Mulhem 37
Hermite Curves
• If P(u) represents a parametric cubic point functionfor the cuve section between control points Pk and Pk+1 as shown bellow:
• If P(u) represents a parametric cubic point functionfor the cuve section between control points Pk and Pk+1 as shown bellow:
Pk
Pk+1
P(u) = (x(u), y(u), z(u)), where
• x(u)=axu3 + bxu2 + cxu + dx
• y(u)=ayu3 + byu2 + cyu + dy
• z(u)=azu3 + bzu2 + czu + dz
March 1, 2009 Dr. Muhammed Al-Mulhem 38
Hermite Curves
• The boundary conditions that define this Hermite curve section are:
P(0) = Pk
P(1) = Pk+1
P’(0) = DPk
P’(1) = DPk+1
• With DPk and DPk+1 specifying the values for the parametric derivatives at control points Pk and Pk+1
• The boundary conditions that define this Hermite curve section are:
P(0) = Pk
P(1) = Pk+1
P’(0) = DPk
P’(1) = DPk+1
• With DPk and DPk+1 specifying the values for the parametric derivatives at control points Pk and Pk+1
March 1, 2009 Dr. Muhammed Al-Mulhem 39
Hermite Curves
• We can write the vector equivalent for the Hermit curve section as:
– P(u) = a u3 + b u2 + cu + d 0<= u <= 1
• Where the x, y and z components of P(u) is
x(u)=axu3 + bxu2 + cxu + dx
y(u)=ayu3 + byu2 + cyu + dy
z(u)=azu3 + bzu2 + czu + dz
• We can write the vector equivalent for the Hermit curve section as:
– P(u) = a u3 + b u2 + cu + d 0<= u <= 1
• Where the x, y and z components of P(u) is
x(u)=axu3 + bxu2 + cxu + dx
y(u)=ayu3 + byu2 + cyu + dy
z(u)=azu3 + bzu2 + czu + dz
March 1, 2009 Dr. Muhammed Al-Mulhem 40
Hermite Curves
• The matrix equivalent is
• And the derivative of the point function is
• The matrix equivalent is
• And the derivative of the point function is
d
c
b
a
uuuuP 1)( 23
d
c
b
a
uuuP 0123)(' 2
March 1, 2009 Dr. Muhammed Al-Mulhem 41
Hermite Curves
• Substituting endpoint values 0 and 1 for parameter u into the above two equations, we can express the Hermite boundary conditions in the matrix form
• Substituting endpoint values 0 and 1 for parameter u into the above two equations, we can express the Hermite boundary conditions in the matrix form
d
c
b
a
D
D
P
P
PK
PK
k
k
0123
0100
1111
1000
1
1
March 1, 2009 Dr. Muhammed Al-Mulhem 42
Hermite Curves
• Solving this equation for the polynomial coefficients, we have
• MH, the Hermite matrix, is the inverse of the boundary condition matrix.
• Solving this equation for the polynomial coefficients, we have
• MH, the Hermite matrix, is the inverse of the boundary condition matrix.
1
1
1
0123
0100
1111
1000
PK
PK
k
k
D
D
P
P
d
c
b
a
1
1
1
0001
0100
1233
1122
PK
PK
k
k
D
D
P
P
1
1
PK
PK
k
k
H
D
D
P
P
M
March 1, 2009 Dr. Muhammed Al-Mulhem 43
Hermite Curves
• The above matrix can be written in terms of the boundary conditions as
• This can be used to determine the expressions for the polynomial Herimte functions.
• The above matrix can be written in terms of the boundary conditions as
• This can be used to determine the expressions for the polynomial Herimte functions.
1
123 1)(
PK
PK
k
k
H
D
D
P
P
MuuuuP
March 1, 2009 Dr. Muhammed Al-Mulhem 44
Hermite Blending Functions
• The above matrix can be used to determine the expressions for the polynomial Herimte functions,
– Hk(u) for k=0,1,2,3
• This can be done by carrying out the matrix multiplications and collecting coefficient for the boundary conditions to obtain the polynomial form:
• P(u) = Pk(2u3 - 3u2 + 1) + Pk+1(-2u3 + 3u2) + DPk(u3 -2u2 + u) + DPk+1(u3 u2)
• = Pk H0(u) + Pk+1 H1(u) + DPk H2(u) + DPk+1 H3(u)
• The above matrix can be used to determine the expressions for the polynomial Herimte functions,
– Hk(u) for k=0,1,2,3
• This can be done by carrying out the matrix multiplications and collecting coefficient for the boundary conditions to obtain the polynomial form:
• P(u) = Pk(2u3 - 3u2 + 1) + Pk+1(-2u3 + 3u2) + DPk(u3 -2u2 + u) + DPk+1(u3 u2)
• = Pk H0(u) + Pk+1 H1(u) + DPk H2(u) + DPk+1 H3(u)
March 1, 2009 Dr. Muhammed Al-Mulhem 45
Blending Functions