Unformatted text preview: Introduction to Computer Graphics
Lecture 15
Representation Of Curves Curves
1. Hermite Splines
1. Bezier Curves
2. BSpline Curve Splines – Old School Duck
Spline Splines  History
Draftsman use ‘ducks’ and
Draftsman
strips of wood (splines) to
draw curves
draw
Wood splines have secondorder continuity A Duck (weight) And pass through the
And
control points
control
Ducks trace out curve Representations of Curves
Use a sequence of points…
• Piecewise linear  does not accurately model a smooth line
• Tedious to create list of points
• Expensive to manipulate curve because all points must be
Expensive
repositioned
repositioned Instead, model curve as piecewisepolynomial
• x = x(t), y = y(t), z = z(t)
x(t),
– where x(), y(), z() are polynomials
where Specifying Curves (hyperlink) Control Points
• A set of points that influence the
set
curve’s shape
curve’s Knots
• Control points that lie on the curve Interpolating Splines
• Curves that pass through the control
Curves
points (knots)
points Approximating Splines
• Control points merely influence shape Interpolating Splines
Curves that pass through the control points (knots) 8 1 ï û ð Approximating Splines
• Control points merely influence shape 8 2 ÞüØ Splines
Splines are Curves or Curving surfaces represented with features of a
Splines
group of control points, simulating the engineering way.
group The procedure for calculating the positions of points between control
The
points is called interpolation.
points Parametric Curves
How do we represent the Curves? Parametric Curves.
Very flexible representation
They are not required to be functions
• They can be multivalued with respect to any dimension p = p(t ) t ∈ [0,1] x = x(t ) y = y (t )t ∈ [0,1]
z = z (t ) Parametric Curving Surfaces
P = P(u , v) 0 ≤ u ≤ 1 0 ≤ v ≤ 1
x = x(u, v) y = y (u, v) 0 ≤ u ≤ 1 0 ≤ v ≤ 1 z = z (u , v) Representation of Splines x(t ) = ant + + a2t + a1t + a0 n
2
1 y (t ) = bnt + + b2t + b1t + b0 z (t ) = c t n + + c t 2 + c t 1 + c
n
2
1
0 n 2 1 t ∈ [0,1] Piecewise Curve Segments
One curve constructed by connecting many
One
smaller segments endtoend
smaller
• Must have rules for how the segments are joined Continuity describes the joint
• Parametric continuity
• Geometric continuity Parametric Continuity
• C0 is position continuity
• C1 is tangent continuity (velocity)
• C2 is 2nd derivative continuity (acceleration) • Matching direction and magnitude of dn / dtn : Cn continous Geometric Continuity
If positions match
If
• G0 geometric continuity (same as C0) If direction (but not necessarily magnitude) of tangent
If
matches
matches
• G1 geometric continuity
• The tangent value at the end of one curve is proportional to the tangent
The
value of the beginning of the next curve
value If direction (but not necessarily magnitude) of
2nd derivative matches
2nd
• G2 geometric continuity 2DParametric Cubic Curves
In order to assure C2 continuity, curves must be of
at least degree 3
at
Here is the parametric definition of a cubic
Here
(degree 3) spline in two dimensions
(degree
How do we extend it to three dimensions? Cubic Polynomials
x(t) = axt3 + bxt2 + cxt + dx Each column is • Similarly for y(t) and z(t) an infinite dimension vector
an Let t: (0 <= t <= 1)
Let T = [t t t 1]
3 2 Coefficient Matrix C
Curve: Q(t) = T*C [t 3 t 2 t a x
1 ∗ bx c x
d x ay
by
cy
dy az bz cz dz Infinite Dimension Vector and Space
A Z An arbitrary funtion:
A = f(t) How about n samples?
How about all samples?
How about all functions?
A A
A A t X Y
A
A Infinite Dimension Vector and Space
An arbitrary function can be considered as one
An
infinite dimension vector.
infinite
All functions can be considered as an entire
All
infinite dimension vector space.
infinite Infinite dimension basic vector and
subspace
When we choose some different functions as the basic
When
different
functions for regenerating other functions (not all), just
as we choose some different infinite dimension vectors
different
as the basic vectors for regenerating other vectors.
as
If the basic vectors can not regenerate the entire space,
If
they regenerate a subspace.
they
Here, t3, t2,t ,1 are four basic vectors for regenerating a
,t
subspace which represent all cubic splines in CG.
subspace Derevative of Parametric Cubic Curves
How do we find the tangent to a curve?
• If f ( x ) = x 2 − 4
If
– tangent at (x=3) is f ' ( x) = 2 x = 2(3) = 6 Derivative of Q(t) is the tangent vector at t: [ d
d
'
Q (t ) = Q (t ) = T ⋅ C = 3t 2
dt
dt 2t 1 0 ⋅ C 2DParametric Cubic Splines
Can represent this as a matrix too Problem1: Coefficients Selection
Why do we need select the cofficients?
• We need confirm the shape of the curves. So how do we select the coefficients?
• [ax bx cx dx] and [ay by cy dy] must satisfy the constraints
must
defined by the knots and the continuity conditions
knots
continuity
• Knots: position and 1n th derevatives; both for single or
position
piecewise curves
piecewise
• Continuity conditions: for piecewise curves Problem2: Is the curve shape controlling
easy?
Difficult to conceptualize curve as
Difficult
x(t) = axt3 + bxt2 + cxt + dx
x(t)
(artists don’t think in terms of coefficients of cubics) Instead, define curve as weighted combination of 4 welldefined cubic polynomials
(wait a second! Artists don’t think this way either!) Each curve type defines different cubic polynomials and
Each
weighting schemes
weighting Parametric Curves
Hermite – two endpoints and two endpoint
tangent vectors for curves
tangent
Bezier  two endpoints and two other points that
define the endpoint tangent vectors
define
BSplines – four control points
• C1 and C2 continuity at the join points
• Come close to their control points, but not guaranteed to
Come
touch them
touch Hermite Cubic Splines
An example of knot and continuity constraints Hermite Cubic Splines
One cubic curve for each dimension
A curve constrained to x/yplane has two curves:
f x (t ) = at 3 + bt 2 + ct + d
a b = t3 t2 t 1 c d [ f y (t ) = et 3 + ft 2 + gt + h
e f = t3 t2 t 1 g h [ Hermite Cubic Splines
A 2D Hermite Cubic Spline is defined by eight
2D
parameters: a, b, c, d, e, f, g, h
parameters:
How do we convert the intuitive endpoint constraints into
How
these (relatively) unintuitive eight parameters?
these
We know:
• (x, y) position at t = 0, p1
• (x, y) position at t = 1, p2
• (x, y) derivative at t = 0, dp/dt
• (x, y) derivative at t = 1, dp/dt Hermite Cubic Spline
We know:
• (x, y) position at t = 0, p1 = a 0 + b0 + c 0 + d
a b = 03 0 2 0 1 c d f x (0) = d = p1x
3 f x ( 0) [ 2 = e0 3 + f 0 2 + g 0 + h
e f = 03 0 2 0 1 g h f y (0) = h = p1y
f y ( 0) [ Hermite Cubic Spline
We know:
• (x, y) position at t = 1, p2 = a1 + b1 + c1 + d
a b = 13 12 1 1 c d f x (1) = a + b + c + d = p2 x
3 f x (1) [ 2 = e13 + f 12 + g1 + h
e f = 13 12 1 1 g h f y (1) = e + f + g + h = p2 y
f y (1) [ Hermite Cubic Splines
So far we have four equations, but we have eight
So
unknowns
unknowns
Use the derivatives
f x (t ) = at 3 + bt 2 + ct + d f y (t ) = et 3 + ft 2 + gt + h f x′(t ) = 3at 2 + 2bt + c f y′(t ) = 3et 2 + 2 ft + g [ f x′(t ) = 3t 2 2t a b 1 0 c d [ f y′(t ) = 3t 2 2t e f 1 0 g h Hermite Cubic Spline
We know:
• (x, y) derivative at t = 0, dp/dt
f x′(0) f y′(0) = 3a 0 + 2b0 + c
2 [ = 3 ⋅ 02 f x′(0) = c = dp1x 2 ⋅0 dt a b 1 0 c d = 3e0 2 + 2 f 0 + g [ = 3 ⋅ 02 f y′(0) = g = dp1y 2 ⋅0 dt e f 1 0 g h Hermite Cubic Spline
We know:
• (x, y) derivative at t = 1, dp/dt
f x′(1) f y′(1) = 3a1 + 2b1 + c
2 a b = 3 ⋅12 2 ⋅1 1 0 c d dp
′(1) = 3a + 2b + c = 1x
fx
dt [ = 3e12 + 2 f 1 + g e f = 3 ⋅12 2 ⋅1 1 0 g h dp1y
f y′(1) = 3e + 2 f + g =
dt [ Hermite Specification
Matrix equation for Hermite Curve
t3
p1
p2
r p1
r p2 0
1 0 3 t2 0
1
0
2 t1 0
1
1
1 t0 1 a b
1
0 c 0d p1y p1x
e p2 y p2 x f
dp2 y = dp1x
g dt
dt dp
dp2 y 1x
h dt
dt t=0
t=1
t=0
t=1 Solve Hermite Matrix
0
1 0 3 0
1
0
2 0
1
1
1 1 1
0 0 −1 p1y p1x a e p2 y p2 x b f
dp1y = dp1x dt
dt c g dp1
dp2 y d h x dt dt Spline and Geometry Matrices
2
− 3 0 1 −2
3
0
0 1
−2
1
0 MHermite p1y p1x
1 a e p2 y p2 x −1
b f
dp1y = dp1x
0 dt
dt c g dp
dp2 y d h 1x
0 dt
dt GHermite Resulting Hermite Spline Equation Sample Hermite Curves Blending Functions
By multiplying first two matrices in lowerleft
By
equation, you have four functions of ‘t’ that
blend the four control parameters
blend
These are blending
functions Blending Functions
H 0 (t ) = 2t − 3t + 1
3
2
H1 (t ) = −2t + 3t
3
2
H 2 (t ) = t − 2t + t
3
2
H 3 (t ) = t − t
3 2 p (t ) = Pk H 0 (t ) + Pk +1 H1 (t ) + Rk H 2 (t ) + Rk +1 H 3 (t ) Hermite Blending Functions
If you plot the
If
blending
functions on
the parameter
‘t’
‘t’ H (t) H (t) H (t) Hermite Blending Functions
Remember, each
blending function
reflects influence
of P1, P2, ∆ P1, ∆ P2
on spline’s shape H (t) H (t) H (t) Summery: Hermite Splines
Advantage:
Advantage:
• Most important, it interpolates curve points with the linear
Most
combination of control point features, and is more easy than
linear combination of polynomials for artists.
linear • If defined with piecewise curves, Hermite Splines can control
If
the local feature of Curves.
the Summery: Hermite Splines
Disadvantage:
Disadvantage:
• The shape feature controlling depended on deravatives of
The
end points is not easy for artists.
end • If defined with piecewise curves, to maintain C2 continuity,
the neighboring curve pieces have to be forced to obtain the
same 2nd derevative at the share end point.
same Splines  History
Draftsman use ‘ducks’ and
Draftsman
strips of wood (splines) to
draw curves
draw
Wood splines have secondorder continuity A Duck (weight) And pass through the
And
control points
control
Ducks trace out curve Bezier Curves
Similar to Hermite, but more intuitive definition of
Similar
endpoint derivatives
endpoint
Four control points, two of which are knots Bezier Curves
The derivative values of the Bezier Curve at the
The
knots are dependent on the adjacent points
knots The scalar 3 was selected just for this curve
The Bezier vs. Hermite
We can write our Bezier in terms of Hermite
• Note this is just matrix form of previous equations Bezier vs. Hermite
Now substitute this in for previous Hermite Bezier Basis and Geometry Matrices
Matrix Form But why is MBezier a good basis matrix? Bezier Blending Functions
Look at the blending
Look
functions
functions
This family of
This
polynomials is called
polynomials
order3 Bernstein
order3
Polynomials
Polynomials
• C(3, k) tk (1t)3k; 0<= k <= 3
• They are all positive in interval [0,1]
• Their sum is equal to 1 Bezier Blending Functions
Thus, every point on curve is
Thus,
linear combination of the
control points
control
The weights of the
The
combination are all positive
combination
The sum of the weights is 1
Therefore, the curve is a
Therefore,
convex combination of the
control points
control Convex combination of control points
Will always remain within bounding region
Will
(convex hull) defined by control points
(convex Nth Bezier Curves
Nth Bezier Curves:
n p (t ) = ∑ Pk BEN k ,n (t ) t ∈ [0,1] k =0 Nth Blending Funtions: n!
n−k
n−k
k
kk
BEN k ,n (t ) =
t (1 − t ) = C n t (1 − t )
k!( n − k )!
k = 0,1, , n Nth Bezier Curves
One must have n+1 control points and n+1 blending
One
functions to construct Nth Bezier Curves or Bezier Curve
pieces.
pieces.
Important: But there is no more segmentation in one
Important:
curve piece, one control point affect all the curve piece.
curve
This is also true for Nth Hermite Curves. Summery: Bezier Curves
Advantage:
• The shape feature controlling depended on positions of
The
end points is very easy for artists.
end • Because of the convex hull attribute, Bezier Curves obtain
Because
better local feature controlling than Hermite Curves.
better Summery: Bezier Curves
Disadvantages:
• Like Hermite Curves, in one curve piece, change one end
Like
point’s feature will affect the whole piece.
point’s • Bezier curves also need maintain C2 continuity for
neighbering curve pieces, and this is more difficult than
Hermite Curves for artists.
Hermite Why more spline slides?
Bezier and Hermite splines have global influence
• One could create a Bezier curve that required 15 points to define the
One
curve…
curve…
– Moving any one control point would affect the entire curve
• Piecewise Bezier or Hermite don’t suffer from this, but they don’t
Piecewise
enforce derivative continuity at join points
enforce Bsplines consist of curve segments whose polynomial
coefficients depend on just a few control points
coefficients
• Local control BSpline Curve
BSpline Curve:
n p(t) = ∑ k Bk,m(t)
P
k =0 Blending Function: t k ≤ t < t k +1
1
Bk ,1 (t ) = 0 t k > t t ≥ t k +1
t − tk
tk +m − t
Bk ,m (t ) =
Bk ,m −1 ( t ) +
Bk +1,m −1 ( t )
t k + m −1 − t k
t k + m − t k +1 Uniform or NonUniform BSpline
Uniform BSpline: t k +1 − t k ≡ C
NonUniform BSpline: t k +1 − t k = f (k ) Blending Function of BSpline Curves
For Uniform Bspline Curves: Bk, 3( t ) Bk ,m (t ) = Bk +1,m (t + ∆t ) = Bk + 2,m (t + 2∆t )
1 B1, 3( t ) B2, 3( t ) B0, 3( t ) 1 2 3 B3, 3( t ) 4 5 t Blending 11
8 Functions of 4 piece 2thV uniform BSpline
(
YØ ´ Bˆª
)
j BSpline Curve (cubic periodic)
Start with a sequence of control points
Select four from middle of sequence (pi2, pi1, pi,
(p
Select
pi+1) • Bezier and Hermite goes between pi2 and pi+1
• BSpline doesn’t interpolate (touch) any of them but
BSpline
approximates going through pi1 and pi p
approximates
p
p
2 1 t4
Q
p0 Q t3 6 t5
p3 t6
Q p4
Q p5 t7 Uniform BSplines
Approximating Splines
Approximates n+1 control points
• P0, P1, …, Pn
Curve consists of n –2 cubic polynomial segments
• Q3, Q4, … Qn
t varies along Bspline as Qi: ti <= t < ti+1
ti (i = integer) are knot points that join segment Qi to Qi+1
knot
Curve is uniform because knots are spaced at equal
Curve uniform
intervals of parameter, t
intervals Uniform BSplines
First curve segment, Q3, is defined by first four
is
control points
control
Last curve segment, Qm, is defined by last four
is
control points, Pm3, Pm2, Pm1, Pm
control
Each control point affects four curve segments
Each Bspline Basis Matrix
Formulate 16 equations to solve the 16 unknowns
The 16 equations enforce the C0, C1, and C2
continuity between adjoining segments, Q
continuity M B −spline −1
3
1
=
6 − 3 1 3
−6
0
4 − 3 1 3 0
3 0 1 0 BSpline
Points along BSpline are computed just as with
Points
Bezier Curves
Bezier Qi ( t ) = UM B −Spline P [ Qi ( t ) = t 3 t 2 t −1
3
1
1
6 − 3 1 3
−6
0
4 − 3 1 pi p 3 0 i +1 3 0 pi +2 1 0 pi +3 BSpline
By far the most popular spline used
C0, C1, and C2 continuous Summary: BSpline Curves
Advantages:
• The Blending Functions of BSpline Curves are only affect
Spline
local features of Curves. Blocal
Spline Curves have more local
Spline
controlling ability than Hermite
and Bezeir Curves.
and P1 P2 P4 P6 P′ 4
P0
P3 P5
P″ 4 P 816 B ;
Ÿ
Local controlling of BSpline P7 Summary: BSpline Curves
Advantages: BSpline • BSpline Curves have the
BSpline
convexhull attribute, with the
better local controlling ability,
they can obtain better curve
quality.
quality. n ∑B
k =0 k ,m (t ) ≡ 1
BSpline Summary: BSpline Curves
Advantages:
• Nth BSpline Curves maintain CN1 continuity at all knots, if
there is no repeated knots.
there • It combines piecewise continuity and local controlling
It
naturally.
naturally. Converting Between Splines
Consider two spline basis formulations for two
Consider
spline types
spline Converting Between Splines
We can transform the control points from one
We
spline basis to another
spline Converting Between Splines
With this conversion, we can convert a BSpline
With
into a Bezier Spline
into
Bezier Splines are easy to render ...
View
Full Document
 Spring '10
 Professor
 Bspline, Cubic Hermite spline, Hermite Cubic Splines

Click to edit the document details