0% found this document useful (0 votes)
15 views

Parametric Curves

The document discusses parametric curves and their uses in computer graphics and modeling. It covers: 1) Parametric curves allow curves to be defined using parameteric functions like x(t) and y(t), rather than explicit or implicit equations. This makes them easier to work with than other representations. 2) Cubic polynomial curves are commonly used in computer graphics due to their smoothness and ability to be defined by a compact matrix of coefficients. 3) Hermite curves are cubic curves defined by two endpoints and tangent vectors at those endpoints, fully constraining the curve. The Hermite basis matrix relates the curve parameters to the geometric constraints.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Parametric Curves

The document discusses parametric curves and their uses in computer graphics and modeling. It covers: 1) Parametric curves allow curves to be defined using parameteric functions like x(t) and y(t), rather than explicit or implicit equations. This makes them easier to work with than other representations. 2) Cubic polynomial curves are commonly used in computer graphics due to their smoothness and ability to be defined by a compact matrix of coefficients. 3) Hermite curves are cubic curves defined by two endpoints and tangent vectors at those endpoints, fully constraining the curve. The Hermite basis matrix relates the curve parameters to the geometric constraints.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Reading

Š Foley, Section 11.2


Optional
Š Bartels, Beatty, and Barsky. An Introduction to Splines
for use in Computer Graphics and Geometric Modeling,
Parametric Curves 1987.
Š Farin. Curves and Surfaces for CAGD: A Practical
Guide, 4th ed., 1997.

1 2

Curves before computers Motivation for curves


The “loftsman’s spline”: What do we use curves for?

Š long, narrow strip of wood or metal Š building models


Š shaped by lead weights called “ducks”
Š gives curves with second-order continuity, usually
Used for designing cars, ships, airplanes, etc.
Š movement paths

Š animation

3 4
Mathematical curve representation Parametric polynomial curves
Š Explicit y=f(x) We’ll use parametric curves where the functions are all
• what if the curve isn’t a function?
polynomials in the parameter.
n
x (u ) = ∑ ak u k
k =0
Š Implicit f(x,y) = 0 n
• hard to work with
y (u ) = ∑ bk u k
x2 + y2 − R2 = 0 Advantages:
k =0
Š easy (and efficient) to compute
Š Parametric (f(u),g(u))
Š infinitely differentiable
x(u) = cos 2πu
y(u) = sin 2πu
5 6

Cubic curves Compact representation


Fix n=3 Place all coefficients into a matrix
For simplicity we define each cubic function within the range  ax a y az 
0 ≤ t ≤1 b b b 
C=
z 
T = t 3 t 2 t 1
x y

Qx (t ) = ax t 3 + bx t 2 + cx t + d x  cx c y cz 
 
Q(t ) = [ x(t ) y (t ) z (t ) ] or Qy (t ) = a y t 3 + by t 2 + c y t + d y d x d y d z 
Qz (t ) = az t 3 + bz t 2 + cz t + d z  ax ay az 
b by bz 
or
Q(t ) = [ x(t ) y (t ) z (t ) ] = t 3 t 1  
x
t2 = T⋅C
 ax ay az   x
c cy cz 
b  
by bz  d x dy dz 
Q(t ) =   t 3 t 1
x
t2
 cx cy cz  
  d d d d
d x dy dz 
Q(t ) = Q′(t ) = ( T ⋅ C ) = T ⋅ C + T ⋅ C = 3t 2 2t 1 0  ⋅ C
7
dt dt dt dt 8
Controlling the cubic Constraining the cubics
Q: How many constraints do we need to specify to fully
Redefine C as a product of the basis matrix M and the
determine the scalar cubic function Q(t)? 4-element column vector of constraints or geometry vector G

C = M ⋅G
 m11 m12 m13 m14   G1x G1 y G1z 
m  G2 z 
m22 m23 m24  G2 x G2 y

Q: How many constraints do we need to specify to fully Q(t ) = t 3 t2 t 1  21 
 m31 m32 m33 m34   G3 x G3 y G3 z 
determine the 3-vector cubic function Q(t)?   
 m41 m42 m43 m44  G4 x G4 y G4 z 
= T⋅M ⋅G

9 10

Hermite Curves
Determined by

Š endpoints P1 and P4
Š tangent vectors at the endpoints R1 and R4
So
Q(t ) = T ⋅ M h ⋅ G h P4

Where P1 R4
 P1x P1 y P1z 
P P4 y P4 z  R1
Gh =  
4x

 R1x R1 y R1z 
 
 R4 x R4 y R4 z 
11 12
Computing Hermite basis matrix Computing Hermite basis matrix
The constraints on Q(0) and Q(1) are found by direct Collecting all constraints we get
substitution:
Q (0) = [ 0 0 0 1] ⋅ M h ⋅ G h Q(t) P4  P1x P1 y P1z  0 0 0 1
P  
Q (1) = [1 1 1 1] ⋅ M h ⋅ G h  4x
P4 y P4 z
 = G = 1 1 1 1
P1 R4  Mh ⋅ Gh
 R1x R1 y R1z  h
0 0 1 0
Tangents are defined by    
R1  R4 x R4 y R4 z  3 2 1 0
Q′(t ) = 3t 2
2t 1 0  ⋅ M h ⋅ G h
so constraints on tangents are: So
−1
0 0 0 1  2 −2 1 1 
Q′(0) = [ 0 0 1 0] ⋅ M h ⋅ G h 1 1 1 1  −3 3 −2 −1
Mh =   = 
Q′(1) = [3 2 1 0] ⋅ M h ⋅ G h Q(t) P4
0 0 1 0 0 0 1 0
P1 R4    
3 2 1 0 1 0 0 0
13 14
R1

Computing a point Blending Functions


Given two endpoints (P1,P4) and two endpoint tangent vectors Polynomials weighting each element of the geometry vector
(R1 , R4):  2 −2 1 1   P1 
Q(t) P4   
 3 2   −3 3 −2 −1  P4 
So Q (t ) = t t t 1
   0 0 1 0   R1 
P1 R4   
 1 0 0 0   R 4 

 P1  Bh(t)
R1 P 
= B h (t )  4  1 P1 P4
 R1 
 2 −2 1 1   P1   
 −3 3 −2 −1  P  R 4 
Q(t ) = t 3 t2 t 1   4 
 0 0 1 0   R1 
  
 1 0 0 0  R 4  R1

15 R4 1 t 16
Continuity Continuity of Splines
We want our curve to have continuity. There shouldn’t be an abrupt P4
P2 =P3 R4
change when we move from one segment to the next.
C0: points coincide,
There are nested degrees of continuity: P1 R2 velocities don’t
R3
C0: C1: R1
P4 R4
P2 =P3 G1: points coincide,
velocities have same direction
P1 R2
R3

R1 P4 R4
P2 =P3 C1: points and velocities
coincide
C2: C3, C4, …: P1 R2 = R3
Q: What’s C2?
17 R1 18

Bézier Curves

Indirectly specify the tangent vectors P3


by specifying two intermediate points

P1 P4

P2
R1 = 3(P2 − P1 )
R 4 = 3(P4 − P3 )
 P1x P1 y P1z   P1 
P P2 y P2 z   P2 
Gb =  = 
2x

 P3 x P3 y P3 z   P3 
 
 P4 x P4 y P4 z   P4 
19 20
Bézier basis matrix Bézier basis matrix
Establish the relation between the Hermite and Besier Q(t ) = T ⋅ M h ⋅ G h = T ⋅ M h ⋅ ( M hb ⋅ G b )
geometry vectors:
= T ⋅ ( M h ⋅ M hb ) ⋅ G b = T ⋅ M b ⋅ G b
R1 = 3(P2 − P1 )
R 4 = 3(P4 − P3 )  −1 3 −3 1
 3 −6 3 0
M b = M h M hb =  
 −3 3 0 0
 P1   1 0 0   P1 
0  
P   0 1 0 0 0
0 1   P2 
0
Gh =  4  =     = M bhG b
 R 1   −3 3 0 0   P3 
    
R 4   0 0 −3 3   P4  Q(t ) = T ⋅ M b ⋅ G b

21 22

Bézier Blending Functions Alternative Bézier Formulation


a.k.a. Bernstein polynomials
 −1 3 −3 1   P1   P1  3
 3
 3 −6 3 
0 P2  P  Q(t ) = ∑ Pi  t i (1 − t )3−i

Q (t ) = t 3 t 2 t 1 
    = Bb (t )  2  i =0 i
   −3 3 0 0   P3   P3 
  P   
1 0 0 0  4   P4   −1 3 −3 1   P1 
Bb(t)  3 −6 3 0   P2 
Q ( t ) = t 3 t 2 t 1   
1    −3 3 0 0   P3 
B4
B1   
1 0 0 0   P4 
B2 B3

n
 n
Q(t ) = ∑ Pi  t i (1 − t ) n −i
1 t 23
i =0 i 24
Displaying Bézier curves Subdivide and conquer
How could we draw one of these things?

DisplayBezier( V0, V1, V2, V3 )


begin
if ( FlatEnough( V0, V1, V2, V3 ) )
Line( V0, V3 );
else
DisplayBezier( V0, V1, V2, V3 )
do something smart;
end; begin
if ( FlatEnough( V0, V1, V2, V3 ) )
It would be nice if we had an adaptive algorithm, that would Line( V0, V3 );
take into account flatness. else
Subdivide(V) ⇒ L, R
DisplayBezier( L0, L1, L2, L3 );
DisplayBezier( R0, R1, R2, R3 );
25 end; 26

Testing for flatness More complex curves


Suppose we want to draw a more complex curve.

Why not use a high-order Bézier?

Instead, we’ll splice together a curve from individual segments that are
cubic Béziers.

Compare total length of control polygon to length of line Why cubic?


connecting endpoints:
V0 − V1 + V1 − V2 + V2 − V3
< 1+ ε
V0 − V3
There are three properties we’d like to have in our newly constructed
splines…
27 28
Local control Interpolation
One problem with Béziers is that every control point affects every point Bézier curves are approximating. The curve does not
on the curve (except the endpoints).
(necessarily) pass through all the control points. Each point
Moving a single control point affects the whole curve! pulls the curve toward it, but other points are pulling as well.

We’d like to have a spline that is interpolating, that is, that


We’d like our spline to have local control, that is, have each control point always passes through every control point.
affect some well-defined neighborhood around that point.
29 30

Ensuring continuity Ensuring C2 continuity


Let’s look at continuity first. Suppose we want to join two cubic Bézier curves
(V0,V1,V2,V3) and (W0,W1,W2,W3) so that there is C2
Since the functions defining a Bézier curve are polynomial, continuity at the joint. W 1
W 2

all their derivatives exist and are continuous.

Therefore, we only need to worry about the derivatives at the


W3
endpoints of the curve.
W0

First, we’ll rewrite our equation for Q(t) in matrix form: Qv (1) = Qw (0) ⇒ V3 = W0
 −1 3 −3 1  P0  Qv′ (1) = Qw′ (0) ⇒ V3 − V2 = W1 − W0
 3 −6 3  P  Q′(0) = 3(V1 − V0 )
Q (t ) = t 3 t2 t 1 
 −3 3
  1
  P2 
Q′(1 ) = 3(V3 − V2 ) Qv′′ (1) = Qw′′ (0) ⇒ V1 − 2V2 + V3 = W0 − 2W1 + W2
  P  Q′′(0) = 6(V0 − 2V1 + V2 )
1   3
Q′′(1 ) = 6(V1 − 2V2 + V3 )

W2 = V1 + 4V3 − 4V2
31 32
A-frames and continuity Building a complex spline
Let’s try to get some geometrical intuition about what this last Instead of specifying the Bézier control points themselves, let’s specify
the corners of the A-frames in order to build a C2 continuous spline.
continuity equation means.

If a and b are points, what is (2a-b)?


W2 = V1 + 4V3 − 4V2
V1 V2 B1 = 2 ( 2V3 − V2 ) − ( 2V2 − V1 )



V3 = W0 
W1

B1

W2
W1
V0

These are called B-splines. The starting set of points are called de Boor
W2 W3 points.
33 34

B-splines Endpoints of B-splines


Here is the completed B-spline. We can see that B-splines don’t interpolate the de Boor
points.

It would be nice if we could at least control the endpoints of


the splines explicitly.

There’s a hack to make the spline begin and end at control


1 2 1  points by repeating them.
V0 =  B0 + ( B1 − B0 ) + B1 + ( B2 − B1 ) 
2 3 3 
1
V1 = B1 + ( B2 − B1 )
3
2
V2 = B0 + ( B1 − B0 )
3
V3 = ...
What are the Bézier control points, in terms of the de Boor
points?
35 36
B-spline basis matrix C2 interpolating splines
Interpolation is a really handy property to have.

How can we keep the C2 continuity we get with B-splines but get
interpolation, too?

Here’s the idea behind C2 interpolating splines. Suppose we had cubic


Béziers connecting our control points C0, C1, C2, …, and that we
 −1 3 −3 1   P1  somehow knew the first derivative of the spline at each point.

1 3 −6 3 0   P2 
Q ( t ) = t 3 t 2 t 1  
  6  −3 0 3 0   P3 
  
1 4 1 0   P4 

What are the V and W control points in terms of Cs and Ds?


37 38

Derivatives at the endpoints Finding the derivatives


Now what we need to do is solve for the derivatives. To do
this we’ll use the C2 continuity requirement.
Q′(0) = 3(V1 − V0 )
Q′(1 ) = 3(V3 − V2 ) V0 =C0 W0 =C1
Q′′(0) = 6(V0 − 2V1 + V2 ) V1 =C0 + 13 D0 W1 =C1 + 13 D1
Q′′(1 ) = 6(V1 − 2V2 + V3 ) V2 =C1 − 13 D1 W2 =C2 − 13 D2
V3 =C1 W3 =C2
 −1 3 −3 1 V0 
 3 −6 3  V  6 (V 1 − 2 V 2 + V 3 ) = 6 (W 0 − 2 W 1 + W 2 )
Q′′(t ) = [ 6t 2 0 0]    1
 −3 3  V2 
  V  ⇓
1   3
D 0 + 4 D1 + D 2 = 3 (C 2 − C 0 )
In general, the nth derivative at an endpoint depends only on
the n+1 points nearest that endpoint.
39 40
Finding the derivatives, cont. Not quite done yet
Here’s what we’ve got so far: We have two additional degrees of freedom, which we can
nail down by imposing more conditions on the curve.
D0 + 4 D1 + D2 = 3(C2 − C0 )
There are various ways to do this. We’ll use the variant
D1 + 4 D2 + D3 = 3(C3 − C1 ) called natural C2 interpolating splines, which requires the
# second derivative to be zero at the endpoints.
Dm−2 + 4 Dm−1 + Dm = 3(Cm − Cm−2 ) This condition gives us the two additional equations we need.
At the C0 endpoint, it is:

How many equations is this? 6 (V 0 − 2V 1 + V 2 ) = 0


How many unknowns are we solving for?

41 42

Solving for the derivatives Forward elimination


Let’s collect our m+1 equations into a single linear system: First, we eliminate the elements below the diagonal:
2 1   D0   E0 
2 1   D0   3(C1 − C0 )  1 4 1  D  E 
1 4 1   D   3(C − C )     1   1 
   1   2 0   1 4 1   D2   E2 
 1 4 1   D2   3(C3 − C1 )     =  
   =   %   #   # 
% # #  1 4 1  Dm-1   Em-1 
           
 1 4 1  Dm−1  3(Cm − Cm−2 )   1 2   Dm   Em 
     
 1 2  Dm   3(Cm − Cm−1 ) 
2 1   D0   F0 = E0 
It’s easier to solve than it looks. 0 7 / 2 1   D  F = E - (1/ 2)E 
   1   1 1 0

 1 4 1   D2   E2 
We can use forward elimination to zero out everything below the    =  
diagonal, then back substitution to compute each D value.  %   #   # 
 1 4 1  Dm-1   Em-1 
     
43  1 2   Dm   Em  44
Back subsitution C2 interpolating spline
The resulting matrix is upper diagonal: Once we’ve solved for the real Dis, we can plug them in to find our Bézier
control points and draw the final spline:
UD = F

u11 … u1m   D0   F0 
  D  F 
   1   1 
   D2   F2 
   =  
 % #   #   # 
   Dm-1   Fm-1 
     
 umm   Dm   Fm 
We can now solve for the unknowns by back substitution:
umm Dm = Fm Have we lost anything?

um-1m-1 Dm-1 + um-1m Dm = Fm-1


45 46

A third option Catmull-Rom splines


If we’re willing to sacrifice C2 continuity, we can get The math for Catmull-Rom splines is pretty simple:
interpolation and local control.
D0 = C1 − C0
D1 = 12 (C2 − C0 )
Instead of finding the derivatives by solving a system of
continuity equations, we’ll just pick something arbitrary but D2 = 12 (C3 − C1 )
local. #
Dn = Cn − Cn−1
If we set each derivative to be a constant multiple of the
vector between the previous and next controls, we get a
Catmull-Rom spline.

47 48
Catmull-Rom basis matrix

What if we want a closed curve, i.e., a loop?

With Catmull-Rom and B-spline curves, this


 −1 3 −3 1   P1  is easy:

12 −5 4 −1  P2 
 
P1 P2

Q ( t ) = t 3 t 2 t 1
  2  −1 0 1 0   P3 
  
 0 2 0 0   P4  P3

P0

P4

49 50

Curves in Animator Project Curves in Animator Project


In the animator project, you will draw a curve
One of the requirements is to
on the screen:
implement “wrapping” so that
the animation restarts smoothly Q(u) = ( x(u), y(u))
when looping back to the
You will actually treat this curve as:
beginning.
θ (u) = y(u)
This is a lot like making a closed t (u) = x(u)
curve: the calculations for the θ -
Where θ is a variable you want to animate.
coordinate are exactly the same.
We can think of the result as a function:
The t-coordinate is a little θ (t )
trickier: you need to create
You have to apply some constraints to make
“phantom” t-coordinates before
sure that θ(t) actually is a function.
and after the first and last
coordinates. 51 52
Summary
•Enforcing constraints on cubic functions
•The meaning of basis matrix and geometry vector
•General procedure for computing the basis matrix
•Properties of Hermite and Bézier splines
•The meaning of blending functions
•Enforcing continuity across multiple curve segments
•How to display Bézier curves with line segments.
•Meanings of Ck continuities.
•Geometric conditions for continuity of cubic splines.
•Properties of C2 interpolating splines, B-splines, and Catmull-Rom
splines.

53

You might also like