Computer Graphics
Computer Graphics
Computer Graphics
(MCA)
Gajendra Sharma
Assistant Professor
Department of IT
Biyani Girls College, Jaipur
2
Published by :
Think Tanks
Biyani Group of Colleges
Edition : 2012
While every effort is taken to avoid errors or omissions in this Publication, any mistake or
omission that may have crept in is not intentional. It may be taken note of that neither the
publisher nor the author will be responsible for any damage or loss of any kind arising to
anyone in any manner on account of such errors and omissions.
Preface
I am glad to present this book, especially designed to serve the needs of
the students. The book has been written keeping in mind the general weakness
in understanding the fundamental concepts of the topics. The book is self-
explanatory and adopts the “Teach Yourself” style. It is based on question-
answer pattern. The language of book is quite easy and understandable based
on scientific approach.
Any further improvement in the contents of the book by making corrections,
omission and inclusion is keen to be achieved based on suggestions from the
readers for which the author shall be obliged.
I acknowledge special thanks to Mr. Rajeev Biyani, Chairman & Dr. Sanjay
Biyani, Director (Acad.) Biyani Group of Colleges, who are the backbones and
main concept provider and also have been constant source of motivation
throughout this endeavour. They played an active role in coordinating the various
stages of this endeavour and spearheaded the publishing work.
I look forward to receiving valuable suggestions from professors of various
educational institutions, other faculty members and students for improvement of
the quality of the book. The reader may feel free to send in their comments and
suggestions to the under mentioned address.
Gajendra Sharma
4
Syllabus
MCA
Computer Graphics
Visibility , Image and object precision Z- buffer algorithm. Floating horizons. Computer
Animation: Design of Animation Sequences. General Computer Animation Functions-Raster
Animations. Key Frame Systems. Morphing Simulating Accelerations. Motion
Specifications. Kinematics and Dynamics.
5
Chapter 1
Ans
The Primary output device in Computer Graphics is a Monitor which operates on
the standard cathode-ray tube(CRT) design and a few more technological
hardware have also come into the concept.
Computer graphics is a complex and diversified technology.
The heated metal cathode and a control grid are the key components of an electron
gun in a CRT. Through the coil of wire, called the filament, inside the cylindrical
cathode structure, heat is supplied to the cathode by directing a current which
makes electrons to be 'boiled off" the hot cathode surface. The free, negatively
charged electrons are then accelerated toward the phosphor coating by a high
positive voltage, in the vacuum inside the CRT envelope. The accelerating voltage
can be generated with a positively charged metal coating on the inside of the CRT
envelope near the phosphor screen, or an accelerating anode can be used, as in
Figure. Most of the times the electron gun is meant to contain the accelerating
anode and focusing system within the same unit. Intensity of the electron beam is
maintained by keeping voltage levels on the control grid, which is a metallic
cylinder and that fits over the shape of the cathode. A high negative voltage
applied to the control grid shuts off the beam as it repels electrons and stops them
from passing through the small hole at the end of the control grid structure. A
smaller negative voltage on the control grid alltogetherly decreases the total
number of electrons passing through it. Since the amount of light emitted by the
phosphor coating depends on the number of electrons which strike the screen, the
brightness of a display can be controlled by changing the voltage on the control
grid. In the electron beam, electrons spread all over the screen as a result of
repulsion among them. To make the electron beam strike at one point, focusing
anode is present in the CRT. Hence our focusing mechanism makes the electron
beam to strike the phosphor screen at a small spot and focusing is following by
usage of magnetic and electric field. Magnetic deflected is carried out by using 2
pairs of magnetic coils within the CRT. One pair is on the top and down position
7
and the other one pair is on the opposite sides of CRT as it is shown in the Figure
Magnetics field thus produced by each pair creates a transverse deflection force,
perpendicular to the way of magnetic field and to the direction in which the
electron bean is travelling. Moreover Horizontal deflection of electron bean is
accomplished by one pair of coils and vertical deflection is carried out by the
others.
Electric deflection is carried out by using two pairs of deflecting plates inside
CRT, the two pairs are mounted vertically and horizontally.
Horizontal deflecting plates provide vertical deflection to the electron beam and
vertical deflecting plates provide horizontal deflection to the electron beam.
Important terminologies in CRT are as follows:
Dot Pitch: It denotes the distance which marks separation between two phosphor
dots of the same color. A dot pitch equal to or less than .25mm is of use
comfortably, whereas we should avoid monitors with a dot pitch equal to or
greater than 0.28 mm.
Refresh rate: It denotes the number of images which are displayed every second,
or we can say that it is the number of times the images is remapped per second.
And It is also known as vertical scan rate and is expressed in Hertz (Hz).
Resolution : It denotes the number of pixels per surface unit and can be
abbreviated as DPI or dots per inches and is calculated both vertically and
8
horizontally. A resolution of 200dpi means that 200 columns and 200 rows of
pixels per square
Size : It is calculated by taking the dimension of the diagonal of the screen and is
expressed
Aspect Ratio : It is termed as the ratio of vertical points to horizontal points.
The range of the intensity depends upon the system capabilities. We can plot only
two different colors or intensities if it is a black and white system. In this case one
bit per pixel is enough, 1 for white intensity and bit value „0‟ for black intensity.
More bits can be used to display color and intensity for colors. So, bitmap is the
term used for frame buffer for black and white systems and Pixmap is the term
which is used for Frame buffer which stores multiple bits per pixel.
For raster system the refresh rate is generally 60 to 80 frames per second, it can be
higher for some systems. After it scans one row and it returns to the left of the
screen for scanning next row, it is called horizontal retrace. After it has refreshed
each scan line, it moves to the top left corner of the display and again starts the
refreshing process and this is called vertical retrace.
9
Raster scan systems are much more capable than the random systems. As it stores
the intensity values for each screen position, it is capable of displaying the color
variations and shade which is not possible with random systems. But raster system
has lower resolution as compared to random system. This is because, random
system follows the line path to be drawn and line drawing commands are stored in
refresh buffer. For raster system, intensity values are stored for each screen
The electron beam is swept across The electron beam is projected0 only
the screen, one row at a time from to the parts of the screen where a
top to bottom. picture is to be drawn.
Q.5 Write short note on Color CRT Monitor. Explain Shadow Mask Method.
Chapter 2
Output Primitives
Q.1 Explain in details the Line Drawing Algorithms using DDA Algorithm.
Ans.: Straight Line Equation in the form of Slope intercept is as follows:
y=mx+b ------------1
where m represents the slope of the line and b as the y intercept which it
makes with the Y axis. The two end point of a line segment are denoted by
the positions (x1, y1) and (x2, y2) as shown in the following diagram. Using
this Equation we can determine values for the slope m and y intercept b
using the following calculations.
y 2 - y1
M= ----2 y2
x 2 - x1
b = y1 – mx1 -----3 y1
Value of y is calculated
∆y – m . ∆x _ _ _ (4) x1 x2
As we did for DDA algorithm, here also we start with I octant where slope
, m<1. Since m<1, we move in x-direction by sampling at unit x intervals.
17
Thus we start plotting from initial, say(x0-y0) and take steps in success x-
columns an plot the point whose y-values is closest to the ideal line path.
13 Specified Line
11 49 Path
10 48
10 11 12 13 50 51 52 53 53
Figure.5 Figure.6
We first consider the scan conversion process for lines with positive slope
less than 1 to illustrate Bresenham’s approach. Pixel position along a line
path are then determined by sampling at unit x intervals starting form left
and point (x0 , y0) of a given line, we step at each successive column (x
position) & plot the pixel whose scan line y is closest to the line path. Now
assuming we have to determine that the pixel at (xk , yk) is to be displayed,
we next need to divide which pixel to plot in column x k+1. Preference
would be at the position (xk+1 , yk) and (xk+1 , yk+1). At sampling position
xk+1, we label vertical pixel separations from the mathematical line path as
d1 and d2. Figure.(8).
Since ∆x > 0 for our example Parameter C is constant & has the value 2∆y
+ ∆x (2b -1), which is independent of pixel position.
If the pixel position at yk is closer to line path than the pixel at yk+1 (that is
d1 < 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 owner in unit steps in either the x or directions. Therefore we can
obtain the values of successive decision Parameter using incremental
integer calculations. At step k = 1, the decision Parameter is evaluated
form eq.(12) as :
Pk+1 = 2∆y . xk+1 - 2∆x . yk+1 + C
yk+1 • d2
y • d1
yk •
xk+1 Figure.8
Subtracting eq.(12) 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) _ _ _ (13)
P0 = 2∆y - ∆x _ _ _ (14)
The following lines express how does Bresenham’s Line Drawing
Algorithm work for m <1 :
Take input for two endpoints of a line & store the left end point in (x 0 , y0).
Load (x0 , y0) into frame buffer that is plot the first point. Calculate
19
constants ∆x, ∆y, 2∆y and 2∆y - 2∆x and obtain the starting value for the
decision parameter as : P0 = 2∆y - ∆x. At each xk along 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 = Pk + 2∆y otherwise the next point to plot is (xk+1 , yk+1) and Pk+1
= Pk +2∆y - 2∆x. Repeat step 4 ∆x times.
Q.3 Digitize the line with end points (20, 10) & (30, 18) using Bresenham’s
Line Drawing Algorithm.
y -y 18 - 10 8
Ans.: slope of line, m = 2 1 = = = 0.8
x 2 - x1 30 - 20 10
∆x = 10 , ∆y = 8
Initial decision parameter has the value
P0 = 2∆y - ∆x = 2x8 – 10 = 6
Since P0 > 0, so next point is (xk + 1, yk + 1) (21, 11)
Now k = 0, Pk+1 = Pk + 2∆y - 2∆x
P1 = P0 + 2∆y - 2∆x
= 6 + (-4)
= 2
Since P1 > 0, Next point is (22, 12)
Now k = 1, Pk+1 = Pk + 2∆y - 2∆x
P2 = 2 + (- 4)
= -2
Since P2 < 0, Next point is (23, 12)
Now k = 2 Pk+1 = Pk + 2∆y
P2 = - 2 + 16
= 14
Since P3 > 0, Next point is (24, 13)
K Pk (xk+1, yk+1)
0 6 (21, 11)
1 2 (22, 12)
2 -2 (23, 12)
3 14 (24, 13)
4 10 (25, 14)
5 6 (26, 15)
6 2 (27, 16)
7 -2 (28, 16)
8 14 (29, 17)
9 10 (30, 18)
Plot the graph with these following points.
Q.4 Explain how does the Mid Point Circle Algorithm work.
Ans.: The equation of a circle can be given as follows, where (xc,yc) represents
the centre coordinates.
(x – xc)2 + (y – yc)2 – r2 = 0
In the following way the calculation is made for the position of points
along the circlular path by moving in the x direction from (x c - r) to (xc + r)
and determining the corresponding y values as :
y = yc (x c - x)2 - r 2
For a given radius r & screen center position (xc, yc). We first set our
Algorithm to calculate the position of points along the coordinate position
(x0, y0). These calculated positions are then placed at this proper screen
position by adding xc to x and yc to y. For a circle from x = 0 to x = y in
first quadrant, the slope varies from 0 to 1.
45º
x (x = 0)
(-x, -y) (x, -y)
yk
yk -1
xk xk+1 xk+2
Taking an assumption that we have just plotted a pixel at (xk, yk). We next
need to determine whether the pixel (xk+1, yk) or (xk+1, yk-1) is closer. Our
decision parameter is the circle function evaluated at the mid point
between these two pixels.
Pk = fcircle (xk + 1, yk - ½)
Or Pk = (xk + 1 )2 +(yk - ½)2 – r2 _ _ _ (3)
This denotes that If Pk < 0, Mid point is inside the circle boundary and the
pixel on the scan line yk is closer to the circle boundary. Otherwise, Mid
point is on or outside the circle boundary and the point on the scan line
yk - 1 is closer. Successive decision parameters are obtained by
incremental calculations. Again the next deciding parameter is calculate
the position at next sampling position by taking the next position.
xk+1 + 1 = xk + 2
Pk+1 = fcircle(xk+1 + 1, yk+1 - ½)
Or Pk+1 = [(xk + 1) + 1]2 + (yk+1 - ½)2 – r2
Or Pk+1 = Pk + 2(xk + 1) + (yk+12 – yk2) – (yk + 1 – yk) + 1 _ _ _ (4)
Successive increment for Pk is 2xk+1 +1(If Pk < 0) otherwise (2xk+1 +1 - 2yk+1)
where
2xk+1 = 2xk + 2 & 2yk+1 = 2yk – 2
Initial decision parameter P0 is obtained as (0, r) = (x0, y0)
23
P0 = fcircle(x, y) = fcircle (1, r - ½) = 1 + (r - ½)2 – r2
5
Or P0 = -r
4
If r is a integer then P0 = 1 – r
Algorithm for this can be defined in the following steps for calculating
the Mid Point:
(1) Input radius r and circle center ( xc, yc) and obtain the first point on
circumference of a circle centered on origin (x0, y0) = (0, r)
5
(2) Calculate the initial value of the decision parameter as : P0 = -r
4
(3) At each xk position, starting at k = 0 if Pk < 0 the next point along
the circle is (xk+1, yk) and Pk+1 = Pk + 2xk+1 + 1, otherwise the next
point along the circle is (xk + 1, yk - 1) and Pk+1 = Pk + 2xk+1 + 1 –
2yk+1 where 2xk+1 = 2xk + 2 & 2yk+1 = 2yk – 2.
(1) Determine symmetry points in other seven octants.
(2) Move each calculated pixel position (x, y) onto the circular path
centered on (xc, yc) & plot coordinate values x = x + xc & y = y + yc.
(3) Repeat step (3) through (5) until x ≥ y.
Q.5 Demonstrate the Mid Point Circle Algorithm with circle radius, r = 10.
Ans.: P0 = 1 – r =1 - 10 = - 9
Now the initial point (x0, y0) = (0, 10) and initial calculating terms for
calculating decision parameter are
2x0 = 0 , 2y0 = 20 Since Pk < 0, Next point is (1, 10)
P1 = - 9 +3 = - 6 Now P1 < 0, Next point is (2, 10)
P2 = - 6 + 5 = - 1 Now P2 < 0, Next point is (3, 10)
P3 = -1+ 7 = 6 Now P3 > 0, Next point is (4, 9)
P4 = 6 + 9 - 18 = - 3 Now P4 < 0, Next point is (5, 9)
P5 = - 3 + 11 = 8 Now P5 > 0, Next point is (6, 8)
P6 = 8 +13 - 16 = 5 Now P6 > 0, Next point is (7, 7)
2 (3, 10) 6 20
3 (4, 9) 8 18
4 (5, 9) 10 18
5 (6, 8) 12 16
6 (7, 7) 14 14
Plot the graph with these points.
ry
yc
rx
rx
25
xc x
2 2
x - xc y - yc
+ =1 _ _ _(4)
rx ry
Now using polar coordinates r & θ
Parameter equations are :
x = xc + rx cos θ
y = yc + ry sin θ
Mid Point Ellipse Algorithm
(-x, y) (x, y)
Region1
Slope = -1
ry
Region2
rx
Figure Figure
yk
•
yk-1 mid
point
xk xk+1 Figure.:1
P1k = fellipse( xk + 1, yk – ½) = ry2( xk + 1)2 + rx2 (yk - ½)2 – rx2ry2 _ _ _ (8)
Next symmetric point (xk+1 +1, yk+1 - ½)
P1k +1 = ry2 [(xk + 1) + 1]2 + r2x [(yk +1 – ½)2 (yk – ½)2] _ _ _ (9)
Where yk + 1 is either yk or yk -1 depending on sign of P1k
2ry2 xk+1 + ry2 if Pk < 0
Increments =
2ry2 xk+1 – 2rx2 yk+1 + ry2 if Pk ≥ 0
With initial position (0, ry) the two terms evaluate to
2ry2x = 0 , 2rx2y = 2rx2ry
Now when x & y are incremented the updated values are
2ry2 xk+1 = 2ry2 xk + 2ry2 , 2rx2 yk+1 = 2rx2 yk – 2rx2
And these values are compared at each step & we move out of Region 1
when condition (7) is satisfied initial decision parameter for region 1 is
calculated as :
27
P10 = fellipse(x0, y0) = (1, ry – ½) = ry2 + rx2( ry - ½)2 – rx2 ry2
P10 = ry2 – rx2 ry + ¼ rx2 _ _ _ (10)
Over Region 2, we step in (-)ve y-direction & mid point selected is
between horizontal pixel positions
P2k = fellipse(x, y) = (xk + ½, yk – 1)
P2k = ry2(xk + ½)2 + rx2( yk – 1)2 – rx2ry2 _ _ _ (11)
yk
yk-1 •
xk xk+1
If P2k > 0 then we select pixel at xk +1
Initial decision parameter for region (2) is calculated by taking (x0, y0) as
last point in Region (1)
P2k + 1 = fellipse(xk+1 + ½, yk+1 –1) = ry2(xk+1 + ½)2 + rx2[(yk – 1) -1]2 – rx2ry2
P2k + 1 = P2k – 2rx2(yk – 1) + rx2 + ry2[(xk +1 + ½)2 – (xk + ½)2] _ _ _ (12)
At initial position (x0, y0)
P20 = fellipse(x0 +½, y0 – 1) = ry2( x0 + ½)2 + rx2(y0 – 1)2 – rx2ry2 _ _ _ (13)
(4) Calculate the initial value of the decision parameter in region (2)
using last point (x0, y0) calculated in region 1 as P20 = ry2 (x0 +
½)2 + rx2 (y0 – 1)2 – rx2ry2.
(5) At each yk position in region (2), starting at k = 0 perform following
test : If P2k > 0 next point is (xk, yk – 1) and P2k+1 = P2k – 2rx2yk + 1 +
28
rx2 otherwise next point is ( xk + 1, yk – 1) and P2k+1 = P2k + 2ry2xk +
1 – 2rx2yk+1 + rx2.
Q.7 Explain Why is DDA Algorithm not good & efficient Algorithm?
Ans.: (1) DDA traces out the successive x & y values by simultaneously
increasing x & y by small steps proportional to their first derivative.
dy
In our example the x increment is 1 but y increment is = m.
dx
since the real values have limited Precision, the accumulation of
round off error in “m” causes the accumulative error. Build up
which drifts the pixel positions from the true line path in most
lines.
(2) Moreover the round off operations & floating point incrementation
is still time consuming.
Q.8 What do you understand by Area Filling? Discuss any one Algorithm.
Ans.: A standard out put primitive in general graphics package is a solid-color
or patterned polygon area. There are two basic approaches to area filling
on raster system :
(1) To fill an area is to determine the overlap intervals for scan lines
that cross the area.
(2) Another is t start from a given interior position & point outward
from this point until we specify the boundary conditions.
30
Now scan line approach is typically used in general graphics package to
still polygons, circles, ellipses and simple curses.
Fill methods starting from an interior point are useful with more complex
boundaries and in interactive painting systems.
Boundary Fill Algorithm : Another approach to area filling is to start at a
point inside a region and paint the interior outward toward the boundary.
If the boundary is specified in a single color, the fill Algorithm precedes
outward pixel by pixel until the boundary color is encountered. This
method is called Boundary Fill Algorithm.
Boundary Fill Algorithm procedure accepts as input the coordinates of an
interior point (x, y), a fill color and a boundary color. Starting with (x, y),
neighboring boundary points are also tested. This process continues till all
the pixels up to the boundary color for the area is tested.
Diagram
Chapter 3
Replacing expressions 5-5 into 5-4, we obtain the transformation equations for
rotating a point at position (x, y) through an angle 9 about the origin:
With the column-vector representations 5-2 for coordinate positions, we can write
the rotation equations in the matrix form:
These general rotation equations differ from Eqs. 5-6 by the inclusion of additive
terms, as well as the multiplicative factors on the coordinate values. Thus, the
above matrix expression could be modified to include : pivot coordinates by
matrix addition of a column vector whose elements contain the additive
(translational) terms In Eqs. 5-9. There are better ways, however, to formulate
such matrix equations, and we discuss in Section 5-2 a more consistent scheme for
representing the transformation equations
Chapter 4
Two Dimensional Concepts Clipping
Algorithm
The region against which the object needs to be clipped is known as clip
window. We will assume here that clip window is a rectangular window
but it might be a polygon shaped as well and can have boundaries in the
curved form as well. Hence the objects which are not inside and are
outside the rectangular clip window are hence discarded. The various
clipping algorithms which are involved in the process of clipping are as
follows:
Point Clipping
Line Clipping
Polygon clipping
Text Clipping
Curve Clipping
Here are a few examples of the application of the clipping concepts which
are as follows:
(1) Creating objects using solid-modeling procedures.
(2) Drawing and painting operations.
(3) Identifying visible surface in three dimensional views.
(4) Antialising line segments or object boundaries.
(5) Extracting parts of defined scene for viewing.
(6) Displaying multi window environment.
35
P9
P4 P2
P10
P1
P8
P5 P5 P6
P3 P7
A line with both end points outside any one of the clip boundaries
(line P3, P4 in Figure.) is outside the window.
A line with both end points inside all clipping boundaries such as
line form P1 to P2 is saved.
And all the other lines that cross one or more clipping boundaries
and may require calculation of multiple intersection point.
For a line segment with end points (x1, y1) and (x2, y2) and one or
both end points outside clipping rectangle, the parametric
representation.Could be used to determine values of parameter u
for intersections with the clipping boundary coordinates.
x = x1 + u(x2 – x1)
y = y1 + u(y2 – y1), 0 ≤ u ≤ 1
Xmin Xmax
0000
0001 WINDOW 0010
W
0101 0100 0110
Code for inside the window region is 0000. Each regions is defined or
represented by 1 bit. First bit from left i.e., MSB is for the region above the
top edge. If this bit is 1, it means point is above the top edge or y>y max.
Each bit position in the region code is used to indicate one of the four
relative coordinate positions of the point with respect to the clip window:
to the left, right, top and bottom.
Second bit from left is for the region below the bottom
By numbering the bit position in the region code as 1 through 4 right to
left, the coordinate regions can be correlated with the bit positions as :
bit 1 : left ; bit 2 : right ; bit 3 : below ; bit 4 : above
A value of 1 in any bit position indicates that point is in that relative
position otherwise the bit position is set to 0.
Now here bit values in the region are determined by comparing
end point coordinate values (x, y) to the clip boundaries.
Bit 1 is set to 1 if x < xwmin
Bit 2 is set to 1 it xwmax < x
P2’’
P1’
P3 P3’ P1
P4
Q.4 Discuss the Cyrus Beck Algorithm for Clipping in a Polygon Window.
Ans. Cyrus Beck Technique : Cyrus Beck Technique can be used to clip a 2–D
line against a rectangle or 3–D line against an arbitrary convex polyhedron
in 3-d space.
Liang Barsky Later developed a more efficient parametric line clipping
Algorithm. Now here we follow Cyrus Beck development to introduce
39
parametric clipping now in parametric representation of line Algorithm
has a parameter t representation of the line segment for the point at which
that segment intersects the infinite line on which the clip edge lies,
Because all clip edges are in general intersected by the line, four values of t
are calculated. Then a series of comparison are used to check which out of
four values of (t) correspond to actual intersection, only then are the (x, y)
values of two or one actual intersection calculated.
Advantage of this on Cohen Sutherland :
(1) It saves time because it avoids the repetitive looping needed to clip
to multiple clip rectangle edge.
Ni • [P(t) – PEi] = 0
P0 Ni
□□□
43
Chapter 5
The Bezier blending functions BEZk,n (u) are the Bernstein polynomial.
BEZk,n(u) = C (n, k) uk (1 – u) n-k _ _ _ (2)
Where C(n,k) are the binomial coefficients
n
C( n ,k ) _ _ _ (3)
kn k
Equivalently we can define Bezier blending function with recursive
calculation :
BEZ k,n (u) = (1 – u) BEZ k,n-1 (u) + u BEZ k-1,n-1 (u) n > k ≥ 1 _ _ _ (4)
Three parametric equations for individual curve coordinates :
n n n
x(u) = ∑ xk BEZ k,n (u) y(u) = ∑ yk BEZ k,n (u) z(u) = ∑ zk BEZ k,n (u)
K=0 K=0 K=0
44
A Bezier Curve is a polynomial of degree one less than the number of
control points used.
Three points generates Parabola.
Four points generates Cubic Curve.
(a) (b)
Bezier Curves generated from three or four control points. Dashed lines
connect the control point positions.
Properties of Bezier Curve :
(1) It always passes through the first and last control points. That is
boundary condition at two ends of the curve are :
For two end points P (0) = P0
P (1) = Pn _ _ _ (6)
Now value for the first derivative of a Bezier Curve at the end
points can be calculated from control point coordinates as :
P’(0) = - nP0 +nP1 First derivative for the
Q.2 What are B-Spline Line, Curves and Surfaces? Write the properties of B-
Spline Curves?
Ans.: These are most widely used class of approximating splines B-splines have
two advantage over Bezier splines.
(1) The degree of a B – spline polynomial can be set independently of
the number of control points (with certain limitations).
(2) B – spline allow local control over the shape of a spline curve or
surface.
The trade of off is that B – splines are move complex than Bezier splines.
B – spline Curves : Blending function for B – spline curve is :
n
46
P (u) = ∑ Pk Bk,d (u) umin ≤ u ≤ umax
K=0 2 ≤ d ≤ n+1
Where the Pk are an input set of (n + 1) control points. There are several
differences between this B-spline formulation and that for Bezier splines.
The range of parameter u now depends on how we choose the B – spline
parameters. And the B – spline blending functions Bk,d are polynomials of
degree d – 1, where parameter d can be chosen to be any integer. Value in
the range from 2 up to the number of control points , n + 1, Local control
for B – splines is achieved by defining the blending functions over
subintervals of the total range of u.
Blending function for B – spline curves are defined by Cox – de Boor
recursion formulas :
1 if uk ≤ u ≤ uk+1
Bk,d (u) =
0 otherwise
u uk uk d u
Bk,d u Bk, d 1 u Bk=1,d 1 u
uk d 1 uk uk d uk 1
Where each blending function is defined over d subintervals of the total
range of u. values for umin and umax then depends on the number of control
points we select, we can increase the number of values in the knot vector
to aid in curve design.
We need to specify the knot values to obtain the blending function using
recurrence relation.
Classification of B – splines according to the knot vectors :
Uniform, Periodic B – splines : When spacing between knot values is
constant. The resulting curve is called a uniform B – spline.
For e.g. : { - 1.5, -1.0, -0.5, 0.0}
0.8
0.6
0.4
0.2
0 1 2 3
P (u) = [u3 u2 u 1] . MB . P1
P2
P3
P(0) = Pk
P(1) = Pk+1 _ _ _ (1)
P’(0) = DPk
P’(1) = DPk+1
With DPk and DPk+1 specifying values for the parametric derivatives
(slope of the curve) at control points Pk and Pk+1 respectively.
Vector equivalent equation :
P(u) = au3 + bu2 + cu + d 0≤u≤1 _ _ _ (2)
Where x component of P is x(u) = axu3 + bxu2 + cxu + dx and similarly for y
and z components. The Matrix is
a
P(u) = [u3 u2 u 1] b _ _ _ (3)
c
d
Derivative of the point function as :
a
P’(u) = [3u2 2u 1 0] b _ _ _ (4)
C PK
d P(u) = [x(u), y(u), z(u)]
PK+1
Figure.(1) Parametric point function P(u) for a Hermite curve section
between control point Pk and Pk+1.
a 0 0 0 1 -1 Pk Pk
b = 1 1 1 1 Pk+1 =MH Pk+1 _ _ _ (6)
c 0 0 1 0 DPk DPk
d 3 2 1 0 DPk+1 DPk+1
Where MH, the Hermite Matrix is the inverse of the boundary constraint
Matrix.
Pk
P(u) = [u3 u2 u 1] MH Pk+1
DPk
DPk+1
Q.5 Explain Zero Order, First Order, and Second Order Continuity in Curve
Blending?
Ans.: To ensure a smooth transition form one section of a piecewise curve to the
next. We can suppose various continuity conditions, at the connection
point. Each section of a spline is described with a set of parametric
coordinate function of the form :
x = x (u), y = y (u), z = z (u), u1 ≤ u ≤ u2 _ _ _ (1)
P2 P2
P3
P0 P3 P0
Convex Hall
P1 P1
Figure.(1) convex hull shapes for two sets of control points.
Parametric Continuity : We set parametric continuity by matching the
parametric derivative of adjoining section at their common boundary.
Zero – Order Parametric Continuity : Described as C0 continuity means
simply that curves meet. That is the values of x, y, z evaluated at u 2 for
first curve section is equal to values of x, y, z evaluated at u 1 for the next
curve section.
First – Order Parametric Continuity : Refered as C1 continuity means that
the first Parametric derivatives (tangent lines) of the coordinate functions
in eq.(1) for two successive curve sections are equal at their joining point.
Second - Order Parametric Continuity : Described as C2 continuity
means that both first and second parametric derivatives of the two curve
sections are the same at the intersection.
With second order continuity, the rates of change of the tangent vector for
connecting sections are equal at their intersection. Thus the tangent line
transitions smoothly from one section of the curve to the Next like in
Figure.(2).
52
Chapter 6
Computer Animations
Q1. Explain the Animation Sequence or rules for Animation
Ans
Animation sequence in general is designed in the following steps.
1. Storyboard layout
2. Object definitions.
3. Key-frame specifications
4. Generation of in-between frames.
The outline of the action is storyboard. This explains the motion sequence. The
storyboard consists of a set of rough structures or it could be a list of the basic
ideas for the motion.
For each participant in the action, an object definition is given. Objects are
described in terms of basic shapes the examples of which are splines or polygons.
The related movement associated with the objects are specified along with the
shapes.
And the intermediate frames between the key frames are In-betweens. And the
Media that we use determines the number of In-betweens which are required to
display the animation. A Film needs 24 frames per second, and graphics terminals
are refreshed at the rate of 30 to 60 frames per second. Depending on the speed
specified for the motion, some key frames are duplicated. For a one minutes film
sequence with no duplication, we would require 288 key frames. We place the key
frames a bit distant if the motion is not too complicated.
A number of other tasks may be carried out depending upon the application
requirement for example synchronization of a sound track.
Animation package also provides function to store and manage the object
database. And the shapes of the objects and the parameters which are associated to
them are stored and updated in the database. Other functions are implemented and
carry out motion generation and object rendering.
4) The relationship among the data and objects which are stored in the database
called application database, and referred by the?
A. Application programs
B. application model
C. graphics display
D. both a and b
10) RGB system needs __of storage for the frame buffer?
A. 100 megabytes
B. 10 megabytes
C. 3 megabytes
D. 2 Gb
11) The SRGP package provides the __to wide the variety of display devices?
A. interface
B. connection
C. link
D. way
15) The midpoint circle drawing algorithm also uses the __of the circle to generate?
A. two-way symmetry
B. four-way symmetry
C. eight-way symmetry
D. both a & b
16) a polygon in which the line segment joining any 2 points within the polygon lies
completely inside the polygon is called__?
A. convex polygon
B. concave polygon
C. both a and b
D. both a and b
17) A polygon in which the line segment joining any 2 points within the polygon may
not lie completely inside the polygon is called __?
A. convex polygon
B. concave polygon
C. both a and b
D. Hexagon
20) Line produced by moving pen is __ at the end points than the line produced by
the pixel replication?
A. thin
59
B. straight
C. thicker
D. both a and b
21) The process of selecting and viewing the picture with different views is called__?
A. Windowing
B. clipping
C. projecting
D. both a and b
22) The process which divides each element of the picture into its visible and
invisible portions, allowing the invisible portion to be discarded is called__?
A. clipping
B. Windowing
C. both a and b
D. Projecting
25) A method used to test lines for total clipping is equivalent to the__?
A. logical XOR operator
B. logical OR operator
C. logical AND operator
D. both a and b
26) A process of changing the position of an object in a straight line path from one
coordinate location to another is called__?
A. Translation
B. rotation
C. motion
D. both b and c
60
27) Data hazards occur when__?
A. Greater performance loss
B. Pipeline changes the order of read/write accesses to operands
C. some functional unit is not fully pipelined
D. machine size is limited
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
A B A A C B C A A C A C A A C
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
A B A A C A A A A C A C A A A
61
Glossary
2D Graphics
Displayed representation of a scene or an object along two axes of reference: height and width (x
and y).
3D Graphics
Displayed representation of a scene or an object that appears to have three axes of reference:
height, width, and depth (x, y, and z).
3D Pipeline
The process of 3D graphics can be divided into three-stages: tessellation, geometry, and
rendering. In the tessellation stage, a described model of an object is created, and the object is
then converted to a set of polygons. The geometry stage includes transformation, lighting, and
setup. The rendering stage, which is critical for 3D image quality, creates a two dimensional
display from the polygons created in the geometry stage.
Anti-aliasing
Anti-aliasing is sub pixel interpolation, a technique that makes edges appear to have better
resolution.
Bitmap
A Bitmap is a pixel by pixel image.
Blending
Blending is the combining of two or more objects by adding them on a pixel-by-pixel basis.
Depth Cueing
Depth cueing is the lowering of intensity as objects move away from the viewpoint.
Dithering
Dithering is a technique for archiving 24-bit quality in 8 or 16-bit frame buffers. Dithering uses
two colors to create the appearance of a third, giving a smooth appearance to an otherwise abrupt
transition.
Flat Shading
The flat shading method is also called constant shading. For rendering, it assigns a uniform color
62
throughout an entire polygon. This shading results in the lowest quality, an object surface with a
faceted appearance and a visible underlying geometry that looks 'blocky'.
Interpolation
Interpolation is a mathematical way of regenerating missing or needed information. For example,
an image needs to be scaled up by a factor of two, from 100 pixels to 200 pixels. The missing
pixels are generated by interpolating between the two pixels that are on either side of the pixel
that needs to be generated. After all of the 'missing' pixels have been interpolated, 200 pixels exist
where only 100 existed before, and the image is twice as big as it used to be.
Lighting
There are many techniques for creating realistic graphical effects to simulate a real-life 3-D object
on a 2-D display. One technique is lighting. Lighting creates a real-world environment by means
of rendering the different grades of darkness and brightness of an object's appearance to make the
object look solid.
Line Buffer
A line buffer is a memory buffer used to hold one line of video. If the horizontal resolution of the
screen is 640 pixels and RGB is used as the color space, the line buffer would have to be 640
locations long by 3 bytes wide. This amounts to one location for each pixel and each color plane.
Line buffers are typically used in filtering algorithms.
Projection
The process of reducing three dimensions to two dimensions for display is called Projection. It is
the mapping of the visible part of a three dimensional object onto a two dimension screen.
Rasterization
Translating an image into pixels.
Rendering
The process of creating life-like images on a screen using mathematical models and formulas to
add shading, color, and lamination to a 2D or 3D wireframe.
Transformation
Change of coordinates; a series of mathematical operations that act on output primitives and
geometric attributes to convert them from modeling coordinates to device coordinates.
Z-buffer
63
A part of off-screen memory that holds the distance from the viewpoint for each pixel, the Z-
value. When objects are rendered into a 2D frame buffer, the rendering engine must remove
hidden surfaces.
Z-buffering
A process of removing hidden surfaces using the depth value stored in the Z-buffer. Before
bringing in a new frame, the rendering engine clears the buffer, setting all Z-values to 'infinity'.
When rendering objects, the engine assigns a Z-value to each pixel: the closer the pixel to the
viewer, the smaller the Z value. When a new pixel is rendered, its depth is compared with the
stored depth in the Z-buffer. The new pixel is written into the frame buffer only if its depth value
is less than the stored one.
Z-sorting
A process of removing hidden surfaces by sorting polygons in back-to-front order prior to
rendering. Thus, when the polygons are rendered, the forward-most surfaces are rendered last.
The rendering results are correct unless objects are close to or intersect each other. The advantage
is not requiring memory for storing depth values. The disadvantage is the cost in more CPU
cycles and limitations when objects penetrate each other.
Filtering
This is a broad word which can mean the removal of coffee grinds from the coffee.
However, within the narrow usage of this book, a filtering operation is the same as a
convolution operation (see "convolution"). Anti-aliasing is usually done by filtering.
flat projection
A method of projecting a 3D scene onto a 2D image such that the resulting object sizes
are not dependent on their position. Flat projection can be useful when a constant scale is
needed throughout an image, such as in some mechanical drawings.
Frame
One complete video image. When interlacing is used, a frame is composed of two fields,
each containing only half the scan lines.
GIF
A file format for storing images. GIF stands for Graphics Interchange format, and is
owned by Compuserve, Inc.
key frame
A selected frame of an animation at which all the scene state is defined. In the key frame
animation method, the scene state at key frames is interpolated to create the scene state at
the in-between frames.
64
An animation control method that works by specifying the complete scene state at
selected, or key, frames. The scene state for the remaining frames is interpolated from the
state at the key frames.
Raster Scan
The name for the pattern the electron beam sweeps out on a CRT face. The image is made
of closely spaced scan lines, or horizontal sweeps.
Refresh Rate
The rate at which parts of the image on a CRT are re-painted, or refreshed. The horizontal
refresh rate is the rate at which individual scan lines are drawn. The vertical refresh rate is
the rate at which fields are drawn in interlaced mode, or whole frames are drawn in non-
interlaced mode.
The rate at which scan lines are drawn when the image on a CRT is re-drawn, or
refreshed.
The rate at which fields are re-drawn on a CRT when in interlaced mode, or the rate at
which the whole image is re-drawn when in non-interlaced mode.
Scan Line
One line in a raster scan. Also used to mean one horizontal row of pixels.
65
Bibliography
1. J. Foley, A. Van Dam, S. Feiner, J. Hughes: Computer Graphics- Principles and
Practice, Pearson
2. Hearn and Baker: Computer Graphics, PHI.