0% found this document useful (0 votes)
269 views13 pages

CGR Unit V INTRODUCTION TO CURVES

This document provides an introduction to curves in computer graphics. It discusses two approaches to drawing curved lines: using curve generation algorithms like DDA, and approximating curves with small line segments through interpolation. Specific topics covered include the DDA algorithm for generating arcs, Lagrange interpolation using blending functions, and types of curves like Hilbert, Koch, B-spline, and Bezier curves.
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)
269 views13 pages

CGR Unit V INTRODUCTION TO CURVES

This document provides an introduction to curves in computer graphics. It discusses two approaches to drawing curved lines: using curve generation algorithms like DDA, and approximating curves with small line segments through interpolation. Specific topics covered include the DDA algorithm for generating arcs, Lagrange interpolation using blending functions, and types of curves like Hilbert, Koch, B-spline, and Bezier curves.
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

Unit-V Introduction to Curves

Second Year Diploma Courses in Computer Science & Engineering / Computer


Engineering / Computer Technology / Information Technology Branch.

Computer Graphics
As per MSBTE ‘I’ Scheme Syllabus
CGR-22318

Unit-V
INTRODUCTION TO CURVES
Total Marks- 08

Contents:
5.1 Curve generation:
5.1.1 Arc generation using DDA Algorithm.
5.1.2 Interpolation:
5.2 Types of Curves:
5.2.1 Hilbert’s Curve,
5.2.2 Koch Curve,
5.2.3 B-Spline,
5.2.4 Bezier Curves.

CGR-22318 [Link] Page 1


Unit-V Introduction to Curves

Unit-V Introduction To Curves

5.1 Curve generation:


We can use two approaches to draw curved lines;
One approach is to use a curve generation algorithm such as DDA. In this approach a true
curve is created.
In the second approach the curve is approximated by a number of small straight line
augments. This can be achieved with the help of interpolation techniques.
5.1.1 Arc generation using DDA Algorithm
Digital differential analyzer algorithm uses the differential equation of the curve. We have
already discussed the DDA approach for line drawing in chapter 2. Let us see the DDA
algorithm for generating circular arcs.
The equation for an arc in the angle parameter can be given as,

R
(x0,y0)

x = R cos + x0 (1)
y = R sin + y0 (2)
Where (x0,y0) is the center of curvature, and R is the radius of arc.
By taking differential equation we get,

= + = R (-sin ) + 0

= - R sin
dx = - R sin and (3)
dy = R cos (4)
From equation (1) and (2)
x = R cos + x0
R cos = x - x0 and
R sin = y - y0
Substituting values of R cos and R sin in equation (3) and (4) we get,
dx = - (y - y0)
dy = (x - x0)
It says when we increment by d , x and y will change by dx and dy, respectively. Thus we can find
the new point by adding dx and dy in the current point. So if a current point on the arc is (x1, y1), next
point (x2,y2) can be computed incrementally as follows,
x2 = x1 + dx = x1- (y - y0)
y2 = y1 + dy = y1 + (x - x0)
Usually, the value of can be determined from the following equation.
= Min (0.01, 1/(3.2 (|x-x0| + |y – y0|)))

CGR-22318 [Link] Page 2


Unit-V Introduction to Curves

Algorithm:
1. Read the center of curvature, say (x0,y0).
2. Read the arc angle .
3. Read the starting point of the arc, say (x, y).
4. Calculate d
= Min (0.01, 1/(3.2 (|x-x0| + |y – y0|)))
5. Initialize Angle =
6. While (Angle < )
do
{
Plot (x, y)
x = x- (y - y0).
y2 = y + (x - x0).
Angle = Angle +
}
7. Stop.
Problems in True-Curve Generation Approach:
1. To specify a curve, we need more information than just its end points.
2. It is difficult to apply transformations. For example, a circle when scaled in only one
direction becomes an ellipse. If our algorithm supports only circular arc generation
then ability to scale picture is limited.
3. New clipping algorithm is required to clip arcs.
4. The curve generation algorithms for curves other than circular or elliptical such as
airplane wings or cars or human faces, are complex.
5.1.2 Interpolation
We have to deal with some complex curves for which no direct mathematical function is
available. Such can be drawn using approximation method.
If we have set of sample points which lie on the required curves, then we can draw the
required curve by filling portions of curves with the pieces of known curves which pass
through nearby sample points.
If the curve passes through the sample (control) points, it is called Interpolation.
Interpolation curves are used in animation and specifying camera motion. It is also used in
digitizing the coordinates.
If the curve does not pass through the sample (control) points and approximate the shape, it is
called approximation or extrapolation. Such curves are used to estimate the shape of the
object surface.

CGR-22318 [Link] Page 3


Unit-V Introduction to Curves
The gap between the sample points can be filled by finding the coordinates of the points along
the known approximating curve and connecting these points with line segments.
The main task in this process is to find the suitable mathematical expression for the known
curve.
There are polynomials, trigonometric, exponential and other classes of functions that can be
used to approximate the curve.
Usually polynomial functions in the parametric forms are preferred.
The polynomial functions in the parametric form can be given as:
x = fx (u)
y = fy (u)
z = fz (u)

Fig. Interpolation Process

CGR-22318 [Link] Page 4


Unit-V Introduction to Curves
We have to draw the curve by determining the intermediate points between the known sample
points. This can be achieved using interpolation techniques.
Let us see the interpolation process.
Suppose we want a polynomial curve that will pass through n sample points.
(x1, y1, z1), (x2, y2, z2), …, (xn, yn, zn)
We will construct the function as the sum of terms, one term for each sample point. These
functions can be given as,
Blending Functions:

The function is called ‘blending function’. For each value of parameter u, the blending
function determines how much the ith sample point affects the position of the curve. In other
words we can say that each sample points tries to pull the curve in its direction and the
function gives the strength of the pull. If some value of u, = 1 for unique value of
th
I (i.e. = 0 for other values of i) then i sample point has complete control of the curve
and the curve will pass through ith sample point. For different value of u, some other sample
point may have complete control of the curve. In such case the curve will pass through that
point as well. In general, the blending functions give control of the curve to each of the
sample points in turn for different values of u, let us assume that the first sample point (x 1, y1,
z1) has complete control when u=-1, the second when u=0, the third when u=1, and so on. i.e.
When u = -1 =1 and 0 for u = 0, 1, 2, …, n – 2
When u=0 =1 and 0 for u = -1, 1, 2, …, n - 2
:
:
When u = (n-2) =1 and 0 for u = -1, 0, 1, …, n - 1
To get = 1 at u = -1 and 0 for u=0, 1, 2, … , n-2, the expression for can be given
as,

Where denominator term is constant used. In general form ith blending function which is 1 at
u = i-2 and 0 for other integers can be given as:

The approximation of the curve using above expression is called as Lagrange interpolation.
From the above expression blending functions for four sample points can be given as,

CGR-22318 [Link] Page 5


Unit-V Introduction to Curves

Using above blending functions, the expression for the curve passing through sampling points
can be realized as follows:
x = x1 + x2 + x3 + x4
y = y1 + y2 + y3 + y4
z = z1 + z2 + z3 + z4
Interpolating Algorithm:
1. Get the sample points.
2. Get intermediate values of u to determine intermediate points.
3. Calculate blending function values for middle section of the curve.
4. Calculate blending function values for first section of the curve.
5. Calculate blending function values for last section of the curve.
6. Multiply the sample points by blending functions to give points on approximation
curve.
7. Connect the neighboring points using straight line segments.
8. Stop.
5.2 Types of Curves:
Curves are categorized as follow:
 Fractal representation
1. Hilbert’s curve
2. Koch curve
 Spline curves representation
Spline curves are the curves defined by the piece-wise smooth polynomial function and
possesses a high degree of smoothness at the places where the polynomial piece connect.
1. B-Spline
2. Bezier Curves
5.2.1 Hilbert’s curve
The Hilbert curve is a space filling curve that visits every point in a square grid with a size
of 2×2, 4×4, 8×8, 16×16, or any other power of 2. The curve generation starts with a
square.
In a first approximation, the square is divided into four quadrants and the curve joins the
center of all quadrants by a straight line.

Fig. (a) The first approximation to Hilbert’s curve

CGR-22318 [Link] Page 6


Unit-V Introduction to Curves
In a second approximation, each quadrant is further subdividing each of the quadrants
and connecting their centers before moving to next major quadrant (see in fig.).

Fig. (b) The second approximation to Hilbert’s curve


In a third approximation, each quadrant is further subdividing each of the quadrants and
connecting their centers before moving to next major quadrant (see in fig.).

Fig. (c) The third approximation to Hilbert’s curve


On applying this process continuously,
 The curve never crosses itself
 Curve gets closer to a square containing it.
 With each subdivision, the length of the curve increases four times.
 There is no limit on length and hence there is no limit on curve length.
 At each subdivision, the scale of the square is reduced by factor 2, and length changed by factor 4.
 The fractal dimension of the curve is given as,
N = 2D
4 = 2D
So, D = 2.
Thus, this curve has topological dimension 1 and fraction dimension 2.
5.2.2 Koch curve
Koch curve begins with the straight line. General procedure for generating the Koch curve can
be stated as:
First approximation of the Koch curve:
1. Divide a straight line into three equal parts.

CGR-22318 [Link] Page 7


Unit-V Introduction to Curves
2. Draw an equilateral triangle on the middle segment, pointing in an outward direction with a
base of the middle segment.
3. Remove the line middle line segment.

Fig. First approximation of the Koch curve


Second approximation of the Koch curve:
To apply the second approximation to the Koch curve we have to repeat the above process for each
of the four segments. The resultant curve is shown in Fig.

Fig. Second approximation of the Koch curve

The resultant curve has more wiggles and its length is 16/9 times the original length.

From the above figures we can easily note following points about the koch curve :

1. Each repetition increases the length of the curve by factor 4/3.


2. Length of curve is infinite.
3. Unlike Hibert's curve, it doesn’t fill an area.
4. It doesn’t deviate much from its original shape.
5. If we reduce the scale of the curve by 3 we find the curve that looks just like the
original one; but we must assemble 4 such curves to make the originals, so we have

Therefore for Koch curve topological dimension is 1 but fractal dimension is 1.2618.

From the above discussion we can say that point sets, curves and surfaces which give a fractal
dimension greater than the topological dimension are called fractals The Hilbert’s curve and
Koch curves are fractals, because their fractal dimensions (respectively, 2 and 1.2618) are
greater than their topological dimension which is 1.

CGR-22318 [Link] Page 8


Unit-V Introduction to Curves

5.2.3 B-Spline

We have seen that, a curve generated by using the vertices (control points) of a defining
Polygon is dependent on some interpolation or approximation scheme to establish the
relationship between the curve and the polygon. This scheme is provided by the choice of
basis function. The Bezier curve produced by the Bernstein basis function has a limited
flexibility. First the number of specified polygon vertices fixes the order of the resulting
Polynomial which defines the curve. The second limiting characteristic is that the value of the
blending function is nonzero for all parameter values over the entire curve. Due to this change
in one vertex, changes the entire curve and this eliminates the ability to produce a local
change within a Curve.

There is another basis function, called the B-spline basis, which contains the Bernstein basis
as a special case. The B-spline basis is nonglobal. It is nonglobal because each vertex Bi is
associated with a unique basis function. Thus, each vertex affects the shape of the curve only
over a range of parameter values where its associated basis function is nonzero. The B-spline
basis also allows the order of the basis function and hence the degree of the resulting curve is
independent on the number of vertices. It is possible to change the degree of the resulting
curve without changing the number of vertices of the defining polygon.

If P(u) be the position vectors along the curve as a function of the parameter u, a B-spline
curve is given by

where the Bi are the position vectors of the n + 1 defining polygon vertices and the N i, k are
the normalized B-spline basis functions for the ith normalized B-spline basis function of order
k, the basis function Ni, k(u) are defined as

The values of xi are the elements of a knot vector satisfying the relation Xi ≤ Xi +[Link]
parameter u varies from to umin to umax, along the curve P(u). The choice of knot vector has
a significant influence on the B-spline basis functions Ni, k(u) and hence on the resulting B-
spline curve. There are three types or knot vector uniform, open uniform and nonuniform. In a
uniform knot vector, individual knot values are evenly spaced. For example,

[0 1 2 3 4 ]

For a given order k, uniform knot vectors give periodic uniform basis functions for which

An open uniform knot vector has multiplicity of knot values at the ends equal to the order k of
the B-spline basis function. Internal knot values are evenly spaced. Examples are,

CGR-22318 [Link] Page 9


Unit-V Introduction to Curves
k = 2[0 0 1 2 3 3]

k = 3[0 0 0 1 2 3 3 3]

k = 4[0 0 0 0 1 2 2 2 2]

Generally, an open uniform knot vector is given by,

Xi = 0 1 ≤ i ≤ k

Xi = i – k k+1 ≤ i ≤ n+1

Xi = n – k + 2 n+2 ≤ i ≤ n+k+1

The curves resulted by the use of open uniform basis function are nearly like Bezier curves. In
fact, when the number of defining polygon vertices is equal to the order of the B-spline basis
and an open uniform knot vector is used, the B-spline basis reduces to the Bernstein basis.
Hence, the resulting B-spline curve is a Bezier curve.

Properties of B-spline curve:-

1. The sum of the B-spline basis functions for any parameter value u is 1.

2. Each basis function is positive or zero for all parameter values, i.e., N i ,k ≥ 0.
3. Except for k = 1 each basis function has precisely one maximum value.
4. The maximum order of the curve is equal to the number of vertices of defining
polygon.
5. The degree of B-spline polynomial is independent on the number of vertices of
defining polygon (with certain limitations).
6. B-spline allows local control over the curve surface because each vertex affects the
shape of a curve only over a range of parameter values where its associated basis
function is nonzero.
7. The curve exhibits the variation diminishing property. Thus the curve does not
oscillate about any straight line move often than its defining polygon.
8. The curve generally follows the shape of defining polygon.
9. Any affine transformation can be applied to the curve by applying it to the vertices of
defining polygon.
10. The curve line within the convex hull of its defining polygon.

5.2.4 Bezier Curves

Bezier curve is an another approach for the construction of the Curve. A Bezier curve is
determined by a defining polygon. Bezier curves have a number of properties that make them
highly useful and convenient for curve and surface design. They are also easy to implement.
Therefore Bezier curves are widely available in various CAD systems and in general graphic
packages. In this section we will discuss the cubic Bezier curve. The reason for choosing

CGR-22318 [Link] Page 10


Unit-V Introduction to Curves
cubic Bezier curve is that they provide reasonable design flexibility and also avoid the large
number of calculations.

In general, a Bezier curve section can be fitted to any number of control points. However, as
number of control points increases, the degree of the Bezier polynomial also increases.
Because in a Bezier curve a degree of a polynomial is one less than the number of control
points used. For example, three control points generate a parabola four points generate cubic
curve and so on. This is illustrated in Fig.

The Bezier curves can be specified with boundary conditions, with a characterizing matrix or
with blending functions. Out of these, blending function specification is the most convenient
way for general Bezier

Consider that the curve has n +1 control points Pk (xk, yk, zk) ... where k varies from 0 to n.
The co-ordinates of these control points can be blended to produce position vector p(u), which
gives the path of an approximating Bezier polynomial function between p0 and pn .The
position vector can be given by.

0 u 1

Bernstein polynomials:-

The Bezier blending functions BEZk,n (u) are the Bernstein polynomials. They are specified
as,
BEZk,n (u) = C (n, k) uk (1-u)n-k
Where the C(n, k) are the binomial coefficients, Binomial coefficients are given by,
C(n, k) =

Equivalently, we can define blending functions with the recursive calculation as,
BEZk,n (u) = (1 – u) BEZk,n-1 (u) + uBEZk-1,n-1 (u), n>k 1

With BEZk, k = uk and BEZ0, k = (1-u)k. The position vector equation represents a set of three
parametric equations for the individual curve co-ordinates:

CGR-22318 [Link] Page 11


Unit-V Introduction to Curves

The successive binomial coefficient can be calculated as

C(n, k) = C(n, k - 1)
Properties of Bezier curve:-

1. The basis functions are real.


2. Bezier curve always passes through the first and last control points i.e. curve has same
end points as the guiding Polygon.
3. The degree of the polynomial defining the curve segment is one less than the number
of defining polygon point. Therefore, for 4 control points, the degree of the
polynomial is three, i.e. cubic polynomial.
4. The curve generally follows the shape of the defining polygon.
5. The direction of the tangent vector at the end points is the same as that of the vector
determined by first and last segments.
6. The curve lies entirely within the convex hull formed by four control points.
7. The convex hull property for a Bezier curve ensures that the polynomial smoothly
follows the control points.
8. The curve exhibits the variation diminishing property. This means that the curve does
not oscillate about any straight line more often than the defining polygon.
9. The curve is invariant under an affine transformation.

In cubic Bezier curve four control Points are used to specify complete curve. Unlike the B-
spline curve, we do not add intermediate points and smoothly extend Bezier curve, but we
pick four more points and construct a second curve which can be attached to the first. The
second curve can be attached to the first curve smoothly by selecting appropriate control
points.

CGR-22318 [Link] Page 12


Unit-V Introduction to Curves

Fig. shows the Bezier curve and its four control points. As shown in the Fig. Bezier curve
begins at the first control point and ends at the fourth control point. This means that if we
want to connect two Bezier curves, we have to make the first control point of the second
Bezier curve match the last control point of the first curve. We can also observe that at the
start of the curve, the curve is tangent to the line connecting first and second control points.
Similarly at the end of curve, the curve is tangent to the line connecting the third and fourth
control point. This means that, to join two Bezier curves smoothly we have to place the third
and the fourth control Points of the first curve on the same line specified by the first and the
second control points of the second curve.

The Bezier matrix for periodic cubic polynomial is

MB =

P(u) = U . MB . GB

Where, GB =

And the product P(u) = U . MB . GB is


P(u) = (1- u)3 + 3u(1 - u)2 + 3u2(1- u) + u3
Therefore, the four blending functions for cubic Bezier curve are:
BEZ0,3(u) = (1 – u)3
BEZ1,3(u) = 3u(1 - u)2
BEZ2,3(u) = 3u2(1- u)
BEZ3,3(u) = u3

CGR-22318 [Link] Page 13

You might also like