
































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































































L T/P/D C
3 -/-/- 3
Objectives:
CORE ELECTIVE – I
To make students understand about fundamentals of Graphics to enable them to design
animated scenes for virtual object creations.
To make the student present the content graphically.
Introduction: Application areas of Computer Graphics, overview of graphics systems, video-
display devices, raster-scan systems, random scan systems, graphics monitors and work
stations and input devices
Output primitives : Points and lines, line drawing algorithms, mid-point circle and ellipse
algorithms.Filled area primitives: Scan line polygon fill algorithm, boundary-fill and flood-fill
algorithms
2-D geometrical transforms : Translation, scaling, rotation, reflection and shear
transformations, matrix representations and homogeneous coordinates, composite transforms,
transformations between coordinate systems
2-D viewing : The viewing pipeline, viewing coordinate reference frame, window to view-port
coordinate transformation, viewing functions, Cohen-Sutherland and Cyrus-beck line clipping
algorithms, Sutherland –Hodgeman polygon clipping algorithm
3-D object representation : Polygon surfaces, quadric surfaces, spline representation, Hermite
curve, Bezier curve and B-Spline curves, Bezier and B-Spline surfaces. Basic illumination models,
polygon rendering methods.
3-D Geometric transformations : Translation, rotation, scaling, reflection and shear
transformations, composite transformations.3-D viewing : Viewing pipeline, viewing
coordinates, view volume and general projection transforms and clipping.
Visible surface detection methods : Classification, back-face detection, depth-buffer, scan-line,
depth sorting, BSP-tree methods, area sub-division and octree methods
Computer animation : Design of animation sequence, general computer animation functions,
raster animation, computer animation languages, key frame systems, motion specifications
and Hughes, Pearson Education.
Education.
Tata Mc-Graw hill edition.
nd
edition.
Outcomes:
Students can animate scenes entertainment.
Will be able to work in computer aided design for content presentation..
Better analogy data with pictorial representation.
Computer-Aided Design for engineering and architectural systems etc.
Objects maybe displayed in a wireframe outline form. Multi-window environment is also
favored for producing various zooming scales and views.
Animations are useful for testing performance.
Presentation Graphics
To produce illustrations which summarize various kinds of data. Except 2D, 3D graphics are good tools for reporting more complex data.
Computer Art
Painting packages are available. With cordless, pressure-sensitive stylus, artists can
produce electronic paintings which simulate different brush strokes, brush widths, and colors. Photorealistic techniques, morphing and animations are very useful in commercial
art. For films, 24 frames per second are required. For video monitor, 30 frames per
second are required.
Entertainment
Motion pictures, Music videos, and TV shows, Computer games
Education and Training
Training with computer-generated models of specialized systems such as the training of
ship captains and aircraft pilots.
Visualization
For analyzing scientific, engineering, medical and business data or behavior. Converting data to visual form can help to understand mass volume of data very efficiently.
Image Processing
Image processing is to apply techniques to modify or interpret existing pictures. It is
widely used in medical applications.
Graphical User Interface
Multiple window, icons, menus allow a computer setup to be utilized more efficiently.
Electrostatic deflection of the electron beam in a CRT
An electron gun emits a beam of electrons, which passes through focusing and deflection
systems and hits on the phosphor-coated screen. The number of points displayed on a CRT is
referred to as r esolutions (eg. 1024x768). Different phosphors emit small light spots of
different colors, which can combine to form a range of colors. A common methodology for
color CRT display is the Shadow-mask meth
Illustration of a shadow-mask CRT
The light emitted by phosphor fades very rapidly, so it needs to redraw the picture repeatedly.
There are 2 kinds of redrawing mechanisms: Raster-Scan and Random-Scan
The electron beam is swept across the screen one row at a time from top to bottom. As it
moves across each row, the beam intensity is turned on and off to create a pattern of
illuminated spots. This scanning process is called refreshing. Each complete scanning of a
screen is normally called a frame.
The refreshing rate, called the frame rate , is normally 60 to 80 frames per second, or
described as 60 Hz to 80 Hz.
Picture definition is stored in a memory area called the frame buffer. This frame buffer
stores the intensity values for all the screen points. Each screen point is called a pixel (picture
element).
On black and white systems, the frame buffer storing the values of the pixels is called a
bitmap. Each entry in the bitmap is a 1-bit data which determine the on (1) and off (0) of the
intensity of the pixel.
On color systems, the frame buffer storing the values of the pixels is called a pixmap
(Though nowadays many graphics libraries name it as bitmap too). Each entry in the pixmap
The basic concept is:
y = mx + c
according to the line equation. Thus we get the left end point as (x1,y1), where y1 may
not be an integer.
it D
it D
lower pixel, then, we set the upper pixel to on; otherwise we set the lower pixel to on.
point of the line.
In computer graphics, a hardware or software implementation of a digital differential analyzer
(DDA) is used for linear interpolation of variables over an interval between start and end point.
DDAs are used for rasterization of lines, triangles and polygons. In its simplest implementation
the DDA Line drawing algorithm interpolates values in interval [(xstart, ystart), (xend, yend)] by
computing for each xi the equations xi = xi−1+1/m, yi = yi−1 + m, where Δx = xend − xstart and
Δy = yend − ystart and m = Δy/Δx.
The dda is a scan conversion line algorithm based on calculating either dy or dx. A line is
sampled at unit intervals in one coordinate and corresponding integer values nearest the line path
are determined for other coordinates.
Considering a line with positive slope, if the slope is less than or equal to 1, we sample at unit x
intervals (dx=1) and compute successive y values as
Subscript k takes integer values starting from 0, for the 1st point and increases by until endpoint
is reached. y value is rounded off to nearest integer to correspond to a screen pixel.
For lines with slope greater than 1, we reverse the role of x and y i.e. we sample at dy=1 and
calculate consecutive x values as
Similar calculations are carried out to determine pixel positions along a line with negative slope.
Thus, if the absolute value of the slope is less than 1, we set dx=1 if i.e. the starting extreme
point is at the left.
This algorithm is very efficient since it use only incremental integer calculations. Instead of
calculating the non-integral values of D1 and D2 for decision of pixel location, it computes a
value, p, which is defined as:
p = (D2-D1)* horizontal length of the line
if p>0, it means D1 is smaller than D2, and we can determine the pixel location accordingly
However, the computation of p is very easy:
The initial value of p is 2 * vertical height of the line - horizontal length of the line.
At succeeding x locations, if p has been smaller than 0, then, we increment p by 2 * vertical
height of the line, otherwise we increment p by 2 * (vertical height of the line - horizontal
length of the line)
All the computations are on integers. The incremental method is applied to
void BresenhamLine(int x1, int y1, int x2, int y2)
{ int x, y, p, const1, const2; /* initialize
variables / p=2(y2-y1)-(x2-x1); const1=2(y2-y1); const2=2((y2-
y1)-(x2-x1));
x=x1;
y=y1;
SetPixel(x,y);
while (x<xend) { x+
+;
if (p<0)
{ p=p+const1;
}
else { y++;
p=p+const2;
}
SetPixel(x,y);
}
}
need to be re-used.
or on the screen with simple copying operations.
circ
We would like to choose
the point that is nearest to
the actual circle
So how do we make this choice?
Let’s re-jig the equation of the circle slightly to give us:
The equation evaluates as follows:
f ( x , y ) x
2
y^2 r^2
fcirc ( x , y ) 0,
0,
<0 if ( x , y ) is outside thecircleboundary
=
if
if
( x , y ) is on thecircleboundary
( x , y ) is inside thecircleboundary
By evaluating this function at the midpoint between the candidate pixels we can make our
decision
Assuming we have just plotted the pixel at ( xk,yk ) so we need to choose between ( xk+ 1 ,yk ) and
( xk+ 1 ,yk- 1)
Our decision variable can be defined as:
pk fcirc ( xk 1, yk^1 )
( xk
y^1 2
k
2 r
2
If pk < 0 the midpoint is inside the circle and and the pixel at yk is closer to the circle
Otherwise the midpoint is outside and yk- 1 is closer
coordinate values:
x x xc y y yc
Repeat steps 3 to 5 until x >= y
To see the mid-point circle algorithm in action lets use it to draw a circle centred at (0,0) with
radius 10.
points of the scan line with the polygon edges. These intersection points are shorted from
left to right. Then, we fill the pixels between each intersection pair.
passing through a vertex as intersecting the polygon twice. In this case we may or may
not add 2 points to the list of intersections, instead of adding 1 points. This decision
depends on whether the 2 edges at both sides of the vertex are both above, both below, or
one is above and one is below the scan line. Only for the case if both are above or both
are below the scan line, then we will add 2 points.
which the edge of the polygon intersects, we need to identify whether a point is an interior
or exterior point. Students may find interesting descriptions of 2 methods to solve this problem in many text books: odd-even rule and nonzero winding number rule.
which I not defined by a single boundary color.
void BoundaryFill(int x, int y, COLOR fill, COLOR old_color)
{ if (GetPixel(x,y)== old_color) {
SetPixel(x,y,fill);
BoundaryFill(x+1,y,fill,boundary);
BoundaryFill(x-1,y,fill,boundary);
BoundaryFill(x,y+1,fill,boundary);
BoundaryFill(x,y-1,fill,boundary); }
In many applications, changes in orientations, size, and shape are accomplished with
geometric transformations that alter the coordinate descriptions of objects.
Basic geometric transformations are:
Translation
Rotation Scaling
Other transformations:
Reflection Shear
Translation
We translate a 2D point by adding translation distances, tx and ty, to the original coordinate
position (x,y):
x' = x + tx, y' = y + ty
Alternatively, translation can also be specified by the following transformation matrix:
1 0 t (^) x 0 1 t
Then we can rewrite the formula as:
0 01
1 0 t x
y' = 0 1 t (^) y
1 0 01 1
For example, to translate a triangle with vertices at original coordinates (10,20), (10,10),
(20,10) by tx=5, ty=10, we compute as followings:
Translation of vertex (10,20):
x' 1 0 5 10 1*10 0 * 20 5 *1 15 y' (^) = 0 1 10 20 = 0 10 1 20 10 *1 = (^30)
Translation of
vertex (10,10):
1 0
x' (^1)
x' x
y
y
0 1 1 0 *10^0 ^20 11^1
0 5 10 1*10 0 *10 5 *1 15
The resultant coordinates of the triangle vertices are (15,30), (15,20), and (25,20)
respectively. Exercise: translate a triangle with vertices at original coordinates (10,25), (5,10),
by tx=15, ty=5. Roughly plot the original and resultant triangles.
3.1.2 Rotation About the Origin
To rotate an object about the origin (0,0), we specify the rotation angle ?. Positive and
negative values for the rotation angle define counterclockwise and clockwise rotations
respectively. The followings is the computation of this rotation for a point:
x' = x cos? - y sin? y' = x sin? + y cos?
Alternatively, this rotation can also be specified by the following transformation matrix:
cos sin 0
0 sin (^) cos
0 0 1
Then we can rewrite the formula as:
x' cos sin 0 y' = sin cos^0
1 0 0 1 1
For example, to rotate a triange about the origin with vertices at original coordinates (10,20),
(10,10), (20,10) by 30 degrees, we compute as followings:
cos sin 0 cos 30 sin 30 0 0.866 0.5 0
sin cos 0 = sin 30 cos 30 0 = 0.5 0.866 0
0 0 1 0 0 1 0 0 1
Rotation of vertex (10,20):
x' 0.866 0.5 0 10 0.866 *10 ( 0.5) * 20 0 *1 1. y' =^ 0.5^ 0.866^0 20 =^ 0.5^ *10^ 0.866^ *^20 0 *1^ =^ 22.
1 0 0 1 1 0 10 0 * 20 11 1
x y
Translation of vertex (20,10):
x' 1 0 5 20 1*^20 0 *10^5 *1^25
y' = 0 1 10 10 =^ 0 ^20 110^10 *1^ = 20
1 0 0 1 1 0 *^20 0 10^ 11^1
2