Sie sind auf Seite 1von 39

- 1 -

Chapter 4 Representations of Curves and Surfaces



4.1 Parametric Representation and Continuity Conditions of Curves
and Surfaces
4.1.1 Parametric Representation of Curves and Surfaces
In drafting terminology, a spline is a flexible strip used to produce a smooth curve through
a designated set of points. Several small weights are distributed along the length of the strip to
hold it in position on the drafting table as the curve is drawn. The term spline curve originally
referred to a curve drawn in this manner. We can mathematically describe such a curve with a
piecewise* cubic polynomial function whose first and second derivatives are continuous across
the various curve sections. In computer graphics, the term spline curve now refers to any
composite curve formed with polynomial sections satisfying specified continuity conditions at
the boundary of the pieces. A spline surface can be described with two sets of orthogonal spline
curves. There are several different kinds of spline specifications that are used in graphics
applications. Each individual specification simply refers to a particular type of polynomial with
certain specified boundary conditions.
Splines are used in graphics applications to design curve and surface shapes, to digitize
drawings for computer storage, and to specify animation paths for the objects or the camera in a
scene. Typical CAD applications for splines include the design of automobile bodies, aircraft
and spacecraft surfaces, and ship hulls.
If u is used as a parameter, a spline in 2D space is described with a set of parametric
coordinate functions of the form
x = x(u), y = y(u) u[0, 1] (4-1)
A point function on the spline in 2D space can be expressed as
P(u) = [x(u), y(u)] (4-2)
Similarly, a spline in 3D space is described with a set of parametric coordinate functions of
the form
x = x(u), y = y(u), z = z(u) u[0, 1] (4-3)
A point function on the spline in 3D space can be expressed as
P(u)= [x(u) , y(u), z(u)] (4-4)
As for a surface, if u and v are used parameters, the parametric equation of the 2D surface is
represented by the form
x = x(u, w) , y = y(u, w) u, w[0, 1] (4-5)
A point function on the surface can be expressed as
P(u, w) = [x(u, w) , y(u, w)] (4-6)
The parametric equation of the 3D surface is
x = x(u, w) , y = y(u, w) , z = z(u, w) u, w[0, 1] (4-7)
A point function on the 3D surface is
P(u, w) = [x(u, w) , y(u, w), z(u, w)] (4-8)
4.1.2 Interpolation and Approximation Splines
We specify a spline curve by giving a set of coordinate positions, called control points,
which indicates the general shape of the curve. These control points are then fitted with
piecewise continuous parametric polynomial functions in one of two ways. When polynomial
sections are fitted so that the curve passes through each control point, as in Fig. 4-1, the resulting
curve is said to interpolate the set of control points. On the other hand, when the polynomials are
fitted to the general control-point path without necessarily passing through any control point, the
resulting curve is said to approximate the set of control points (Fig. 4-2).

Figure 4-1
A set of six
control points
interpolated
with piecewise
continuous
Figure 4-2
A set of six control points
approximated with piecewise
continuous polynomial sections.
polynomial
sections.


Figure 4-3
An approximation spline surface for a
CAD application in automotive design.
Surface contours are plotted with
polynomial curve sections, and the
surface control points are connected
with straight-line segments. (Courtesy
of Evans Sutherland.)

- 2 -
Interpolation curves are commonly used to digitize drawings or to specify animation paths.
Approximation curves are primarily used as design tools to structure object surfaces Figure 4-3
shows an approximation spline surface created for a design application. Straight lines connect
the control-point positions above the surface.
A spline curve is defined, modified, and manipulated with operations on the control points.
By interactively selecting spatial* positions for the control points, a designer can set up an initial
curve. After the polynomial fit is displayed for a given set of control points, the designer can
then reposition some or all of the control points to restructure the shape of the curve. In addition,
the curve can be translated, rotated*, or scaled with transformations applied to the control points.
CAD packages can also insert extra control points to aid a designer in adjusting the curve
shapes.
The convex polygon boundary that encloses a set of control points is called the convex*
hull. One way to envision the shape of a convex hull is to imagine a rubber band stretched
around the positions of the control points so that each control point is either on the perimeter* of
the hull or inside it (Fig. 4-4). Convex hulls provide a measure for the deviation of a curve or
surface from the region bounding the control points. Some splines are bounded by the convex
hull, thus ensuring that the polynomials smoothly follow the control points without erratic
oscillations*. Also, the polygon region inside the convex hull is useful in some algorithms as a
clipping region.

Figure 4-4
Convex-hull shapes (dashed lines) for two sets of control points.

A polyline connecting the sequence of control points for an approximation spline is usually
displayed to remind a designer of the control-point ordering. This set of connected line segments
is often referred to as the control graph of the curve. Other names for the series of straight-line
sections connecting the control points in the order specified are control polygon and
characteristic polygon. Figure 4-5 show the shape of the control graph for the control-point
sequences in Fig. 4-4.
- 3 -
Figure 4-5
Control-graph shapes (dashed lines) for two different sets of
control points.

4.1.3 Continuity Conditions
Parametric Continuity Conditions
To ensure a smooth transition from one section of a piecewise parametric curve to the next,
we can impose various continuity conditions at the connection points. If each section of a
spline is described with a set of parametric coordinate functions of the form
x = x(u), y = y(u), z = z(u), u
1
u u
2
(4-9)
we set parametric continuity by matching the parametric derivatives* of adjoining curve sections
at their common boundary.
Zero-order parametric continuity, described as C
0
continuity, means simply that the curves
meet. That is, the values of x, y, and z evaluated at u, for the first curve section are equal,
respectively, to the values of x, y, and z evaluated at u, for the next curve section. First-order
parametric continuity, referred to as C
1
continuity, means that the first parametric derivatives
(tangent lines) of the coordinate functions in Eq. 4-9 for two successive curve sections are equal
at their joining point. Second-order parametric continuity, or C
2
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. Figure 4-6 shows examples
of C
0
, C
1
, and C
2
continuity.
With second-order continuity the rates of change of the tangent vectors for connecting
sections are equal at their intersection. Thus, the tangent line transitions smoothly from one
section of the curve to the next (Fig. 4-6(c)). But with first-order continuity, the rates of change
of the tangent vectors for the two sections can be quite different (Fig. 4-6(b)), so that the general
shapes of the two adjacent sections can change abruptly, First-order continuity is often sufficient
for digitizing drawings and some design applications, while second-order continuity is useful for
setting up animation paths for camera motion and for many precision CAD requirements A
- 4 -
camera traveling along the curve path In Fig. 4-6(b) with equal steps in parameter u would
experience an abrupt change in acceleration at the boundary of the two sections, producing a
discontinuity in the motion sequence. But if the camera were traveling along the path in Fig.
4-6(c), the frame sequence for the motion would smoothly transition across the boundary.

- 5 -

Figure 4-6
Piecewise construction
of a curve by joining
two curve segments
using different orders
of continuity:
(a) zero-order
continuity only,
(b) first-order
continuity, and
(c) second-order
continuity.

Geometric Continuity Conditions
An alternate method for joining two successive curve sections is to specify conditions for
geometric continuity. In this case, we only require parametric derivatives of the two sections to
be proportional to each other at their common boundary instead of equal to each other.
Zero-order geometric continuity, described as G
0
continuity, is the same as zero-order
parametric continuity. That is, the two curves sections must have the same coordinate position at
the boundary point. First-order geometric continuity, or G
1
continuity, means that the parametric
first derivatives are proportional at the intersection of two successive sections. If we denote* the
parametric position on the curve as P(u) , the direction of the tangent vector P'(u), but not
necessarily its magnitude, will be the same for two successive curve sections at their joining
point under G
1
continuity. Second-order geometric continuity, or G
2
continuity, means that both
the first and second parametric derivatives of the two curve sections are proportional at their
boundary. Under G
2
continuity, curvatures* of two curve sections will match at the joining
position.
A curve generated with geometric continuity conditions is similar to one generated with
parametric continuity, but with slight differences in curve shape. Figure 4-7 provides a
comparison of geometric and parametric continuity. With geometric continuity, the curve is
pulled toward the section with the greater tangent vector.

Figure 4-7
Three control points fitted with two curve sections joined with (a) parametric
continuity and (b) geometric continuity, where the tangent vector of curve C
3
at
oint P
1
, has a greater magnitude than the tangent vector of curve C
1
at P
1
. p


4.2 Hermite Curves
4.2.1 Spline Specifications
There are three equivalent methods for specifying a particular spline representation: (1) We
can state the set of boundary conditions that are imposed on the spline; or (2) we can state the
matrix that characterizes the spline; or (3) we can state the set of blending functions (or basis
functions) that determine how specified geometric constraints on the curve are combined to
calculate positions along the curve path.
To illustrate these three equivalent specifications, suppose we have the following
parametric cubic polynomial representation for the x coordinate along the path of a spline
section:
x(u) = a
x
u
3
+ b
x
u
2
+ c
x
u + d
x
, 0 u 1 (4-10)
Boundary conditions for this curve might be set, for example, on the endpoint coordinates x(0)
and x(1) and on the parametric first derivatives at the endpoints x'(0) and x'(1) . These four
boundary conditions are sufficient to determine the values of the four coefficients a
x
, b
x
, c
x
, and
d
x
.
From the boundary conditions, we can obtain the matrix that characterizes this spline curve
by first rewriting Eq. 4-10 as the matrix product
[ ] C U
d
c
b
a
u u u u x
x
x
x
x
=

= 1 ) (
2 3
(4-11)
where U is the row matrix of powers of parameter u, and C is the coefficient* column matrix.
Using Eq.4-11, we can write the boundary conditions in matrix form and solve for the
coefficient matrix C as
- 6 -
geom spline
M M C =
(4-12)
where M
geom
is a four-element column matrix containing the geometric constraint values
(boundary conditions) on the spline; and M
spline
is the 4-by-4 matrix that transforms the
geometric constraint values to the polynomial coefficients and provides a characterization for the
spline curve. Matrix M
geom
contains control-point coordinate values and other geometric
constraints that have been specified. Thus, we can substitute the matrix representation for C into
Eq. 4-11 to obtain
- 7 -
geom spline
M M U u x = ) (
(4-13)
The matrix, M
spline
characterizing a spline representation, sometimes called the basis matrix, is
particularly useful for transforming from one spline representation to another.
Finally, we can expand Eq. 4-13 to obtain a polynomial representation for coordinate x in
terms of the geometric constraint parameters

=
=
3
0
) ( ) (
k
k k
u BF g u x
(4-14)
where g
k
are the constraint parameters, such as the control-point coordinates and slope of the
curve at the control points, and BF
k
(u) are the polynomial blending functions. In the following
sections, we discuss some commonly used splines and their matrix and blending-function
specifications.
4.2.2 Cubic Spline Interpolation Methods
This class of splines is most often used to set up paths for object motions or to provide a
representation for an existing object or drawing, but interpolation splines are also used
sometimes to design object shapes. Cubic polynomials offer a reasonable compromise between
flexibility and speed of computation. Compared to higher-order polynomials, cubic splines
require less calculations and memory and they are more stable. Compared to lower-order
polynomials, cubic splines are more flexible for modeling arbitrary curve shapes.
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. Suppose
we have n+1 control points specified with coordinates
p
k
= (x
k
, y
k
, z
k
), k = 0, 1, 2, , n

Figure 4-8
A piecewise continuous cubic-spline interpolation of n + 1 control points.


A cubic interpolation fit of these points is illustrated in Fig. 4-8. We can describe the
parametric cubic polynomial that is to be fitted between each pair of control points with the
following set of equations:
x(u) = a
x
u
3
+ b
x
u
2
+ c
x
u + d
x
y(u) = a
y
u
3
+ b
y
u
2
+ c
y
u + d
y
( 0 u 1 ) (4-15)
z(u) = a
z
u
3
+ b
z
u
2
+ c
z
u + d
z
For each of these three equations, we need to determine the values of the four coefficients a, b, c,
and d in the polynomial representation for each of the n curve sections between the n + 1 control
points. We do this by setting enough boundary conditions at the "joints" between curve sections
so that we can obtain numerical values for all the coefficients. In the following sections, we
discuss common methods for setting the boundary conditions for cubic interpolation splines.

4.2.3 Hermite Interpolation
A Hemite spline (named after the French mathematician Charles Hermite) is an
interpolating piecewise cubic polynomial with a specified tangent at each control point.

Figure 4-9
Parametric point function P(u) for a Hermite curve
section between control point p
k
and p
k+1
.

If P(u) represents a parametric cubic point function for the curve section between control
points p
k
and p
k+1
, as shown in Fig. 4-9, then the boundary conditions that define this Hermite
curve section are
P(0) = p
k
P(1) = p
k+1
P(0) = Dp
k
(4-16)
P(1) = Dp
k+1
with Dp
k
and Dp
k+1
, specifying the values for the parametric derivatives (slope of the curve) at
control points p
k
and p
k+1
, respectively.
- 8 -
We can write the vector equivalent of Eqs. 4-15 for this Hermite-curve section as
P(u) = au
3
+ bu
2
+cu + d, 0

u 1 (4-17)
where the x component of P is x(u) = a
x
u
3
+ b
x
u
2
+ c
x
u + d
x
, and similarly for the y and z
components. The matrix equivalent of Eq. 4-17 is
(4-18) [ ]

=
d
c
b
a
u u u u P 1 ) (
2 3
and the derivative of the point function can be expressed as
(4-19) [ ]

=
d
c
b
a
u u u P 0 1 2 3 ) (
2
Substituting endpoint values 0 and 1 for parameter u into the previous two equations, we can
express the Hermite boundary conditions 4-16 in the matrix form:
(4-20)

+
+
d
c
b
a
Dp
Dp
p
p
k
k
k
k
0 1 2 3
0 1 0 0
1 1 1 1
1 0 0 0
1
1
Solving this equation for the polynomial coefficients, we have

+
+
+
+
+
+

1
1
1
1
1
1
1
0 0 0 1
0 1 0 0
1 2 3 3
1 1 2 2
0 1 2 3
0 1 0 0
1 1 1 1
1 0 0 0
k
k
k
k
H
k
k
k
k
k
k
k
k
Dp
Dp
p
p
M
Dp
Dp
p
p
Dp
Dp
p
p
d
c
b
a
(4-21)
- 9 -
where M
H
, the Hermite matrix, is the inverse of the boundary constraint matrix. Equation 4-18
can thus be written in terms of the boundary conditions as
[ ]

=
+
+
1
1 2 3
1 ) ( P
k
k
k
k
H
Dp
Dp
p
p
M u u u u (4-22)
Finally, we can determine expressions for the Hermite blending functions by carrying out
the matrix multiplications in Eq. 4-22 and collecting coefficients for the boundary constraints to
obtain the polynomial form:
P(u) = p
k
(2u
3
3u
2
+ 1) + p
k+1
(-2u
3
+ 3u
2
) + Dp
k
(u
3
2u
2
+ u) + Dp
k+1
(u
3
u
2
)
= p
k
H
0
(u) + p
k+1
H
1
(u) + Dp
k
H
2
(u) + Dp
k+1
H
3
(u) (4-23)
The polynomials H
k
(u) for k = 0, 1, 2, 3 are referred to as blending functions because they
blend the boundary constraint values (endpoint coordinates and slopes) to obtain each coordinate
position along the curve. Figure 4-10 shows the shape of the four Hermite blending functions.

Figure 4-10
The Hermite blending functions.


Hermite polynomials can be useful for some digitizing applications where it may not be too
difficult to specify or approximate the curve slopes. But for most problems in computer graphics,
- 10 -
it is more useful to generate spline curves without requiring input values for curve slopes or
other geometric information, in addition to control-point coordinates. Cardinal splines, discussed
in the following section, are variations on the Hermite splines that do not require input values for
the curve derivatives at the control points. Procedures for these splines compute parametric
derivatives from the coordinate positions of the control points.

The data of Hermit Curves:
arry1[9][2]={100,300,120,200,220,200,270,100,370,100,420,200,420,300,220,280,100,300};


Programs:
void CHermitView::Hermit()
{
CClientDC dc(this);
CPen pen1,pen2;
pen1.CreatePen(PS_SOLID,2,RGB(255,0,255));
pen2.CreatePen(PS_SOLID,3,RGB(0,0,0));
int a1[9][2]={100,300,120,200,220,200,270,100,370,100,420,200,420,300,220,280,100,300};
int a2[9][2]={70,-70,70,-70,70,-70,70,-70,70,70,70,70,-70,70,-70,70,70,-70};
for(int i=0;i<8;i++)
{
- 11 -
dc.SelectObject(&pen1);
dc.MoveTo(a1[i][0],a1[i][1]);
dc.LineTo(a1[i+1][0],a1[i+1][1]);
dc.MoveTo(a1[i][0],a1[i][1]);
for(double u=0;u<1;u=u+0.01)
{
double x,y;
x=(2*u*u*u-3*u*u+1)*a1[i][0]+(-2*u*u*u+3*u*u)*a1[i+1][0]
+(u*u*u-2*u*u+u)*a2[i][0]+(u*u*u-u*u)*a2[i+1][0];
y=(2*u*u*u-3*u*u+1)*a1[i][1]+(-2*u*u*u+3*u*u)*a1[i+1][1]
+(u*u*u-2*u*u+u)*a2[i][1]+(u*u*u-u*u)*a2[i+1][1];
dc.SelectObject(&pen2);
dc.LineTo(x,y);
Sleep(20);
}
dc.SelectObject(&pen1);
}
pen1.DeleteObject();
pen2.DeleteObject();
}

4.2.4 Cardinal Splines
As with Hermite splines, cardinal splines are interpolating piecewise cubics with specified
endpoint tangents at the boundary of each curve section. The difference is that we do not have to
give the values for the endpoint tangents. For a cardinal spline, the value for the slope at a
control point is calculated from the coordinates of the two adjacent control points.

Figure 4-12
Tangent vectors at the endpoints
of a cardinal-spline section are
Figure 4-11
Parametric point function P(u)
for a cardinal-spline section
between control points p
k
and
p
k+1
.
p

roportional to the chords formed
with neighboring control points
(dashed lines).
- 12 -
A cardinal spline section is completely specified with four consecutive control points. The
middle two control points are the section endpoints, and the other two points are used in the
calculation of the endpoint slopes. If we take P(u) as the representation for the parametric cubic
point function for the curve section between control points p
k
and p
k+1
, as in Fig. 4-11, then the
four control points from p
k-1
, to p
k+1
, are used to set the boundary conditions for the cardinal
spline section as
P(0) = p
k
P(1) = p
k+1
P(0) =1/2(1 t)(p
k+1
p
k-1
)

(4-24)
P(1) = 1/2(1 t)(p
k+2
p
k
)

Figure 4-13
Effect of the tension parameter on the shape
of a cardinal spline section.


Thus, the slopes at control points p
k
and p
k+1
, are taken to be proportional, respectively, to the
chords
1 1 + k k
p p , and
2 + k k
p p (Fig. 4-12). Parameter t is called the tension parameter since it
controls how loosely or tightly the cardinal spline fits the input control points. Figure 4-13
illustrates the shape of a cardinal curve for very small and very large values of tension t. When t
= 0, this class of curves is referred to as Catmull-Rom splines, or Overhauser splines.
Using methods similar to those for Hermite splines, we can convert the boundary
conditions 4-24 into the matrix form
(4-25) [ ]

=
+
+

2
1
1
2 3
1 ) ( P
k
k
k
k
C
p
p
p
p
M u u u u
- 13 -
where the cardinal matrix is
(4-26)



=
0 0 1 0
0 0
2 3 3 2
2 2
s s
s s s s
s s s s
M
C
with s = (1 - t) / 2.

- 14 -


nding matrix equation 4-25 into polynomial form, we have
k-1 k
k+1 k+2
2
) (4-27)
k-1 0 k 1 k+1 2 k+2 3
whe blending functions. Figure
Figure 4-14
The cardinal blending functions for t = 0 and s = 0.5
Expa
P(u) = p ( su
3
+ 2su
2
su) + p [(2 s)u
3
+ (s 3)u
2
+ 1]
+ p [(s 2)u
3
+ (3 2s)u
2
+ su)] + p (su
3
su
= p CAR (u) + p CAR (u) + p CAR (u) + p CAR (u)
re the polynomials CAR
k
(u) for k = 0, 1, 2, 3 are the cardinal
4-14 gives a plot of the basis functions for cardinal splines with t = 0.

- 15 -
The data of Cardinal Splines
220,200,270,100,370,100,420,200,420,300,220,280,100,300};

arry1[9][2]={100,300,120,200,



4.3 Bezier Curves and Surfaces
eveloped by the French engineer Pierre Bezier for
use i
urve section can be fitted to any number of control points. The number
of c
This spline approximation method was d
n the design of Renault automobile bodies. Bezier* splines have a number of properties that
make them highly useful and convenient for curve and surface design. They are also easy to
implement. For these reasons, Bezier splines are widely available in various CAD systems, in
general graphics packages (such as GL on Silicon Graphics systems), and in assorted drawing
and painting packages (such as Aldus SuperPaint and Cricket Draw).
4.3.1 Bezier Curves
In general, a Bezier c
ontrol points to be approximated and their relative position determine the degree of the
Bezier polynomial. As with the interpolation splines, a Bezier curve can be specified with
boundary conditions, with a characterizing matrix, or with blending functions. For general
Bezier curves, the blending-function specification is the most convenient.
- 16 -
with k varying from 0
to n
k
n k k
0
,
The Bezier blending functions BEZ
k,n
(u) are the Bernstein polynomials:
= ) 1 ( ) , ( ) (
,
where the C(n, k) are the binomial coefficients:
Suppose we are given n + 1 control-point positions: p
k
= (x
k
, y
k
, z
k
),
. These coordinate points can be blended to produce the following position vector P(u),
which describes the path of an approximating Bezier polynomial function between p
0
and p
n
.

=
n
u BEZ p u P ), ( ) (
0 u 1 (4-28)
=
k n k
(4-29)
n k
u u k n C u BEZ

)! ( !
! n
(4-30)
) , (
k n k
k n C

=
Vector equation 4-28 represents a set of three parametric equations for the individual curve
(4-31)


Figure 4-15
Examples of two-dimensional Bezier curves generated from three, four, and
five control points. Dashed lines connect the control-point positions.
coordinates:

=
=
=
=
=
=
n
k
n k k
n
k
n k k
n
k
n k k
u BEZ z u z
u BEZ y u y
u BEZ x u x
0
,
0
,
0
,
) ( ) (
) ( ) (
) ( ) (

- 17 -
As a rule, a Bezier curve is a polynomial of degree one less than the number of control
points used: Three points generate a parabola*, four points a cubic curve, and so forth. Figure
4-15 demonstrates the appearance of some Bezier curves for various selections of control points
in the xy plane (z = 0). With certain control-point placements, however, we obtain degenerate
Bezier polynomials. For example, a Bezier curve generated with three collinear control points is
a straight-line segment. And a set of control points that are all at the same coordinate position
produces a Bezier "curve" that is a single point.
Bezier curves are commonly found in painting and drawing packages, as well as CAD
systems, since they are easy to implement and they are reasonably powerful in curve design.
Efficient methods for determining coordinate positions along a Bezier curve can be set up using
recursive calculations. For example, successive binomial coefficients can be calculated as
) 1 , (
1
) , (
+
= k n C
k
k n
k n C
(4-32)
for n k.
.3.2 Properties of Bezier Curves
ier curve is that it always passes through the first and last
contro
(4-33)
s of a Bezier curve at the endpoints can he
calcu
(4-34)
rve is along the line joining the first two control
points,

n
)] (4-35)
within the convex hull
(conv
k 0
so that any curve position is simply the weighted sum of the control-point positions. The

4
A very useful property of a Bez
l points. That is, the boundary conditions at the two ends of the curve are
P(0) = p
0
P(1) = p
n

Values of the parametric first derivative
lated from control-point coordinates as
P'(0) = -np
0
+ np
1
P'(1) = -np
n-1
+ np
n
Thus, the slope at the beginning of the cu
and the slope at the end of the curve is along the line joining the last two endpoints.
Similarly, the parametric second derivatives of a Bezier curve at the endpoints are calculated as
P''(0) = -n(n-1)[(p
2
-p
1
)-(p
1
-p
0
)]
P''(1) = -n(n-1)[(p
n-2
-p
n-1
)-(p
n-1
-p
Another important property of any Bezier curve is that it lies
ex polygon boundary) of the control points. This follows from the properties of Bezier
blending functions: They are all positive and their sum is always 1,

=
n
n k
u BEZ
,
1 ) (
(4-36)
=
- 18 -
convex-hull property for a Bezie e polynomial smoothly follows the
control points without erratic oscillations.


4.3.3 Design Techniques Using Bezier Curves
Closed Bezier curves are generated by specifying the first and last control points at the
e position, as in the example shown in Fig. 4-16. Also, specifying multiple control points at
that position. In Fig. 4-17, a single coordinate
posi

r curve ensures that th

sam
a single coordinate position gives more weight to
tion is input as two control points, and the resulting curve is pulled nearer to this position.

Figure 4-18
Piecewise approximation curve formed with two Bezier sections. Zero-order and
first-order continuity are attained between curve sections by setting p'
0
= p
2
and
by making points p
1
, p
2
, and p'
1
collinear.
Figure 4-16
A closed Bezier curve generate
Figure 4-17
A Bezier curve can be made to pass
closer to a given coordinate position
d
by specifying the first and last
control point at the same
l
by assigning multiple control points
to that position.
ocation.
- 19 -
We can fit a Bezier curve to any number of control points, but this requires the calculation
of polynomial functions of higher degree. When complicated curves are to be generated, they
can be formed by piecing several Bezier sections of lower degree together. Piecing together
smaller sections also gives us better control over the shape of the curve in small regions. Since
Bezier curves pass through endpoints, it is easy to match curve sections (zero-order continuity).
Also, Bezier curves have the important property that the tangent to the curve at an endpoint is
along the line joining that endpoint to the adjacent control point. Therefore, to obtain first-order
continuity between curve sections, we can pick control points p'
0
and p'
1
of a new section to be
along the same straight line as control points p
n-1
, and p
n
, of the previous section (Fig. 4-18).
When the two curve sections have the same number of control points, we obtain C
1

continuity by choosing the first control point of the new section as the last control point of the
previous section and by positioning the second control point of the new section at position
p
n
+ (p
n
p
n-1
)
Thus,
4.3.4
ials.
ted with four control points. The four blending functions for
are

) = 3u(1 u)
(4-37)


nly nonzero blending function is
1. At u = 1, the only nonzero function is BEZ
3,3
with a value of 1 at
that
the three control points are collinear and equally spaced.
We obtain C
2
continuity between two Bezier sections by calculating the position of the third
control point of a new section in terms of the positions of the last three control points of the
previous section as
p
n-2
+ 4(p
n
p
n-1
)
Requiring second-order continuity of Bezier curve sections can be unnecessarily restrictive. This
is especially true with cubic curves, which have only four control points per section. In this case,
second-order continuity fixes the position of the first three control points and leaves us only one
point that we can use to adjust the shape of the curve segment.
Cubic Bezier Curves
Many graphics packages provide only cubic spline functions. This gives reasonable design
flexibility while avoiding the increased calculations needed with higher-order polynom
Cubic Bezier curves are genera
cubic Bezier curves, obtained by substituting n = 3 into Eq. 4-29
BEZ
0,3
(u) = (1 u)
3
BEZ
1,3
(u
2
BEZ
2,3
(u) = 3u
2
(1 u)
BEZ
3,3
(u) = u
3
Plots of the four cubic Bezier blending functions are given in Fig. 4-19. The form of the
blending functions determines how the control points influence the shape of the curve for values
of parameter u over the range from 0 to 1. At u = 0, the o
BEZ
0,3
, which has the value
point. Thus, the cubic Bezier curve will always pass through control points p
0
, and p
3
. The
other functions, BEZ
1,3
and BEZ
2,3
influence the shape of the curve, at intermediate values of
parameter u, so that the resulting curve tends toward points p
1
and p
2
. Blending function BEZ
l,3

is maximum at u = 1 / 3, and BEZ
2,3
is maximum at u = 2 / 3.
- 20 -


We note in Fig. 4-18 that each of the four blending functions is nonzero over the entire
range of parameter u. Thus, Bezier curves do not allow for local control of the curve shape. If we
decide to reposition any one of the control points, the entire curve will be affected.
At the end positions of the cubic Bezier curve, the parametric first derivatives (slopes) are
P'(0) = 3(p
1
p
0
), P'(1) = 3(p
3
p
2
)
And the parametric second derivatives are
P''(0) = 6(p
0
2p
1
+ p
2
), P''(1) = 6(p
1
2p
2
+ p
3
)
We can use these expressions for the parametric derivatives to construct piecewise curves with
C
1
or C
2
continuity between sections.
By expanding the polynomial expressions for the blending functions, we can write the cubic
Bezier point function in the matrix form

3
0
p
p
Figure 4-19 The four Bezier blending functions for cubic curves (n = 3).
[ ]

=
2
1 2 3
1 ) ( P
p
p
M u u u u
Bez
(4-38)

where the Bezier matrix is


- 21 -
(4-39)
ting splines. But the more useful B-splines, as well as
-sp
Example1:

0 0 3 3
Bez
M

0 3 6 3

1 3 3 1
=

0 0 0 1
We could also introduce additional parameters to allow adjustment of curve "tension" and
"bias", as we did with the interpola
lines, provide this capability.



Figure 4-20
Bezier surfaces constructed for (a) m = 3, n = 3, and (b) m = 4, n = 4.
Dashed lines connect the control points.


- 22 -
Program:
View::Bezier()

CClientDC dc(this);
dc.TextOut(100,50,"Bezier
");
CPen pen1,pen2;
pen1.CreatePen(PS_SOLID,3,RGB(255,0,0));
pen2.CreatePen(PS_SOLID,1,RGB(255,0,255));
int a[7][2]={{300,220},{200,100},{100,250},{300,400},{500,250},{400,100},{300,220}};
for(int i=0;i<4;i=i+3)
{
dc.MoveTo(a[i][0],a[i][1]);
.LineTo(a[i+1][0],a[i+1][1]);
],a[i+2][1]);
dc.LineTo(a[i+3][0],a[i+3][1]);
i][1]);

u*u-6*u*u+3*u)*a[i+1][0]
+3][0];
*u*u)*a[i+2][1]+u*u*u*a[i+3][1];
dc.SelectObject(&pen1);
ect();
}
void CBezier
{
dc
dc.LineTo(a[i+2][0

dc.MoveTo(a[i][0],a[
for(double u=0;u<1;u=u+0.01)
{
double x,y;
x = (-u*u*u+3*u*u-3*u+1)*a[i][0]+(3*u*
+(-3*u*u*u+3*u*u)*a[i+2][0]+u*u*u*a[i
y = (-u*u*u+3*u*u-3*u+1)*a[i][1]+(3*u*u*u-6*u*u+3*u)*a[i+1][1]
+(-3*u*u*u+3

dc.LineTo(x,y);
Sleep(20);
}
dc.SelectObject(&pen2);
}
pen1.DeleteObject();
pen2.DeleteObj
Example2:
- 23 -





Program:
void CBezierView::Bezier()
{
CClientDC dc(this);
CPen pen1,pen2;
pen1.CreatePen(PS_SOLID,2,RGB(0,255,0));
pen2.CreatePen(PS_SOLID,2,RGB(0,0,0));
int a[50][2]={180,200,190,130,235,120,280,135,
300,150,320,185,310,200,300,240,
260,285,230,290,255,285,300,290,
320,293,360,310,400,310,480,270,
435,320,410,340,380,380,370,400,
330,420,300,420,240,420,210,410,

- 24 -
170,350,160,310,140,290,180,235,
170,232,160,234,140,236,138,235,
138,234,140,233,155,228,160,226,
180,220,160,220,150,222,130,220,
128,219,128,217,130,216,160,210,
170,205,180,200};
//
dc.SelectObject(&pen1);
for (int i=0;i<=44;i=i+1)
{
dc.MoveTo(a[i][0],a[i][1]);
dc.LineTo(a[i+1][0],a[i+1][1]);
245,215,245,215);
[0]+(3*u*u*u-6*u*u+3*u)*a[i+1][0]
+3*u*u)*a[i+2][0]+u*u*u*a[i+3][0];
3*u+1)*a[i][1]+(3*u*u*u-6*u*u+3*u)*a[i+1][1]
*u*u)*a[i+2][1]+u*u*u*a[i+3][1];

}
pen1.DeleteObject();
//Bezier
dc.SelectObject(&pen2);
dc.Arc(215,185,245,215,
dc.Arc(228,198,232,202,232,202,232,202);
dc.MoveTo(250,340);
dc.LineTo(320,340);
.M dc oveTo(250,350);
dc.LineTo(320,350);
dc.MoveTo(250,360);
dc.LineTo(320,360);
dc.Arc(230,310,330,390,330,285,330,400);
for (i=0;i<=44;i=i+3)
{
dc.MoveTo(a[i][0],a[i][1]);
for(double u=0;u<1;u=u+0.01)
{
double x,y;
x = (-u*u*u+3*u*u-3*u+1)*a[i]
+(-3*u*u*u
y = (-u*u*u+3*u*u-
+(-3*u*u*u+3
dc.LineTo(x,y);
Sleep(20);
}
}
pen2.DeleteObject();
}
4.3.5 Bezier Surfaces
- 25 -
be used to design an object surface by
etric vector function for the Bezier surface
of Bezier blending functions:
Two sets of orthogonal* Bezier curves can
trol points. The param specifying an input mesh of con
is formed as the Cartesian product

=
m n
B p v u P ) , (
= =
u BEZ v EZ
, ,
) ( ) ( (4-40)
the (m + 1) by (n + 1) control points.
The control points are connected by dashed
nd constant v. Each curve of constant u is
0 to 1, with u fixed at one of the values in this unit
milarly.
as Bezier curves, and they provide a convenient
e design applications. For each surface patch, we can select a mesh of
d" plane, then we choose elevations above the ground plane for
the z-coordina r using the
boundary constra


oosing control points along a straight line
acro
j k
k j
0 0
, n k m j
with p
j,k
specifying the location of
Figure 4-20 illustrates two Bezier surface plots.
urves of constant u a lines, and the solid lines show c
ying v over the interval from plotted by var
interval. Curves of constant v are plotted si
Bezier surfaces have the same properties
method for interactiv
control points in the xy "groun
te values of the control points. Patches can then be pieced togethe
ints.
Figure 4-21
A composite Bezier surface
constructed with two Bezier sections,
joined at the indicated boundary line.
The dashed lines connect specified
control points. First-order continuity
is established by making the ratio of
length L1 to length L2 contrast for
ons.
each collinear line of control points
across the boundary between the
surface secti

Figure 4-21 illustrates a surface formed with two Bezier sections. As with curves, a smooth
transition from one section to the other is assured by establishing both zero-order and first-order
continuity at the boundary line. Zero-order continuity is obtained by matching control points at
the boundary. First-order continuity is obtained by ch
ss the boundary and by maintaining a constant ratio of collinear line segments for each set of
specified control points across section boundaries.
Example1chair
(n = 3, m = 3)



int a[9][2]={{200,600},{150,500},{0,480},
{300,400},{250,300},{150,250},
{450,400},{420,300},{250,250}};
int b[9][2]={{450,400},{420,300},{250,250},
{650,400},{580,300},{400,250},
{700,150},{600,10},{450,50}};


(n = 4, m = 4)



- 26 -


int a[16][2]={{200,600},{150,500},{75,475},{0,480},
{250,500},{200,400},{120,350},{75,350},
{300,400},{250,300},{200,280},{150,250},
{450,400},{420,300},{350,280},{250,250}};
int b[16][2]={{450,400},{420,300},{350,280},{250,250},
{650,400},{580,300},{500,275},{400,250},
{680,250},{590,150},{500,150},{420,150},
{700,150},{600,10},{500,20},{450,50}};

4.4 B-Spline Curves and Surfaces
These are the most widely used class of approximating splines. B-splines have two
advantages over Bezier splines: (1) the degree of a B-spline polynomial can be set independently
of the number of control points (with certain limitations), and (2) B-splines allow local control
over the shape of a spline curve or surface The trade-off is that B-splines are more complex than
Bezier splines.


- 27 -

Figure 4-22
A closed, periodic, piecewise,
cubic B-spline constructed with
cyclic specification of the six
ntrol points. co
4.4.1 Cubic, Periodic B-Splines
- 28 -
packages, we consider the
larly useful for generating certain
can be generated in sections by
clically specifying four of the six control points shown at each step. If any three consecutive
ugh that coordinate position.
P(0) = 1/6 (p
0
+ 4p
1
+ p
2
)
P(1) = 1/6 (p
1
+ 4p
2
+ p
3
)
P'(0) = 1/2 (p
2
p
0
) (4-41)
P'(1) = 1/2 (p
3
p
1
)
These boundary conditions are similar to those for cardinal splines: Curve sections are
defined with four contro1 points, and parametric derivatives (slopes) at the beginning and end of
each curve section are parallel to the chords joining adjacent control points. The B-spline curve
section starts at a position near p
1
, and ends at a position near p
2
.
A matrix formulation for a cubic periodic B-splines with four control points can then be
writt where the B-spline matrix for periodic cubic polynomials is

0
p
p
Since cubic, periodic B-splines are commonly used in graphics
formulation for this class of splines. Periodic splines are particu
d curves. For example, the closed curve in Fig. 4-22 close
cy
control points are identical, the curve passes thro
In this section, we consider an alternate formulation for periodic cubic B-splines. We start
with the boundary conditions and obtain the blending functions normalized to the interval 0 u
1. Using this formulation, we can also easily obtain the characteristic matrix. The boundary
conditions for periodic cubic B-splines with four consecutive control points, labeled p
0
, p
1
, p
2
,
and p
3
, are

en as
[ ]

=
3
2
1 2 3
1 ) ( P
p
p
M u u u u
B
(4-42)
where the B-spline matrix for period cubic polynomials is



=
0 1 4 1
0 3 0 3
0 3 6 3
1 3 3 1
6
1
B
M (4-43)
This matrix can be o taine by ving for the coefficients in a general cubic polynomial
undary conditions.
spline blending functions over the parameter range from 0
mial form. For example, for the tension
b d sol
expression using the specified four bo
We obtain the periodic, cubic B-
to 1 by expanding the matrix representation into polyno
value t = 1, we have
B
0,3
(u)= 1/6 (1 u)
3
, 0 u 1
B
1,3
(u)= 1/6 (3u
3
6u
2
+ 4) (4-44)
B
2,3
(u)= 1/6 ( 3u
3
+ 3u
2
+ 3u +1)

B
3,3
(u)= 1/6 u
3
- 29 -
4.4.2 B-Spline Surfaces
Formulation of a B-spline surface is that for Bezier splines. We can obtain a
vector point function over a B-spline surface using the Cartesian product of B-spline blending
functions in the form
1 2
0 0 k k
where the vector values for p
k1,k2
specify positions of the (n
1
+ 1) by (n
2
+ 1) control points.
B-spline surfaces exhibit the same prop of their component B-spline curves.
A surface can be constructed from selected values for parameters d
1
, and d
2
, (which determine
the polynomial degrees to be used) and from the specified knot vector. Figure 4-23 shows an

similar to

=
1 2
2 1 2 1 2 1
, , ,
) ( ) ( ) , (
n n
n k n k k k
v B u B p v u P (4-45)
= =
erties as those
object modeled with B-spline surfaces.

Figure 4-23
A prototype helicopter, designed
and modeled by Daniel Langlois
of SOFTUIAGE, Inc., Montreal,
0,000 B-spline surface using 18
patches. The scene was then
rendered using ray tracing, bump
mapping, and reflection mapping.
(Coudesy silicon Graphics Inc )
Example1:
The data of Bezier Surfaces:
- 30 -
(x, y, z) 0 1 2 3
0 (0, 50, 0) (25, 35, 0) (75, 25, 0) (100, 50, 0)
1 (15, 40, 40) (30, 30, 60) (80, 40, 65) (95, 45, 45)
2 (15, 10, 40) (30, 15, 60) (80, 20, 65) (95, 10, 45)
3 (0, 0, 0) (25, -15, 0) (75, -25, 0) (100, 0, 0)




The data of B-Spline Surfaces:
(x, y, z) 0 1 2 3
0 (0, 50, 0) (25, 35, 0) (75, 25, 0) (100, 50, 0)
1 (15, 40, 40) (30, 30, 60) (80, 40, 65) (95, 45, 45)
2 (15, 10, 40) (30, 15, 60) (80, 20, 65) (95, 10, 45)
3 (0, 0, 0) (25, -15, 0) (75, -25, 0) (100, 0, 0)




- 31 -

- 32 -
The data of Bezier/B-Spline Surfaces:
(x, y) 0 1 2 3
0 (100, 300) (110, 180) (120, 160) (140, 230)
1 (180, 200) (190, 130) (200, 110) (240, 170)
2 (310, 200) (320, 130) (330, 110) (370, 170)
3 (420, 300) (430, 180) (450, 160) (490, 240)

P00-03: (100, 300), (110, 180), (120, 160), (140, 230)
P10-13: (180, 200), (190, 130), (200, 110), (240, 170)
P20-23: (310, 200), (320, 130), (330, 110), (370, 170)
P30-33: (420, 300), (430, 180), (450, 160), (490, 240)






Example2:
(x, y) 0 1 2 3
0 (100,400) (110,300) (130,250) (150,350)
1 (200,320) (210,280) (250,200) (280,250)
2 (300,320) (300,280) (330,180) (360,250)
3 (400,400) (380,320) (410,200) (480,280)



- 33 -

- 34 -
Program:
void CBezier2View::Bezier2()
{
CClientDC dc(this);
dc.TextOut(150,100,"16 Bezier ");
CPen pen;
pen.CreatePen(PS_SOLID,1,RGB(255,0,0));
double a[16][2]={{100,400},{110,300},{130,250},{150,350},
{200,320},{210,280},{250,200},{280,250},
{300,320},{300,280},{330,180},{360,250},
{400,400},{380,320},{410,200},{480,280}};
for(int i=0;i<16;i=i+4)
{
MoveTo(a[i][0],a[i][1]);
for(int j=0
{
dc.LineTo(a[i+ 1]
}
}
for(i=0;i<4;i++)
{
dc.MoveTo(a[i][0],a[i][1]);
for(int j=0;j<16;j=j+4)
{
dc.LineTo(a[i+j][0],a[i+j][1]);
}
}
double x,y;
x=a[0][0];
y=a[0][1];
dc.MoveTo(x,y);
dc.SelectObject(&pen);
for(double u=0;u<1;u=u+0.1)
{
double U0= -u*u*u+3*u*u-3*u+1;
double U1=3*u*u*u-6*u*u+3*u;
double U2=-3*u*u*u+3*u*u;
double U3=u*u*u;
x=U0*a[0][0]+U1*a[4][0]+U2*a[8][0]+U3*a[12][0];
dc.
;j<4;j++)
j][0],a[i+j][ );

- 35 -
=U0*a[0][1]+U1*a[4][1]+U2*a[8][1]+U3*a[12][1];
for(double w=0;w<1;w=w+0.1)
W1=3*w*w*w-6*w*w+3*w;
*W0
1
2
1*a[7][0]+U2*a[11][0]+U3*a[15][0])*W3);
y=((U0*a[0][1]+U1*a[4][1]+U2*a[8][1]+U3*a[12][1])*W0
]+U2*a[9][1]+U3*a[13][1])*W1
a[6][1]+U2*a[10][1]+U3*a[14][1])*W2
+(U0*a[3][1]+U1*a[7][1]+U2*a[11][1]+U3*a[15][1])*W3);
Sleep(2);

ble w=0;w<1;w=w+0.1)
w-3*w+1;
W1=3*w*w*w-6*w*w+3*w;
W3=w*w*w;
W0*a[0][0]+W1*a[1][0]+W2*a[2][0]+W3*a[3][0];
[1]+W1*a[1][1]+W2*a[2][1]+W3*a[3][1];
eTo(x,y);
u=0;u<1;u=u+0.1)
3*u*u-3*u+1;
*u+3*u;
double U2=-3*u*u*u+3*u*u;
2*a[8][0]+U3*a[12][0])*W0
0]+U2*a[9][0]+U3*a[13][0])*W1
+U1*a[6][0]+U2*a[10][0]+U3*a[14][0])*W2
0])*W3);
y
dc.MoveTo(x,y);

{
double W0=-w*w*w+3*w*w-3*w+1;
double
double W2=-3*w*w*w+3*w*w;
double W3=w*w*w;
x=((U0*a[0][0]+U1*a[4][0]+U2*a[8][0]+U3*a[12][0])
+(U0*a[1][0]+U1*a[5][0]+U2*a[9][0]+U3*a[13][0])*W
+(U0*a[2][0]+U1*a[6][0]+U2*a[10][0]+U3*a[14][0])*W
+(U0*a[3][0]+U

+(U0*a[1][1]+U1*a[5][1
+(U0*a[2][1]+U1*

dc.LineTo(x,y);

}
}
for(dou
{
double W0=-w*w*w+3*w*
double
double W2=-3*w*w*w+3*w*w;
double
x=
y=W0*a[0]
dc.Mov
for(double
{
double U0=-u*u*u+
double U1=3*u*u*u-6*u

double U3=u*u*u;
x=((U0*a[0][0]+U1*a[4][0]+U
+(U0*a[1][0]+U1*a[5][
+(U0*a[2][0]
+(U0*a[3][0]+U1*a[7][0]+U2*a[11][0]+U3*a[15][
- 36 -
][1])*W0
U1*a[5][1]+U2*a[9][1]+U3*a[13][1])*W1
*a[10][1]+U3*a[14][1])*W2
0*a[3][1]+U1*a[7][1]+U2*a[11][1]+U3*a[15][1])*W3);
y=((U0*a[0][1]+U1*a[4][1]+U2*a[8][1]+U3*a[12
+(U0*a[1][1]+
+(U0*a[2][1]+U1*a[6][1]+U2
+(U
dc.LineTo(x,y);
Sleep(2);
}
}
pen.DeleteObject();
}

B-Spline Surfaces


Other Examples:






- 37 -





- 38 -

- 39 -
B99
(x, y, z) (x, y, z) (x, y, z)
1 (0,0,0) 28 (15,50,0) 55 (30,90,0)
2 (25,-15,0) 29 (25,35,10) 56 (35,100,0)
3 (75,-25,0) 30 (70,45,0) 57 (90,105,10)
4 (100,-20,0) 31 (110,50,80) 58 (105,110,0)
5 (120,-15,0) 32 (105,65,0) 59 (125,115,0)
6 (185,-25,0) 33 (190,55,20) 60 (195,105,0)
7 (210,0,0) 34 (210,65,0) 61 (210,110,20)
8 (280,-15,0) 35 (280,55,0) 62 (280,100,0)
9 (310,-20,0) 36 (310,60,0) 63 (310,115,0)
10 (5,10,0) 37 (20,60,0) 64 (40,110,0)
11 (30,15,10) 38 (35,55,10) 65 (45,120,0)
12 (80,18,0) 39 (75,65,30) 66 (90,125,10)
13 (95,10.0,0) 40 (100,70,0) 67 (105,130,0)
14 (125,15,0) 41 (135,85,0) 68 (125,125,0)
15 (180,20,10) 42 (195,75,150) 69 (200,125,0)
16 (205,10,0) 43 (210,70,10) 70 (210,130,0)
17 (255,20,0) 44 (270,5,0) 71 (280,130,0)
18 (305,10,0) 45 (335,80,0) 72 (350,135,0)
19 (10,40,0) 46 (25,70,0) 73 (30,120,0)
20 (40,30,0) 47 (30,85,10) 74 (35,130,0)
21 (85,38,50) 48 (70,85,0) 75 (90,145,10)
22 (90,45,0) 49 (95,90,0) 76 (105,150,0)
23 (120,45,0) 50 (120,90,0) 77 (125,155,0)
24 (190,35,10) 51 (195,95,0) 78 (195,145,0)
25 (215,40,0) 52 (230,80,10) 79 (210,140,0)
26 (285,30,30) 53 (280,90,0) 80 (280,130,10)
27 (315,40,20) 54 (330,95,0) 81 (360,450,0)

Das könnte Ihnen auch gefallen