0% found this document useful (0 votes)
27 views11 pages

Smooth 2

The document discusses curve representation in computer graphics and modeling. It introduces Bézier curves, which use polynomials defined by control points to represent smooth curves. The key properties of Bézier curves are explained, including their mathematical definition using Bernstein polynomials and de Casteljau's algorithm for evaluating points on the curve.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views11 pages

Smooth 2

The document discusses curve representation in computer graphics and modeling. It introduces Bézier curves, which use polynomials defined by control points to represent smooth curves. The key properties of Bézier curves are explained, including their mathematical definition using Bernstein polynomials and de Casteljau's algorithm for evaluating points on the curve.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Reading

Required:

Š Angel 12.1-12.3, 12.5.2, 12.6-12.7, 12.9

Optional

Š Bartels, Beatty, and Barsky. An Introduction to


Splines for use in Computer Graphics and
Parametric curves Geometric Modeling, 1987.
Š Farin. Curves and Surfaces for CAGD: A Practical
Guide, 4th ed., 1997.

1 2

Curves before computers Mathematical curve representation

The “loftsman’s spline”: Š Explicit y=f(x)


• what if the curve isn’t a function, e.g., a circle?
Š long, narrow strip of wood or metal
Š shaped by lead weights called “ducks”
Š gives curves with second-order continuity,
usually
Used for designing cars, ships, airplanes, etc.
Š Implicit g(x,y) = 0
But curves based on physical artifacts can’t be
replicated well, since there’s no exact definition of
what the curve is.

Around 1960, a lot of industrial designers were


working on this problem.

Today, curves are easy to manipulate on a computer Š Parametric (x(u),y(u))


and are used for CAD, art, animation, … • For the circle:
x(u) = cos 2πu
y(u) = sin 2πu

3 4
Parametric polynomial curves de Casteljau’s algorithm

We’ll use parametric curves, Q(u)=(x(u),y(u)), where Recursive interpolation:


the functions are all polynomials in the parameter.

n
x(u) = ∑ ak uk
k =0
n
y(u) = ∑ bk uk
k =0

Advantages:

Š easy (and efficient) to compute


Š infinitely differentiable (all derivatives above
the nth derivative are zero)

We’ll also assume that u varies from 0 to 1. What if u=0?


Note that we’ll focus on 2D curves, but the What if u=1?
generalization to 3D curves is completely
straightforward.

5 6

de Casteljau’s algorithm, cont’d Finding Q(u)

Recursive notation: Let’s solve for Q(u):

V01 = (1- u )V0 + uV1


V11 = (1- u )V1 + uV2
V21 = (1- u )V2 + uV3

V02 = (1- u )V01 + uV11


V12 = (1- u )V11 + uV21

Q(u ) = (1- u )V02 + uV12


= (1- u )[(1- u )V01 + uV11 ] + u[(1- u )V11 + uV21 ]
= (1- u )[(1- u ){(1- u )V0 + uV1 } + u{(1- u )V1 + uV2 }] + ...
What is the equation for V01 ? = (1- u )3 V0 + 3u(1- u )2 V1 + 3u2 (1- u )V2 + u3V3

7 8
Finding Q(u) (cont’d) Bernstein polynomials

The coefficients of the control points are a set of


In general, functions called the Bernstein polynomials:
n
⎛ n⎞
Q(u ) = ∑ ⎜ ⎟u i (1− u )n−i Vi
n
Q(u ) = ∑ bi (u )Vi
i =0 ⎝ i ⎠
i =0

where “n choose i” is: For degree 3, we have:


⎛ n⎞ n!
⎜⎝ i ⎟⎠ = (n − i )! i ! b0 (u ) = (1− u )3
b1(u ) = 3u(1− u )2
This defines a class of curves called Bézier curves. b2 (u ) = 3u2 (1− u )

What’s the relationship between the number of b3 (u ) = u3


control points and the degree of the polynomials?
Useful properties on the interval [0,1]:
Š each polynomial has value between 0 and 1
Š sum of all four is exactly 1 (a.k.a., a “partition of
unity”)
These together imply that the curve is generated by
convex combinations of the control points and
therefore lies within the convex hull of those control
points.
9 10

Displaying Bézier curves Adaptive Sampling of Bézier curves

How could we draw one of these things? Suppose the control points are arranged as follows:

How many line segments do you really need to draw?

It would be nice if we had an adaptive algorithm, that


would take into account flatness.

DisplayBezier( V0, V1, V2, V3 )


begin
if ( FlatEnough( V0, V1, V2, V3 ) )
Line( V0, V3 );
else
something;
end;
11 12
Subdivide and conquer Testing for flatness

DisplayBezier( V0, V1, V2, V3 )


Compare total length of control polygon to length of
begin line connecting endpoints:
if ( FlatEnough( V0, V1, V2, V3 ) )
Line( V0, V3 );
else V0 − V1 + V1 − V2 + V2 − V3
Subdivide(V[]) ⇒ L[], R[]
< 1+ ε
V0 − V3
DisplayBezier( L0, L1, L2, L3 );
DisplayBezier( R0, R1, R2, R3 );
end;
13 14

Curve desiderata Local control

Bézier curves offer a fairly simple way to model One problem with Béziers is that every control point
parametric curves. affects every point on the curve (except the
endpoints).
But, let’s consider some general properties we would
like curves to have… Moving a single control point affects the whole
curve!

We’d like to have local control, that is, have each


control point affect some well-defined neighborhood
around that point.
15 16
Interpolation Continuity

Bézier curves are approximating. The curve does We want our curve to have continuity: there
not (necessarily) pass through all the control points. shouldn’t be any abrupt changes as we move along
Each point pulls the curve toward it, but other points the curve.
are pulling as well.
“0th order” continuity would mean that curve doesn’t
jump from one place to another.

We’d like to have a curve that is interpolating, that We can also look at derivatives of the curve to get
is, that always passes through every control point. higher order continuity.

17 18

1st and 2nd Derivative Continuity Cn (Parametric) Continuity

First order continuity implies continuous first In general, we define Cn continuity as follows:
derivative:
dQ(u ) Q(u ) is C n continuous
Q '(u ) =
du iff
i
Let’s think of u as “time” and Q(u) as the path of a d Q( u )
Q ( i ) (u ) = is continuous for 0 ≤ i ≤ n
particle through space. What is the meaning of the du i
first derivative, and which way does it point?
Note: these are nested degrees of continuity:

C-1: C0:

Second order continuity means continuous second


derivative:
d 2 Q( u )
Q ''(u ) = C1, C2 : C3, C4, …:
du2
What is the intuitive meaning of this derivative?

19 20
Reparameterization Arc length parameterization

We have so far been considering parametric We can reparameterize a curve so that equal steps in
continuity, derivatives w.r.t. the parameter u. parameter space (we’ll call this new parameter “s”)
map to equal distances along the curve:
This form of continuity makes sense particularly if we
really are describing a particle moving over time and
want its motion (e.g., velocity and acceleration) to be Q( s ) ⇒ Δs = s2 − s1 = arclength [ Q( s1 ), Q( s2 )]
smooth.

But, what if we’re thinking only in terms of the shape We call this an arc length parameterization. We can
of the curve? Is the parameterization actually re-write the equal step requirement as:
intrinsic to the shape, i.e., is it the case that a shape
has only one parameterization? arclength[ Q( s1 ), Q( s2 )]
=1
s2 − s1

Looking at very small steps, we find:

arclength[ Q( s1 ), Q( s2 )] dQ( s )
lim = =1
s2 → s1 s2 − s1 ds

21 22

Gn (Geometric) Continuity Gn Continuity (cont’d)


Now, we define geometric Gn continuity as follows: The second derivative now has a specific geometric
interpretation. First, the “osculating circle” at a point on
a curve can be defined based on the limit behavior of
Q( s ) is G n continuous
three points moving toward each other:
iff
i
d Q( s ) O( s1 , s2 , s3 )
Q( i ) ( s) = is continuous for 0 ≤ i ≤ n
ds i O( s )
c
Where Q(s) is parameterized by arc length. Q( s1 ) r
The first derivative still points along the tangent, but
Q( s2 ) Q( s3 ) Q( s )
its length is always 1.
O( s ) = lim O( s1 , s2 , s3 )
Gn continuity is usually a weaker constraint than Cn s1, s2 , s3 → s
continuity (e.g., “speed” along the curve does not
matter). The second derivative Q’’(s) then has these properties:

1
Q′′( s ) = κ ( s ) = Q′′( s ) ∼ c( s ) − Q( s )
r( s)

where r(s) and c(s) are the radius and center of O(s),
respectively, and κ(s) is the “curvature” of the curve at s.

We’ll focus on Cn (i.e., parametric) continuity of curves


for the remainder of this lecture.
23 24
Bézier curves Æ splines Ensuring C0 continuity

Bézier curves have C-infinity continuity on their Suppose we have a cubic Bézier defined by
interiors, but we saw that they do not exhibit local (V0,V1,V2,V3), and we want to attach another curve
control or interpolate their control points. (W0,W1,W2,W3) to it, so that there is C0 continuity at
the joint.
It is possible to define points that we want to
interpolate, and then solve for the Bézier control C 0 : QV (1) = QW (0)
points that will do the job.
What constraint(s) does this place on (W0,W1,W2,W3)?
But, you will need as many control points as
interpolated points -> high order polynomials ->
wiggly curves. (And you still won’t have local
control.)

Instead, we’ll splice together a curve from individual


Béziers segments, in particular, cubic Béziers.

We call these curves splines.

The primary concern when splicing cuves together is


getting good continuity at the endpoints where they
meet…

25 26

The C0 Bezier spline 1st derivatives at the endpoints

How then could we construct a curve passing For degree 3 (cubic) curves, we have already shown
through a set of points P1…Pn? that we get:

Q(u ) = (1- u )3 V0 + 3u(1- u )2 V1 + 3u2 (1- u )V2 + u3V3

We can expand the terms in u and rearrange to get:

Q(u ) = ( −V0 + 3V1 − 3V2 + V3 )u3 +


(3V0 − 6V1 + 3V2 )u2 + ( −3V0 + 3V1 )u + V0

What then is the first derivative when evaluated at


each endpoint, u=0 and u=1?

Q′(0) =

We call this curve a spline. The endpoints of the


Q′(1) =
Bezier segments are called joints.

In the animator project, you will construct such a


curve by specifying all the Bezier control points
directly.

27 28
Ensuring C1 continuity The C1 Bezier spline

Suppose we have a cubic Bézier defined by How then could we construct a curve passing
(V0,V1,V2,V3), and we want to attach another curve through a set of points P0…Pn?
(W0,W1,W2,W3) to it, so that there is C1 continuity at
the joint.

⎧Q (1) = QW (0)
C 1 : ⎨ V'
⎩QV (1) = QW (0)
'

What constraint(s) does this place on (W0,W1,W2,W3)?

We can specify the Bezier control points directly, or


we can devise a scheme for placing them
automatically…

29 30

Catmull-Rom splines Catmull-Rom to Beziers

If we set each derivative to be one half of the vector We can write the Catmull-Rom to Bezier
between the previous and next controls, we get a transformation as:
Catmull-Rom spline.
⎡V0T ⎤ ⎡ 0 1 0 0 ⎤ ⎡ P0T ⎤
⎢ T⎥ ⎢ ⎢ ⎥
0 ⎥ ⎢ P1T ⎥
This leads to:
⎢V1 ⎥ = ⎢ −1/ 6 1 1/ 6 ⎥
⎢V2T ⎥ ⎢ 0 1/ 6 1 −1/ 6 ⎥ ⎢ P2T ⎥
V0 = P1 ⎢ T⎥ ⎢ ⎥⎢ ⎥
⎢⎣V3 ⎥⎦ ⎣ 0 0 1 0 ⎦ ⎢⎣ P3T ⎥⎦
V1 = P1 + 61 ( P2 - P0 )
V2 = P2 - 61 ( P3 - P1 ) V = MCatmull-RomP
V3 = P2

31 32
Endpoints of Catmull-Rom splines Tension control

We can see that Catmull-Rom splines don’t We can give more control by exposing the derivative
interpolate the first and last control points. scale factor as a parameter:

By repeating those control points, we can force V0 = P1


interpolation. V1 = P1 + τ3 ( P2 - P0 )
V2 = P2 - τ3 ( P3 - P1 )
V3 = P2

The parameter τ controls the tension. Catmull-Rom


uses τ = 1/2. Here’s an example with τ =3/2.

33 34

2nd derivatives at the endpoints Ensuring C2 continuity

Finally, we’ll want to develop C2 splines. To do this, Suppose we have a cubic Bézier defined by
we’ll need second derivatives of Bezier curves. (V0,V1,V2,V3), and we want to attach another curve
(W0,W1,W2,W3) to it, so that there is C2 continuity at
Taking the second derivative of Q(u) yields: the joint.
⎧QV (1) = QW (0)
Q′′(0) = 6(V0 - 2V1 + V2 ) ⎪
C : ⎨QV' (1) = QW' (0)
2

= -6[(V1 - V0 ) + (V1 - V2 )] ⎪Q '' (1) = Q '' (0)


Q′′(1) = 6(V1 - 2V2 + V3 )
⎩ V W

= -6[(V2 - V3 ) + (V2 - V1 )] What constraint(s) does this place on (W0,W1,W2,W3)?

35 36
Building a complex spline B-splines

Instead of specifying the Bézier control points Here is the completed B-spline.
themselves, let’s specify the corners of the A-frames
in order to build a C2 continuous spline.

What are the Bézier control points, in terms of the de


Boor points?

V0 = ____[____ B0 + ____ B1 ]
+ ____[____ B1 + ____ B2 ]
= ____ B0 + ____ B1 + ____ B2
V1 = ____ B1 + ____ B2
V2 = ____ B1 + ____ B2
These are called B-splines. The starting set of points V3 = ____ B1 + ____ B2 + ____ B3
are called de Boor points.
37 38

B-splines to Beziers Endpoints of B-splines


We can write the B-spline to Bezier transformation as: As with Catmull-Rom splines, the first and last control
points of B-splines are generally not interpolated.

⎡V0T ⎤ ⎡1/ 6 2 / 3 1/ 6 0 ⎤ ⎡ B0T ⎤ Again, we can force interpolation by repeating the


⎢ T⎥ ⎢ ⎢ ⎥
2 / 3 1/ 3 0 ⎥ ⎢ B1T ⎥
endpoints…twice.
⎢V1 ⎥ = ⎢ 0 ⎥
⎢V2T ⎥ ⎢ 0 1/ 3 2 / 3 0 ⎥ ⎢ B2T ⎥
⎢ T⎥ ⎢ ⎥⎢ ⎥
⎢⎣V3 ⎥⎦ ⎣ 0 1/ 6 2 / 3 1/ 6 ⎦ ⎢⎣ B3T ⎥⎦

V = MB-splineB

39 40
Closing the loop Curves in the animator project

What if we want a closed curve, i.e., a loop? In the animator project, you will draw a curve on the
screen:
With Catmull-Rom and B-spline curves, this is easy:
Q(u ) = ( x (u ), y (u ) )

You will actually treat this curve as:

θ (u ) = y (u )
t (u ) = x ( u )

Where θ is a variable you want to animate. We can


think of the result as a function:

θ (t )

In general, you have to apply some constraints to


make sure that θ(t) actually is a function.

41 42

Summary

What to take home from this lecture:

Š Geometric and algebraic definitions of Bézier


curves.
Š Basic properties of Bézier curves.
Š How to display Bézier curves with line
segments.
Š Meanings of Ck continuities.
Š Geometric conditions for continuity of cubic
splines.
Š Properties of B-splines and Catmull-Rom
splines.
Š Geometric construction of B-splines and
Catmull-Rom splines.
Š How to construct closed loop splines.

43

You might also like