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

C Unit 2 M

The document discusses various algorithms for representing and drawing lines on a digital display, including the Digital Differential Analyzer algorithm and Bresenham's line algorithm. It explains how these algorithms use integer calculations to determine which pixels to select between endpoint coordinates to minimize jaggedness and provide constant line density. Several examples are provided to illustrate how the algorithms work step-by-step.
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)
26 views

C Unit 2 M

The document discusses various algorithms for representing and drawing lines on a digital display, including the Digital Differential Analyzer algorithm and Bresenham's line algorithm. It explains how these algorithms use integer calculations to determine which pixels to select between endpoint coordinates to minimize jaggedness and provide constant line density. Several examples are provided to illustrate how the algorithms work step-by-step.
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/ 22

Academic Year: 2022-2023 Regulation IFETCE 2019

IFET COLLEGE OF ENGINERING


(An Autonomous Institution)
Department of Mechanical Engineering
Year/Sem: : III / VI
Subject Code & : 19UMEPE605 Computer Aided Design

UNIT II- REPRESENTATION OF CURVES AND SURFACES


Mathematical representation of lines, circle, ellipse &parabola, Cubic Spline Curve, Bezier Curve
and B-spline Curve, Bicubic surface. Bezier Surface and B-spline Surface.

2.1 Mathematical representation of lines


Several line drawing algorithms are developed. Their basic objective is to enable visually
satisfactory images in least possible time. This is achieved by reducing the calculations to a
minimum. This is by using integer arithmetic rather than floating point arithmetic. This way of
minimizing even a single arithmetic operation is important. This is because every drawing or image
generated will have a large number of line segments in it and every line segment will have many
pixels. So saving of one computation per pixel will save number of computations in generating an
object. This in turn minimizes the time required to generate the whole image on the screen. Straight
line segments are used a great deal in computer generated pictures. The following criteria have been
stipulated for line drawing displays:
1. Lines should appear straight
2. Lines should terminate accurately
3. Lines should have constant density
4. Line density should be independent of length and angle
5. Line should be drawn rapidly
The process of turning on the pixels for a line segment is called vector generation. If the end
points of the line segment are known, there are several schemes for selecting the pixels between
the end pixels. One method of generating a line segment is a symmetrical digital differential
analyzer (DDA).

2.2 DDA ALGORITHM


The digital differential analyzer generates lines from their differential equations. The DDA works on
the principle that X and Y are simultaneously incremented by small steps proportional to the first
derivatives of X and Y. In the case of a straight line the first derivatives are constant and are
proportional to DX and DY, where D is a small quantity. In the real world of limited precision
displays, addressable pixels only must be generated. This can be done by rounding to the next
integer after each incremental step. After rounding, a pixel is displayed at the resultant X and Y
locations. An alternative to rounding is the use of arithmetic overflow. X and Y are kept in registers
that have integer and fractional parts. The incrementing values which are less than unity are
repeatedly added to the fractional part and whenever the result overflows the corresponding integer
part is incremented. The integer parts of X and Y are used to plot the line. This would normally have
the effect of truncating. The DDA is therefore initialized by adding 0.5 in each of the fractional parts
to achieve true rounding. The symmetrical DDA generates reasonably accurate lines since a
1
Academic Year: 2022-2023 Regulation IFETCE 2019

displayed pixel is never away from a true line by half the pixel unit. A Pascal procedure for a simple
DDA is given below:
Procedure DDA (X1, Y1, X2, Y2: integer);
length : var ;
i : integer;
X, Y, X-incr, Y-incr : real ;
begin
length : = abs (X2– X1) ;
if abs (Y2–Y1) < length then length: = abs (Y2–Y1);
X - incr : = (X2 – X1) /length ;
Y - incr : = (Y2 – Y1) /length ;
X : = X1 + 0.5 ; Y = Y1 + 0.5 ;
for i : = 1 to length do
begin
plot (trunc (X) ; trunc(Y) ;
X : = X + X - incr ;
Y : = Y + Y - incr ;
end;
end.

Example
To draw a straight line from connecting two points (2, 7) and (15, 10)
X1 = 2, X2 = 15 abs(X2 – X1) = 13
Y1 = 7, Y2 = 10 abs(Y2 – Y1) = 3
Length = 13
X incr = (X2–X1/L) =13/13 = 1
Y incr = (Y2–Y1/L) =3/13= 0.23
Initial values of X and Y are
X = 2.5 Y = 7.5
The X and Y are tabulated in Table 1 and Fig. 1 shows a plot of the line.

Table 1 - Pixel Values Fig. 1 Plotting a Line

2
Academic Year: 2022-2023 Regulation IFETCE 2019

It can be noted that lines drawn on a raster display may have a jagged or staircase appearance unless
the lines are vertical or horizontal. This is because the points that are plotted must be pixel grid
points and many of these may not lie on the actual line.

2.3 BRESENHAM'S LINE ALGORITHM

An accurate and efficient raster line-generating algorithm, developed by Bresenham, scans converts
lines using only incremental integer calculations that can be adapted to display circles and other
curves. Figures 2 and 3 illustrate sections of a display screen where straight line segments are to be
drawn. The vertical axes show-scan-line positions, and the horizontal axes identify pixel columns.
Sampling at unit x intervals in these examples, we need to decide which of two possible pixel
positions is closer to the line path at each sample step. Starting from the left endpoint shown in Fig.
2, we need to determine at the next sample position whether to plot the pixel at position (11, 11) or
the one at (11, 12).

Similarly, Fig. 3 shows-a negative slope-line path starting from the left endpoint at pixel position
(50, 50). In this one, do we select the next pixel position as (51,50) or as (51,49)? These questions
are answered with Bresenham's line algorithm by testing the sign of an integer parameter, whose
value is proportional to the difference between the separations of the two pixel positions from the
actual line path. To illustrate Bresenharn's approach, we-first consider the scan-conversion process
for lines with positive slope less than 1. Pixel positions along a line path are then determined by
sampling at unit x intervals. Starting from the left endpoint (x0, y0) of a given line, we step to
each successive column (x position) and plot the pixel whose scan-line y value is closest to
the line path. Assuming we have determined that the pixel at (xk, yk) is to be displayed, we
next need to decide which pixel to plot in column xk+1,.Our choices are the pixels at positions
(Xk+l, yk) and (xk+l, yk+l).

Fig: 2 - Section of a display screen where a straight line segment is to be plotted, starting from the
pixel at column 10 on scan line 11

Fig: 3 - Section of a display screen where a negative slope line segment is to be plotted, starting from
the pixel at column 50 on scan line 50
3
Academic Year: 2022-2023 Regulation IFETCE 2019

At sampling position xk+l, we label vertical pixel separations from the mathematical line
path as d1 and d2 (Fig. 4). The y coordinates on the mathematical line at pixel column
position xk+l is calculated as
y=m(xk+1)+b
Then
d1=y-yk
=m(xk+1)+b-yk
and
d2=(yk+1)-y
=yk+1-m(xk+1)-b
The difference between these two separations is
d1-d2=2m(xk+1)-2yk+2b-1 -----------1

Fig:4 - Distance between pixel positions and the line y coordinates at sampling position xk+1

A decision parameter pk for the kth step in the line algorithm can be obtained by rearranging
Eq. 1 so that it involves only integer calculations. We accomplish this by substituting m =
Δy/Δx, where Δy and Δx are the vertical and horizontal separations of the endpoint positions,
and defining:
pk=Δx(d1-d2)
=2Δy.xk-2Δx.yk+c ------------2
The sign of pk, is the same as the sign of dl–d2, since Δx>0 for our example. Parameter cis
constant and has the value 2Δy + Δx(2b - l), which is independent of pixel position and will
be eliminated in the recursive calculations for pk. If the pixel at yk is closer to the line path
than the pixel at yk+1(that is, dl<d2), then decision parameter pk is negative. In that case, we
plot the lower pixel; otherwise, we plot the upper pixel.
Coordinate changes along the line occur in unit steps in either the x or y directions.
Therefore, we can obtain the values of successive decision parameters using incremental
integer calculations. At step k + 1, the decision parameter is evaluated from Eq. 5as
pk+1=2Δy.xk+1-2Δx.yk+1+c
Subtracting Eq. 2 from the preceding equation, we have
pk+1-pk =2Δy(xk+1-xk)-2Δx(yk+1-yk)
But xk+1, = xk+ 1, so that
pk+1=pk + 2Δy-2Δx(yk+1-yk)

4
Academic Year: 2022-2023 Regulation IFETCE 2019

Where the term yk+1- yk is either 0 or 1, depending on the sign of parameter pk. This recursive
calculation of decision parameters is performed at each integer x position, starting at the left
coordinate endpoint of the line. The first parameter, p0, is evaluated from Eq. 5 at the starting pixel
position (xo, yo) and with m evaluated as Δy/Δx:
We can summarize Bresenham line drawing for a line with a positive slope less than 1 in the
following listed steps. The constants 2Δy and 2Δy - 2Δx are calculated once for each line to be scan
converted, so the arithmetic involves only integer addition and subtraction of these two constants.

Bresenham's Line-Drawing Algorithm for I mI<1


1. Input the two line endpoints and store the left endpoint in (xo,yo)
2. Load (xO, yO) into the frame buffer; that is, plot the first point.
3. Calculate constants Δx, Δy, 2Δy, and 2Δy - 2Δx, and obtain the starting value for the decision
parameter as
po= 2Δy - Δx
4. At each xkalong the line, starting at k = 0, perform the following test:
If Pk< 0, the next point to plot is (xk+1,yk)and
Pk+1=P k+2Δy
Otherwise, the next point to plot is (xk+ 1 ,yk+ 1) and
pk+1= pk+ 2Δy - 2Δx
5. Repeat step 4 Δx times.

2.4 Mathematical representation of circle


We know that the equation of a circle centered at the origin is x2 + y2 = R2, where (0, 0) is the origin
R is the radius and (x, y) is any point on the circle.
x2 + y2 = R2
y2 = R2 – x2
y = + √ (R2 – x2)
To draw a quarter circle, we can increment x from 0 to R in unit steps, solving for +y at each step.
This method will work, but it is inefficient because of the multiply and square root operations. Here
the circle will have large gaps for values of x close to R, because the slope of the circle becomes
infinite there.
Eight-way symmetry
We can improve the process of the previous section by taking greater advantage of the symmetry in
a circle. Consider first a circle centered at the origin. That is (0, 0). If the point (x, y) is on the circle
the new can trivially compute seven other points on the circle as in Fig: 5
We need to compute only one 45-degree segment to determine the circle completely. For a
circle centered at the origin (0,0), the eight symmetrical points can be displayed with
procedure circlepoints().
Void circlepoints (int x, int y)
{
putpixel ( x, y);
putpixel ( y, x);
putpixel ( y, -x);
putpixel ( x, -y);
5
Academic Year: 2022-2023 Regulation IFETCE 2019

putpixel ( -x, -y);


putpixel ( -y, -x);
putpixel ( -y, x);
putpixel ( -x, y);
}
This procedure can be easily generalized to the case of circles with arbitrary centers.
Suppose the point (xcenter, ycenter) is the center of the circle. Then the above function can
be modified as
Void circlepoints(xcenter, ycenter, x, y)
intxcenter, ycenter, x, y;
{

(Fig:5 Eight symmetrical points on a circle)

putpixel ( xcenter + x, ycenter + y);


putpixel ( xcenter + y, ycenter + x);
putpixel ( xcenter + y, ycenter - x);
putpixel ( xcenter + x, ycenter - y);
putpixel ( xcenter - x, ycenter - y);
putpixel ( xcenter - y, ycenter - x);
putpixel ( xcenter -y, ycenter + x);
putpixel ( xcenter - x, ycenter + y);
}
2.5 DDA ALGORITHM
To write an algorithm to generate a circle of the form (x-a)2+(y-b)2=r2 by the help of digital
differential analyzer where (a,b) is the center of the circle and r is the radius.
1. START
2. Get the values of the center (a,b) and radius (r) of the circle.
3. Find the polar co-ordinates by
x=a+rcosθ
y=b+rsinθ
4. Plot the points(x,y) corresponding to the values of θ ,where θ lies between 0 and 360.
5.STOP

6
Academic Year: 2022-2023 Regulation IFETCE 2019

2.6 MIDPOINT CIRCLE ALGORITHM (Bresenham's Circle Algorithm)


As in the raster line algorithm, we sample at unit intervals and determine the closest pixel position to
the specified circle path at each step. For a given radius r and screen center position (xc ,yc), we can
first set up our algorithm to calculate pixel positions around a circle path centered at the coordinate
origin (0,0).Then each calculated position (x, y) is moved to its proper screen position by adding xc
to x and yc to y. Along the circle section from x = 0 to x = y in the first quadrant, the slope of the
curve varies from 0 to -1. Therefore, we can take unit steps in the positive x direction over this
octant and use a decision parameter to determine which of the two possible y positions is closer to
the circle path at each step. Positions in the other seven octants are then obtained by symmetry.
To apply the midpoint method, we define a circle function:
fcircle(x,y)=x2+y2-r2
Any point (x,y) on the boundary of the circle with radius r satisfies the equation fcircle(x,y)= 0. If
the point is in the interior of the circle, the circle function is negative. And if the point is outside the
circle, the circle function is positive. To summarize, the relative position of any point (x. y) can be
determined by checking the sign of the circle function:

<0 if(x,y) is inside the circle boundary


fcircle(x,y) =0 if(x,y) is on the circle boundary
>0if(x,y) is outside the circle boundary

The circle-function tests are performed for the midpositions between pixels near the circle path at
each sampling step. Thus, the circle function is the decision parameter in the midpoint algorithm,
and we can set up incremental calculations for this function as we did in the line algorithm.

Fig: 6, Midpoint between candidate pixels at sampling position xk+1 along a


circular path
Fig:6 shows the midpoint between the two candidate pixels at sampling position xk+ 1.
Assuming we have just plotted the pixel at (xk, yk), we next need to determine whether the
pixel at position (xk+ 1, yk) or the one at position (xk+ 1, yk-1) is closer to the circle. Our
decision parameter is the circle function 3-27 evaluated at the midpoint between these two
pixels:
pk = fcircle(xk+1,yk-(1/2) )
= (xk+1)2+(yk-(1/2))2-r2
If pk<0, this midpoint is inside the circle and the pixel on scan line ykis closer to the circle
boundary. Otherwise, the midposition is outside or on the circle boundary, and we select the
pixel on scan lineyk- 1.
7
Academic Year: 2022-2023 Regulation IFETCE 2019

Successive decision parameters are obtained using incremental calculations. We obtain a


recursive expression for the next decision parameter by evaluating the circle function at
sampling position xk+1+1 = xk+ 2:
pk+1 = fcircle(xk+1+1,yk+1-(1/2) )
= [(xk+1)+1]2+(yk+1-(1/2))2-r2
Or
pk+1=pk+2(xk+1)+(y2k+1-y2k)-(yk+1-yk)+1
Whereyk+1, is either ykor yk-1, depending on the sign of pk. increments for obtaining pk+1, are
either 2xk+1+1(if pkis negative) or 2xk+1+1-2yk+1. Evaluation of the terms 2xk+1,n d 2yk+1,can
also be done incrementallyas
2xk+1=2xk +2
2yk+1=2yk -2
At the start position (0, r), these two terms have the values 0 and 2r, respectively. Each
successive value is obtained by adding 2 to the previous value of 2xand subtracting 2 from
the previous value of 2y.
The initial decision parameter is obtained by evaluating the circle function at the start
position (x0, y0) = (0, r):
p0=fcircle(1,r-(1/2) )
=1+(r-(1/2))2-r2
Or
p0=(5/4)-r
If the radius r is specified as an integer, we can simply round p0to
p0 = 1 - r(for r an integer) , since all increments are integers.
Bresenham's line algorithm, the midpoint method calculates pixel positions along the
circumference of a circle using integer additions and subtractions, assuming that the circle
parameters are specified in integer screen coordinate. We can summarize the steps in the
midpoint circle algorithm as follows.

Midpoint Circle Algorithm


1. Input radius r and circle center (xc,yc), and obtain the first point onthe circumference of a
circle centered on the origin as
(x0,y0)=(0,r)
2. Calculate the initial value of the decision parameter as
p0=(5/4)-r
3. At each xk position, starting at k = 0, perform the following test: If pk<0, the next point
along the circle centered on (0,0) is (xk+1, yk) and
pk+1=pk+2(xk+1)+1
Otherwise, the next point along the circle is (xk + 1, yk - 1)and
pk+1=pk+2(xk+1)+1-2(yk+1)
Where2xk+1, = 2xk + 2and 2yk+1, = 2yk - 2.
4. Determine symmetry points in the other seven octants.
5. Move each calculated pixel position (x, y) onto the circular path centered on(xc,yc) and
plot the coordinate values:
x=x+xc, y=y+yc
6. Repeat steps 3 through 5 until x ≥y.
8
Academic Year: 2022-2023 Regulation IFETCE 2019

Example:
Given a circle radius r = 10, we demonstrate the midpoint circle algorithm by determining positions
along the circle octant in the first quadrant hum x = 0 to x = y. The initial value of the decision
parameter is
p0=1-r=-9
For the circle centered on the coordinate origin, the initial point is (x0,y0) =(0, l0), and initial
increment terms for calculating the decision parameters are:
2x0=0, 2y0=20
Successive decision parameter values and positions along the circle path are calculated using the
midpoint method as

2.7 Mathematical representation of ellipse


Loosely stated, an ellipse is an elongated circle. Therefore, elliptical curves can be generated
by modifying circle-drawing procedures to take into account the different dimensions of an
ellipse along the major and minor axes.

Properties of Ellipses
An ellipse is defined as the set of points such that the sum of the distances from two fixed
positions (foci) is the same for all points (Fig. 7). If the distances to the two foci from any
point P = (x, y) on the ellipse are labeled dl and d2, then the general equation of an ellipse can
be stated as
d1+ d2= constant
Expressing distances d1and d2interms of the focal coordinates F1 = (x1, y1) and F2= (x2,y2),
we have
√((x-x1) 2+(y-y1)2) + √((x-x2)2+(y-y2)2)=constant
By squaring this equation, isolating the remaining radical, and then squaring again, we can
rewrite the general ellipse equation in the form
Ax2+ By2+ Cxy+ Dx+ Ey+ F = 0
Where the coefficients A, B, C, D, E, and F are evaluated in terms of the focal coordinates
and the dimensions of the major and minor axes of the ellipse. The major axis is the straight
line segment extending from one side of the ellipse to the other through the foci. The minor
axis spans the shorter dimension of the ellipse, bisecting the major axis at the halfway
position (ellipse center) between the two foci.

9
Academic Year: 2022-2023 Regulation IFETCE 2019

An interactive method for specifying an ellipse in an arbitrary orientation is to input the two foci and
a point on the ellipse boundary. With these three coordinate positions, we can evaluate the constant
in A. Then, the coefficients in B can be evaluated and used to generate pixels along the elliptical
path.

Fig: 7 Ellipse generated about foci F1 and F2

Ellipse equations are greatly simplified if the major and minor axes are oriented to align with the
coordinate axes. In Fig.8, we show an ellipse in "standard position" with major and minor axes
oriented parallel to the x and y axes. Parameter rx for this example labels the semi major axis, and
parameter ry labels the semi minor axis. The equation of the ellipse shown in Fig.1:42 can be written
in terms of the ellipse center coordinates and parameters rx and ry as
((x-xc)/rx)2+((y-yc)/ry)2=1
Using polar coordinates r and θ,we can also describe the ellipse in standard position with the
parametric equations:
x= xc+rxcosθ
y= yc+rysinθ
Symmetry considerations can be used to further reduce computations. An ellipse in standard position
is symmetric between quadrants, but unlike a circle, it is not symmetric between the two octants of a
quadrant. Thus, we must calculate pixel positions along the elliptical arc throughout one quadrant,
and then we obtain positions in the remaining three quadrants by symmetry (Fig 9).

Fig:8 Ellipse centered at (xc,yc) Fig: 9 Symmetry of an ellipse


10
Academic Year: 2022-2023 Regulation IFETCE 2019

DDA ALGORITHM
To write an algorithm to generate an ellipse using the Digital Differential Analyzer
Algorithm (DDA).
Equation to the ellipse is
((x-xc)/rx)2+((y-yc)/ry)2=1
where (xc,yc) - center of the ellipse.
rx- x radius of ellipse, ry-y radius of ellipse.
1. START
2. Get the centre (xc,yc),x radius (rx) and y radius (ry) of the ellipse.
3. The polar co-ordinates on an ellipse are
x=xc+rxcosθ
y=yc+r y sinθ
4. Plot the point(x,y) corresponding to the values of θ where 0<=θ<=360
5. STOP

2.8 Mathematical representation of parabola


Since every parabola is congruent to x2=4ay, for some choice of a>0, we can study the geometry of
every parabola by confining ourselves to this one! This shows the power of both coordinate
geometry and transformations. Imagine a particle moving in the plane along a curve CC as shown in
Fig.10

Fig: 10 Detailed description of diagram

The x- and y-coordinates of the particle can be thought of as functions of a new variable t, and so we
can write x=f(t), y=g(t), where f,g are functions of t. In some physical problems t is thought of as
time. The equations

x=f(t) y=g(t)
are called the parametric equations of the point P(x,y) and the variable tt is called a parameter. It
is often very useful to take a cartesian equation y=F(x) and introduce a parameter t so that the x-
and y-coordinates of any point on the curve can be expressed in terms of this parameter.

Here is a very simple example of a parametrisation. Suppose we begin with the line whose equation
is y=3x−4. We can introduce a new variable tt and write x=t. Then we have y=3t−4. Thus we can
rewrite the equationy=3x−4 in parametric form as x=t, y=3t−4.

11
Academic Year: 2022-2023 Regulation IFETCE 2019

2.9 REPRESENTATION OF CURVES


A curve or a surface may be described or represented by a set of equations. These equations can be
categorized into two forms:
i. Generic form
The generic form in which any generic point (x, y, z) satisfies a relationship in implicit form in x,
y, and z i.e. f(x, y, z) = 0. A single such constraint generally describes a surface while two
constraints considered together can be thought of as a curve which is the intersection of two
surfaces. This may be expressed in an explicit form in the following manner:
x = g1(y, z)
y = g2(x, z)
z = g3(x, y)
ii. Parametric form
A parametric curve is one whose defining equations are in terms of a simple, common
independent variable known as parametric variable. In the parametric form, the representation is
done by a set of functions. A curve may be represented by
x = x (u)
y = y (u)
z = z (u)
Where x, y, z are co-ordinates of the points on the curve which are functions of some parameter
u and the parametric variable is constrained in the interval. For example, a point (x, y) is located
at an angle θ from +X axis on a circle with centre at (0, 0) and radius = 1 can be described in
parametric form as:
x = Cos θ
y = Sin θ
Where θ is the parameter. Surfaces are described similarly for which x, y and z are functions two
independent parameters u and v. Parametric design is very popular in computer aided design for a
variety of reasons, which are listed below:
1. Separation of variables
2. Each variable is treated alike
3. More degrees of freedom/control
4. Parametric equations can be transformed directly
5. Infinite slopes can be handled without computational breakdown
6. Easy to express as vectors
7. Amenable to plotting and digitizing
8. Inherently bounded

2.10 DESIGN OF CURVED SHAPES


Design of curved shapes should satisfy the following requirements:
i. It should be possible to represent the shape mathematically.
ii. The modeling should involve minimum computation.
iii. It should be possible to generate a CNC program to machine the surfaces (2, 3, 4 and 5 axis
machining) or to prepare a mould or die to make the part (as in plastic injection molding or
casting or automobile panel pressing).
12
Academic Year: 2022-2023 Regulation IFETCE 2019

A component can be designed using the curves and shapes which can be mathematically described
e.g. arc, circle, and conics, ellipsoid, hyperbolic parabolic, sphere, and cone, cylinder, linear, conical
- and circular swept surfaces etc. However very often the designer starts with specifying a few points
which roughly describe the shape.
Two approaches are available to designers to model curves and surfaces in such cases:
Interpolation and approximation. The interpolation essentially tries to pass a curve on a surface
called interpolant through all these points. Approximation tries to fit a smoother curve on surface
which may be close to these points but may not actually pass through each of them. Fig.11 illustrates
the difference between interpolation (a) and approximation (b).

Fig. 11 Interpolation and Approximation

One of the popular methods of interpolation is to use the Lagrange polynomial, which is the unique
polynomial of degree n passing through n + 1 points. However, Lagrange polynomial is unsuitable in
modeling of curves because of:
i. Large number of computations involved and
ii. Tendency for the curve to oscillate between data points when the data points are large.
Another approach is to look for a polynomial of fewer degrees than W passing through these
W + 1 data points. This is done by combining polynomials of lesser degree passing through several
consecutive data points and smoothly piecing several such curve segments together by blending. In
general, the modeling of curves is done to satisfy the following:
i. Axis independence
ii. Global and local control
iii. Smoothness of curves
iv. Versatility
v. Continuity between adjoining segments of curve.

2.11 CUBIC SPLINES


Splines are functions that are used for fitting a curve through a number of data points. A cubic spline
has the property that the three co-ordinate functions x (u), y (u), and z (u) are each cubic polynomial
in the variable u:
x (u) = a u3 + b u2 + c u + d
y (u) = e u3 + f u2 + g u + h
z (u) = j u3 + k u2 + l u + m

13
Academic Year: 2022-2023 Regulation IFETCE 2019

Whereas parametric curves are generally considered to be defined over an infinite range of
parameter values of u, it is always necessary to limit these to a finite interval when modeling shapes
on a computer. The domain u is, therefore taken as 0 < u < = 1 in the discussion that follows:
A spline passes through two end points and satisfies differentially condition at these end points.
These four conditions require a polynomial degree of at least 3. The derivations of cubic splines for
x, y and z are similar. The difference will be only in the end point coordinates and derivatives at the
end points. Therefore only the derivation of x(u) is considered here.

2.12 HERMITE CURVE


Let x(0), x(1), x’(0) and x’(1) are the end points and the derivatives at the end points respectively.
Since x(u) = au3 + bu2 + cu + d, we get
x (0) = d
x (1) = a + b + c + d
x’(0) = c
x’(1) = 3a + 2b + c
The above equations can be solved to obtain the four equations given below:
a = 2X(0) – 2X(1) + X’(0) + X’(1)
b = –3X(0) + 3X(1) – 2X’(0) – X’(1)
c = X’(0)
d = X(0)
or

The coefficients of cubic spline polynomials y(u) and z(u) are similarly obtained by replacing x data
by y and z data.
In a vectorial form the parametric cubic curve can be expressed as:
P (u) = au3 + bu2 + cu + d -- Where u∈ (0,1)
3 2 1
P (u) = [u u u ] [ a b c d]T
Let
U = [u3 u2 u1] and A = [a b c d]T
P=UA

Curves are defined by interpolating points and tangents at these points. The parametric
cubic curve can be designed using the four vectors P(0), P(1), P’(0) and P’(1). Each one of these
vectors has three components.
P0 = d
P1 = a + b + c + d
P’(0) = c
P’(1) = 3a + 2b + c

14
Academic Year: 2022-2023 Regulation IFETCE 2019

P = (2u3 –3u2 + 1)P0+ (–2u3 + 3u2 )P1+ (u3– 2u2+u) P’0+ (u3– u2) P’1
Let F1 = 2u3 – 3u2 + 1
F2 = -2u3 + 3u2
F3 = u3 – 2u2 + u
F4 = u3 – u2
then P = F1 P0 + F2 P1 + F3 P’ + F4 P’
Let F = [F1 F2 F3 F4 ] and B = [ P0 P1 P’0 P’1]
Then P = F B
F1, F2, F3, F4, are called blending function or Hermite polynomial basis functions. B is the matrix of
geometric coefficients. F is the blending function matrix. The blending function matrix F can be
written as the product of two matrices.
F=UM
Where

Where M is called universal transformation matrix.


Therefore P = U M B
P=UA
Hence A = M B
And conversely
B = M–1 A
Where

For a given set of end points P0 and P1 and slopes P’0 and P’1 several sets of curves can be
generated by varying the magnitude of the tangent vectors. (unit tangent vector t = Pu / |Pu| ).
Figure 12 shows a cubic spline connecting four points. There are several other formulations of cubic
splines. Ferguson used cubic polynomials for curve and surface design in aircrafts. However, these
methods generally suffer from the fact that they do not allow the user to change the smoothness of
the curve.

Fig. 12 Cubic Spline

15
Academic Year: 2022-2023 Regulation IFETCE 2019

2.13 BEZIER CURVE


Bezier curves, developed by P.Bezier at Ranault Automobile Company and P. de Casteljau at
Citreon, France are used for curve and surface design of automobile panels. A Bezier curve is
blended at the joints and is completely defined by four consecutive points (X0, Y0), (X1,y1),
(X2,Y2), (X3,Y3). The curve passes only through the first and fourth point.
The two intermediate points are used to define the slope of the curve at the end points. If X0, X1, X2
and X3 are the X- co-ordinates of the control points, it is assumed that:
i. The curve passes through the end points X0 and X3
ii. The slope at the points are:
X’(0) = 3(X1 – X0)
X’(1) = 3(X3– X2)
Using these properties, the coefficients of Bezier curve for x term can be expressed as :

The cubic polynomial x(t) in the Bezier form can be expressed as :

The advantages of Bezier curve over cubic spline is that the direction of the curve at the joints can be
defined and changed simply by specifying the position of the second and third data points. Changing
a control point not only affects the shape of the curve near the control point but has an influence
throughout the curve.
This lack of local control is a major weakness of Bezier curve. Fig. 13 shows Bezier cubic segments
for two sets of values of X.

Fig. 13 Bezier Curve


The Bezier cubic segment discussed above is a special case of the more general Bezier polynomial
curve segment

16
Academic Year: 2022-2023 Regulation IFETCE 2019

( ) ∑ ( )

Where u ∈ [0, 1]
With blending functions: Bi,n (u) = C(n,i) ui (1 – u)n-i
Where n is the binomial coefficient
( ) ( )
And p (u) are the control points and there are n+1 of them defining the vertices of the characteristic
polygon.
This generates what is known as piecewise polynomial. The N (u) blending functions are defined
recursively as:
( )
=0 otherwise
( ) ( ) ( ) ( )
( )

The resulting parametric polynomials are of degree (k - 1). The t are called knot values.
For an open curve there are

The blending functions confine the effects of a control point movement to the immediate locale.
Thus the curve change shape is local and not global as it is for Bezier curves.

When the control points are distinct, this curve is continuous in slope and in curvature between
successive segments but it does not pass through any of the intermediate control points. The cubic β-
spline has the advantage that the control points may be moved without affecting slope and curvature
continuity and only four spans of the overall curve will be affected by the change. Moreover, by
allowing two control points to coincide it is possible to create a curvature discontinuity. A slope
discontinuity, similarly, can be introduced by choosing three successive control points to be
coincident.
It is possible to represent complex curve shapes by considering composite curves constructed from
individual segments, in the case of cubic spline, Bezier and B-spline techniques.

2.14 B-SPLINE CURVES:


17
Academic Year: 2022-2023 Regulation IFETCE 2019

This form of cubic segments uses a third set of basic functions different from the types discussed
earlier. A cubic β-spline curve is a special case of spline curve. The equation for this curve can be
written as:

( ) ∑ ( )

∈ ( )

This generates what is known as piecewise polynomial. The N (u) blending functions are defined
recursively as:
( )
= 0 otherwise

( ) ( ) ( ) ( )
( )

The resulting parametric polynomials are of degree (k - 1). The t is called knot values.
For an open curve there are

The blending functions confine the effects of a control point movement to the immediate locale.
Thus the curve change shape is local and not global as it is for Bezier curves.

When the control points are distinct, this curve is continuous in slope and in curvature between
successive segments but it does not pass through any of the intermediate control points. The cubic β-
spline has the advantage that the control points may be moved without affecting slope and curvature
continuity and only four spans of the overall curve will be affected by the change. Moreover, by
allowing two control points to coincide it is possible to create a curvature discontinuity. A slope
discontinuity, similarly, can be introduced by choosing three successive control points to be
coincident.
It is possible to represent complex curve shapes by considering composite curves constructed from
individual segments, in the case of cubic spline, Bezier and B-spline techniques.

2.15 NURBS AND β-SPLINES


Two important surface representation schemes exist that extend the control of shape beyond
movement of control vertices. These are NURBS (Non Uniform Rational β-Splines) and β- splines.
In the case of NURBS a local vertex is extended to a four dimensional co-ordinate, the extra
18
Academic Year: 2022-2023 Regulation IFETCE 2019

parameter being a weight that allows a subtle form of control which is different in effect to moving a
control vertex. In the simplest form of β-spline control two global parameters (bias and tension) are
introduced which affect the whole curve.

NURBS
A non-uniform β-spline curve is defined on a knot vector where the interior knot spans are not equal.
A rational β-spline is defined by a set of four dimensional control points.
P = (Wi Xi , Wi Yi , Wi Zi , Wi )
The perspective map of such a curve in three dimensional space is called a rational β-spline curve.

Rational β- splines have the same analytical and geometric properties as non-rational β- splines.
Wi associated with each control point is called a weight and can be viewed as an extra shape
parameter. Wi affects the curve only locally and can be interpreted geometrically as a coupling
factor. The curve is pulled towards a control point if W increases.
β- SPLINES
β- splines are obtained from β-splines by introducing two new degrees of freedom: bias and tension.
These can be applied uniformly or non-uniformly.

2.16 REPRESENTATION OF SURFACES


A surface can be defined as the locus of points which satisfy a constraint equation in the form of
F(X, Y, Z) = 0. In parametric form a surface may be represented as
x = X (u, v)
y = Y (u, v)
z = Z (u, v)
where X, Y and Z are suitable functions of two parameters u and v. For example, the parametric
representation of the surface of a sphere whose centre is at the origin of coordinates and of radius R
is
x = X (θ, φ) = R sin φ cos θ
y = Y (θ, φ) = R sin φ sin θ
z = Z (θ, φ) = R cos φ

The design of surfaces may be based on quadrics like ellipsoid, hyperboloid, cone, hyperbolic
cylinder, parabolic cylinder, elliptic cylinder and elliptic paraboloid. A surfacemay be generated by

19
Academic Year: 2022-2023 Regulation IFETCE 2019

sweeping a pattern curve along a spline curve. The swept surfacemay also be linear, conical linear or
circular swept surface.

2.16.1 PARAMETRIC DESIGN OF SURFACES


Parametric surfaces may be defined in one of the following methods:
1. In terms of points of data (positions, tangents, normal)
2. In terms of data on a number of space curves lying in these surfaces.
The resulting surface will either interpolate or approximate the data. Surfaces are normally designed
in patches, each patch corresponding to a rectangular domain in u-v space. A surface patch defined
in terms of point data will usually be based on a rectangular array of data points which may be
regarded as defining a series of curves in one parameter direction which in turn are interpolated or
approximated in the direction of the other parameter to generate the surface. Fig 14 shows the
parameter curves on a surface patch defined by a rectangular array of data points.

Fig. 14 Surface Patch

2.16.2 BICUBIC POLYNOMIAL SURFACE PATCHES


A general representation of bicubic surface patch is:
r = R (u, v) = U M A M VT
Where M is the basis matrix
U = [1 u u2 u3]
A = aij
V = [1 v v2 v3]
For Coon’s patch, the basis function M is identical to that of cubic spline segment.

the vector coefficients for coon’s patches are given by

20
Academic Year: 2022-2023 Regulation IFETCE 2019

The position and derivative data on two adjacent corners effectively define not only the edge curve
which joins them but also the cross slope at each point on the edge. This makes it possible to
combine two or more patches with continuity of position and slope.

2.16.3 BEZIER BICUBIC SURFACE PATCHES


The Bezier bicubic surface patch uses the basis matrix:

The vector coefficients are given by a 4 × 4 matrix of position vectors for sixteen points forming a
characteristic polyhedron. Fig. 15 shows the characteristic polyhedron for a Bezier surface. The four
corner points R (0,0), R (3,0), R (3,3) and R (0,3) lie at the corners of the surface patch itself
whereas remaining points do not lie on the patch. The four points along each edge of the polyhedron
define the four edge curves of the patch. The four interior points determine the cross derivatives at
the corner and cross slopes along the nearest edges to them.

Fig. 15 Bi-cubic Surface Patch

2.16.4 CUBIC B-SPLINE SURFACES


The basis function for a cubic B-spline surface is the same as that of cubic B-spline curve. As in the
case of B-spline curve, none of the control points forming the characteristic polyhedron lies on the
surface. Composite surfaces can be obtained by combining several surface patches.

2.16.5 SURFACE MODELING IN COMMERCIAL DRAFTING AND MODELING


SOFTWARE
Surface types available for geometric modeling range from simple planes to complex sculptured
surfaces. These surfaces are usually represented on the workstation terminals as a set of ruled lines.
However, computer recognizes these lines as continuous surfaces. Users select surface types from a
menu to model individual details or fully envelope parts. Some of the features of surface modeling
packages are given below:

2.16.6 SURFACE MODELING COMMANDS


There are a number of commands to create a surface model

21
Academic Year: 2022-2023 Regulation IFETCE 2019

i. 3-D face: The different faces of an object can be modeled using this command. The X,Y,Z co-
ordinates of each vertex are input one after another to model a face and each of the faces is defined
one after another in this manner.
ii. P face: The P-face command produces a general polygon mesh of a arbitrary topology. Using this
command, it is possible to avoid defining a single vertex several times as is done in 3-D face
command. The user defines all vertices and then defines the faces in terms of the vertices.
iii. Rulesurf: This command creates a polygon representing the ruled surface between two curves.
Figure 16 shows an example of ruled surfaces.

Fig.16 Ruled Surface

iv. Tabsurf: A polygon mesh representing general tabulated mesh defined by a path curve and a
direction vector (generatrix) is created by this command. Fig. 17 shows a typical surface created by
this command.

Fig. 17 Examples of Tabulated Surface

v. Revsurf: A surface of revolution is created by rotating a path curve or profile about an axis. The
rotation can be through 360 degrees or part of it.
vi. Edgesurf: This command constructs a Coon’s surface patch using four adjoining curved edges,
an example of edge surf commands is shown in Fig.18.

Fig. 18 Example of Edge Surface

22

You might also like