Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
1
1
CS 536Computer Graphics
Hermite and Catmull-Rom CurvesWeek 2, Lecture 4
David Breen, William Regli and Maxim PeysakhovDepartment of Computer Science
Drexel University
Additional slides from Don Fussell, University of Texas andSteve Marschner, Cornell University
2
Outline• Hermite Curves• Continuity• Catmull-Rom Curves
Hermite Curve
3
• 3D curve of polynomial bases• Geometrically defined by position
and tangents at end points• No convex hull guarantees• Supports tangent-continuous (C1)
composite curves
Algebraic Representation• All of these curves are just parametric algebraic polynomials
expressed in different bases• Parametric cubic curve (in R3)
• First derivative of curve
€
x = axu3 + bxu
2 + cxu + dxy = ayu
3 + byu2 + cyu + dy
z = azu3 + bzu
2 + czu + dz
P(u) = au3 +bu2 + cu+d
D. Fussell – UT, Austin
P '(u) = 3au2 + 2bu + cx = 3axu
2 + 2bxu + cxy = 3ayu
2 + 2byu + cyz = 3azu
2 + 2bzu + cz
Algebraic Representation• All of these curves are just parametric algebraic polynomials
expressed in different bases• Parametric cubic curve (in R3)
• First derivative of curve
P(u) = au3 +bu2 + cu+d
D. Fussell – UT, Austin
P '(u) = 3au2 + 2bu + c
P(0) = dP(1) = a+b+ c+dPu(0) = cPu(1) = 3a+ 2b+ c
Hermite Curves• 12 degrees of freedom (4 3-d vector
constraints)• Specify endpoints and tangent vectors at
endpoints
• Solving for the coefficients:
P(0) = dP(1) = a+b+ c+dPu(0) = cPu(1) = 3a+ 2b+ c
a = 2p(0)− 2p(1)+pu(0)+pu(1)b = −3p(0)+3p(1)− 2pu(0)−pu(1)c = pu(0)d = p(0)
pu(u) ≡ dPdu(u)
•
•pu(0)
u = 0
u = 1
p(0)
p(1)
pu(1)
D. Fussell – UT, Austin
2
Hermite Curves• Putting it all together
7
a = 2p(0)− 2p(1)+pu(0)+pu(1)b = −3p(0)+3p(1)− 2pu(0)−pu(1)c = pu(0)d = p(0)
P(u) = au3 +bu2 + cu+d
P(u) = (2u3 −3u2 +1)p(0)+ (−2u3 +3u2 )p(1)+ (u3 − 2u2 +u)pu(0)+ (u3 −u2 )pu(1)
Hermite Basis• Substituting for the coefficients and collecting terms gives
• Call
the Hermite blending functions or basis functions
• Then
P(u) = (2u3 −3u2 +1)p(0)+ (−2u3 +3u2 )p(1)+ (u3 − 2u2 +u)pu(0)+ (u3 −u2 )pu(1)
€
H1(u) = (2u3 − 3u2 +1)H2(u) = (−2u3 + 3u2)H3(u) = (u3 − 2u2 + u)H4 (u) = (u3 − u2)
P(u) =H1(u)p(0)+H2(u)p(1)+H3(u)pu(0)+H4(u)p
u(1)
H1 H2
H3
H4
n
D. Fussell – UT, Austin
Blending Functions
• At u = 0:– H1 = 1, H2 = H3 = H4 = 0– H1’ = H2’ = H4’ = 0, H3’ = 1
• At u = 1:– H1 = H3 = H4 = 0, H2 = 1– H1’ = H2’ = H3’ = 0, H4’ = 1
H1(u) H2(u) H3(u) H4(u)
P(0) = p0P’(0) = T0
P(1) = p1P’(1) = T1
P(u) = (2u3 −3u2 +1)p(0)+ (−2u3 +3u2 )p(1)+ (u3 − 2u2 +u)pu(0)+ (u3 −u2 )pu(1)
P '(u) = (6u2 − 6u)p(0)+ (−6u2 + 6u)p(1)+ (3u2 − 4u+1)pu(0)+ (3u2 − 2u)pu(1)
Hermite Curves - Matrix Form• Putting this in matrix form
• MH is called the Hermite characteristic matrix• Collecting the Hermite geometric
coefficients into a geometry vector G,
D. Fussell – UT, Austin
𝐆 = 𝒑(𝟎) 𝒑(𝟏) 𝒑′(𝟎) 𝒑′(𝟏)
𝐇 = H+(𝑢) H-(𝑢) H.(𝑢) H/(𝑢)
=
2 −3−2 3
0 10 0
1 −21 −1
1 00 0
𝑢.𝑢-𝑢1
= 𝐌𝐇U
Hermite and Algebraic Forms• Putting it all together produces the matrix
formulation for the Hermite curve P(u)
• MH transforms geometric coefficients (“coordinates”) from the Hermite basis to the algebraic coefficients of the monomial basis
D. Fussell – UT, Austin
𝑷 𝑢 = 𝐆𝐌7𝐔𝑷 𝑢 = 𝐆𝐁7
Hermite Curves
14
• Geometrically defined by position and tangents at end points
3
Hermite to Bézier
• Mixture of points and vectors is awkward and unintuitive
• Specify tangents as differences of points
q0 q1
Hermite to Bézier
– note derivative is defined as 3 times offset
p0 = q0; p3 = q1;p1 = q0+ (1/3)t0; p2 = q1- (1/3)t1
q0 q1
Bezier to Hermite
– note derivative is defined as 3 times offset
q0 = p0; q1 = p3;t0 = 3(p1 - p0); t1 = 3(p3 - p2);
q0 q1
18
Back to Bézier Curves• k+1 control points
defines a degree k curve
• Endpoint interpolation• Convex hull property
Pics/Math courtesy of G. Farin @ ASU
19
Issues with Bézier Curves
• Creating complex curves requires many control points– potentially a very high-degree polynomial
with many wiggles• Bézier blending functions have global
support over the whole curve– move just one point, change whole curve
• Improved Idea: link (C1) lots of low degree (cubic) Bézier curves end-to-end
20
ContinuityTwo types:• Geometric Continuity, Gi:
– endpoints meet– tangent vectors’ directions are equal
• Parametric Continuity, Ci:– endpoints meet– tangent vectors’ directions are equal– tangent vectors’ magnitudes are equal
• In general: C implies G but not vice versa
4
21
Parametric Continuity
• Continuity (recall from the calculus):– Two curves are Ci continuous at a point p iff the i-th derivatives of the curves are equal at p
Pics/Math courtesy of Dave Mount @ UMD-CP
22
Continuity
• What are the conditions for C0 and C1continuity at the joint of curves xl and xr?– tangent vectors at end points equal– end points equal
Ql Qr1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
Ql (1) =Qr (0), dQl
dt(1) = dQ
r
dt(0)
23
Continuity• The derivative of is the parametric
tangent vector of the curve:
1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
24
Continuity• In 3D, compute this for each component of
the parametric function– For the x component:
• Similar for the y and z components.
1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
xl xr
Chaining Bézier curves
• No continuity built in• Achieve C1 using collinear control points
around join points
Catmull-Rom splines• Our first example of an interpolating
spline • Like Bézier, equivalent to Hermite
– in fact, all splines of this form are equivalent
• First example of a spline based on just an input point sequence
• Does not have convex hull property• Only has C1 continuity
5
• A sequence of Hermite/Bezier curves• Would like to define tangents
automatically– use adjacent control points
– end tangents: user-defined or fit a parabola
Catmull-Rom splines Catmull-Rom splines• Tangents are (pk + 1 – pk – 1) / 2 for
interior control points (pk)• User specifies tangents at first (T0) and
last (TN) input points• Or fit parabola to first/last 3 pointsq0 = pkq1 = pk+1t0 = 0.5(pk+1 − pk−1)t1 = 0.5(pk+2 − pk )
Adding tension• Adding tension to Catmull-Rom spline
involves adjusting tangents at interior join points, pi
• When T=0, standard C-R spline• When T=1, tangent is zero
t0 = (1−T )0.5(pk+1 − pk−1)t1 = (1−T )0.5(pk+2 − pk )
Adding tension• Scale user-provided tangent vectors
• T0’ = (1 – T) T0
• TN’ = (1 – T) TN
30
Adding Tension
31 32
Programming Assignment 2• Process command-line arguments• Read in 3D input points and tangents• Compute tangents at interior input points• Modify tangents with tension parameter• Compute Bezier control points for curves defined
by each two input points• Use HW1 code to compute points on each Bezier
curve• Each Bezier curve should be a polyline• Output points by printing them to the console as
an IndexedLineSet with multiple polylines, and control points as spheres in Open Inventor format