Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

y

Sixth Semester 8.E. Degree Examinati«_m


CBCS • Model Question Pape~ • 1 ·
COMPUTER GRAPHICS AND VISUALIZATION
Time: 3 hrs. . , . . . . . Max. Marks: I00
Note: Auswer a11y FIVE full questl01is, selecil11g ONE full question from eacll111od11le.

MODULE-1
1. a. Computer graphics can be applied in all fields, Justify this statement. (08 Marks)
Ans. Computer-Aided Design for engineering and architectural systems.
Objects maybe displayed in a wireframe outline form. Multi-wind~w 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 ·
graphi~s 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,
an~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 se~ond are required.
Entertainment
Motion.pictures, Music videos, a11d 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 da~a or behavior.
C:onverting data to visual form can .help to understand mass volu~e of data very
effici~ntly. ·
Image Processing
Image processing 'is to apply techniques to modify orinterpretexisting pi~tures. It is
widely -used in medical applications. · ·
Graphical User Interface ~ , .
Multiple window, icons; menus allow a computer setup to be utilized more efficiently.
· b. Explain the differences between raster scan and random scan display device.
· (06 Marks)

3
.-- ' --------~-y-.,.,.,~~"'~•t.1,~
comp~ Grcq,~~Vimnlt--~ -
VI se,,w (CSE I IS£) ' ' ' ---- . .
cacs - Mode-ltQ~Po,.pu - 1 ·
such objects in OpenGL we pass it a list of vertices. The list occurs between the two
Ans. •·-•·• ,.,...n ·5 \ni;;iii \ Rand~m Scan System -
OpenGL function calls glBegin() a_nd glEnd(). The argument of g!Begin() determine
1
Base of Raster Scan System which object is •dniwn. These functions are glBegin(int mode); glEnd( void); The
Difference The electron be'am is directed on~ parameter mQde of the funct1on glBegin can be one of the following:
The electron beam is swept across the parts of screen where a picture is
Electron ·the screen, one row at a time, from. GL_POINTS .
to be drawn.
Beam top to bottom. GL_LINES
lts resolution is goo i because%
lts resolution is poor because raster system produces smooth Jines GL_LINE_STRIP
GL_LINE_LOOP
Resolution I s~stem in contrast produces ~igzag drawings because CRT beam directly GL_TRIANGLES
Imes that are plotted as discrete
follows the line pat~. GL_TRIANGLE_STRIP
point sets. Picture definition is stored as a set or
Picture definition is stored as a set of line drawing instructions in a display GL_TRIANGLE]AN
Picture intensity values for all screen points, GL_QUADS
Definition 1called pixels in a refresh buffer area. file. OR
The capability of this system to store These systems are designed for line. 2. a. What do you mean by interactive computer graphics? Explain (02 Marks)
· Realistic
Display
I intensity values for pixel makes it drawing and can't display realistic
well suited for the realistic display
of scenes contain shadow and color
shaded scenes.
Ans. Interactive Computer graphics is ari art of drawing pictures, lines, charts, etc.
using computers with the help of programming. Computer graphics image is made
pattern. up of number of pixels. Pixel is the smallest addressable graphical unit represented
Screen . points/pixels are · used to ·1 Mathematical .functions are used to on the computer screen.
Draw an
draw an image. draw an imagt:. Creation ofan object+ Manipulation of Object+ Display ofan object using Computer
Image_
b. What arc advantages of DVST over CRT? Also list some disadvantages of .
c. What Opcngl? List the basic primitives supported by OpcnGL . (06 Marks) DVST. · (04 Marks)
Ans. OpenGL is a software interface that allows you to access the graphics hardware Ans. Advantages:
without taking care of the hardware details or which graphics adapter is in th_e i. No refreshing is needed.
system. OpenGL is a low-level graphics library specification. It makes available to ii. Very complex pictures can be displayed at very high resolution without flicker.
the programmer a small set of geomteric primitives points, lines, polygons, images, Disadvantages:
and bitmaps. OpenGL provides a set of commands that allow the specification of i. They ordinarily do not display color
geometric objects in two or three dimensions, using the provided primitives, togethe~ ii. Selected part of the picture cannot be erased .
wid1 commands that control-how these objects are rendered (drawn).• OpenGL Utility iii. The erasing and redrawing process can take several seconds for complex pictures.
Library (GLU) contains several routines that use lower-level OpenGL commands
c. Compute the following: .
to perform such tasks as setting up matrices for specific viewing orientations and
(i) Size of 800 i 600 image at 240 pixels per inch.
projections and rendering surfaces. OpenGL Utility Toolkit (GLUT) is a window-
(ii) Resolution of2 x 2 inch image that Iias 512 x 512 pixels.
system-independent toolkit, written by Mark Kilgard, to _hide the complexities of
(iii) Height of the ·resized image 1024 x 768 to one that is 640 pixels wide with
differing window APls.If you are using the OpenG'L Utility Toolkit (GLUT) for the same.aspect ratio. · '
managing your window manager tasks, you should include: · •·
(iv) Width of an image having height of. S inches and an aspect ratio 1:5.
#include <GUglut.h>
. ~e f~llowing fi!es mu~t be placed in the proper folder to run a OpenGL Program. (04 Marks)
Ans. 240 pixels corresponds to 1 inch
L1brar1es (place m the ltb\ subdirectory of Visual C++) . '
=> 800 pixels will corresponds fo 800 / 240 inch = 31 / 3 inch Similarly 600 pixels
?pengl~2.li~, glu32Jib, glut32.lib.The corresponding header files and dynamically => 600 / 240 = 21 / 2 inch
lmk~d ltbran.es are_ (g!·~; glu.h, glut.h, opengl32.dll, glu32.dll, glut32.dll) Hence, the size of the image is 31 / 3·inch x 2.\ / 2 inch
Basic graphics pnm1t1ves · i) 512 / 2 = 256 pixels per inch. .
ipen~L Provides tools for drawing all the output primitives such as points, 1ine5, ii) Aspect ratio of the l 024 x 768 image is 7~8 / l 024 = ¾.
iang es, polygons; quads etc and it is defined by one or more vertices. To draw
Hence, width of the image having height of 640 pixels having aspect ratio 3/~ is 640
4 e- jZ)""'- '
S#114144 £uu#- P'-"""' 5
--- .comp~ GYt1.phic¼'cu--ui, c13CS -Mode-vQ~WtVPc;tper - l
VI S(Wtl ( CSE I ISE)
T The circle octant ·in the first quadrant from x=0 to x=y. The initial value 9fthe
X ¾=480 ..
iii) Width of the image of aspect ratio 1.5 = 5 x 1.5 = 75. decision parameter is P0 =l-r= -9
For the circle centered on the coordinate origin, the initial point is (x0 ,yJ=(o; 10) and
d. Describe the midpoint cin:le generation algorithm with an example (08 Marks) initial increment terms for calcuh1ting the decision parameters are
Ans. void PlotCirclePoints(int centerx, int centery, int x, int y) · 2Xo=0 . 2y0 =20 · ,. _
. { . . . · . Successive midpoint decision parameter values and the corresponding coordinate
positions along the circle path are listed in the following table. ,
SetPixel(centerx+x,centery+y);
(Xt+1, yt-1) 2Xt+1 · 2)"Hl
SetPixel(centerx-x,centery+y); p,;
SetPixel(centerx+x,centery-y); 0. . (l,10) 2 20
-9
SetPixel(centerx-x,centery-y); -6 . . (2,10) 4 20
I
SetPixel(centerx+y,centery+x); -1 (3,10) 6 20
2
SetPixel(centerx-y,centery+x);
3 6 (4,9) 8 18
SetPixel(centerx+y;centery-x);
SetPixel(centerx-y,centery-x); 4 -3 (5,9) 10 18
} '5 8 (6,8) · 12 16
void MidpointCircle(int centerx, int centery, int radius) (7,7) 14 14
6 . . 5
{ int x=O; •
Module-2 ·
int y=radms;
int p= I-radius;
_PlotCirclePoints(centerx,centery,x,y);
3,WExplain the Bou~dary-Fill AlgQrithm w.r,t computer gr~phics -(08 Marks)
Ans.
while(x<y) • This algorithm starts at a point inside a region and paint the interior outward
{ if(p<O) towards the boundary.
{ p:=p+2*x+3; • This is a simple method ,but not efficient: L It is recursive method which may
} occupy a large stacksize in the main memory.
..,else void BoundaryFill(int x, int y, COLOR fill, COLOR boundary)
{ p=p+2*(x-y)+5; { .
;
y=y; l; COLOR current; ·current=GetPixel(x,y);
} if(current<>boundary) and (current<>fill) then
_x =x+l; { SetPixel(x,y,fill); . .
;lotCirclePoints(centerx,centery;x,y); BoundaryFill(x+ l ,y,fill,boundary); _ BoundaryFill(x-l ,y,fill,boundary);
Boundaryf ill(x,y+ l ,fill,boundary); BoundaryFill(x,y- l ,fill,boundary);
} } . .
ii-
(x,y)
(y. -x) . $eedp1x,1 Borderplxets
Eumple : Midpoint Circle Drawing
. Given a circle radius r= JO
s""'"'" ·& .- ;z,~
• Pixels fined with the
new cow.va1u~
}
6 7
~ eu,..'P--
• More efficient metnoas nu nun Lv111<11 I'"''" JP ~ .. - ~ --· --- - .- - •· ··••w, '"~lead
proceeding to neighboring points. · · of C13CS • M~.9ue¼t'Wt11Pape,,-.- 1
b. Explain the concatenation properties of the composite matrix. (08Mark.,) OR
Ans. Matrix multiplicathm is associative: .. 4. a. Write explanatory note on i) Flood Fill ii) Text generation Methods in OpenGL
A·B·C =(A·B) ·C =A·(B·C) . .
Therefore, we can evaluate matrix products using these associative grouping. For Ans. i) Flood Fill . . d F'\I · fill
example, we have a triangle, we want to rotate it with the matrix B, then we translate _ Flood-Fill is similar to Boundary-Fill. The difference is that Floo - 1 1s to an
it with matrix A. Then, for a vertex of that triangle represented as C, we compute its : area which is not defined by a single boundary color. _·
transformation as: C'=A·(B·C) void FloodFm(intx; int y, COLOR fill, COLORold_color)
But we can also change the computat_ion method as: C' =(A· B)·C . ·{ .
if(GetPixel(x,y) = old_color)
The advantage of computing it using C' = (A·B)·C instead ofC'=A·(B ·C) is that,
{
for computing the 3 vertices of the triangle, G1, C2, C 3, the computation time is
SetPixel(x,y,fill);
shortened, FloodFill(x+ 1,y,fi ll;old_color);
Using C'=A·(B·C): FloodFill(x-1,y,fill,old_colo~);
I. compute B · CI and put the result into II · FloodFill(x,y+ I,fi 11,old_color);
2. compute A · I I and put the result into CI' FloodFill(x,y-1,fill,old_color);
3. compute B · C2 and put the result into 12 }
4. compute A· 12 and put the result into C2' }
5. compute B · C3 and put the result into 13 ii)Text Generation Methods in OpenGL
6. compute-A· 13 and put the result-into C3'
There are 3 basic methods of generating characters, they are namely stroke method,_
. Using C' = (A-B)·C: starbust method and BitMap Method. ·
- Compute A · B and put the resuJt into M a) Stroke Method - This method uses small line segments to generate' a character.
- <,ompute. M · CI and put the result into Cl' The small series of line segments are drawn like strokes of a pen to form a character.
- compute M · C2 and put the result into cz•· The stroke method supports the scaling of a c_haracter.
- compute M · C3 and putthe result into C3' b) Star _Bust Method - In this method a fix pattern of line segments are used .to
· c. List the opengl translate, rotate and scale functions in opengl. · (04 Marks) generate·charcters. This method is called as star burst because of its characteristic
Ans. Translation . appearence. Since the 24 bits arerequlred to represent a character, -!11ore memory is
. void glTranslate{fd} (TYPE x, TYPE y, TYPE z); required. Character quality is poor and it is worst for the curve shaped characters.
Multiplies the current matrix by a matrix that moves (translates) an object by c) Raster / Bitl\1ap Method - It is also called as bit map method or dot matrix .
the given · - ·. method since characters are represented by an array of dots in · the matrix form.
x, y, and z values . Usually the dot patterns for all characters ar_stored in the hardware device called
Rotation character generator chip. Each dot in the matrix is a pixel. The character is placed on
· D void glRotate{fd}(TYPE angl~, TYPE x, TYPE y, TYPE z); the screen by copying pixel values from the character array into some portion of the
DMultiplies the current matrix by a matrix tiiat rotates an object in a counterclockwise screens frame buffer. The opengl function is void glut Bitmap Character(void *font, . .
int character);. · ·
direction about · · ·
the ray from the origin through the·point (x, y, z). The angle parameter b. Explain the different types of polygons supp_orted by openGL. (07 Marks) ·
specifies the angle of rotation · · Ans. Polygons(GL_POLYGON) .
in degrees. • Successive vertices define line segments and a line.Segment connects the final
Scaling vertex to the first. ·
I) Void ~l~caie{fd} (TYPEx,TYPEy,TYPEz); . . . • ·Interior is filled according to the state of relevant attributes. ·
2) _Multiplies the current matrix by a matrix that stretches shrinks or reflects an • Most graphics systems allow us to fill the polygon with color or pattern or to draw ·
obJect along the axes, ' ' · the lines around the edges but not to do both.
• We use the function glPolygonMode to tell what we want. ·
8 . S""4141,, E- p ~
s~~'P~
9
VI Se+W (est I IS£} l.,Ul'''t'"""V'' ... - T -- ~
.:!,.::::~:.:.:~=---~-~---"'.-:---:----::---~~
• To do both, we h1we to render it twice, once in each mode. ......._ In order to represent this transformation as a matrix transformation, we need to use
• Traingles and Quadrilaterals are sp~ial cases of polygon~. homogeneous coordinate. The required homogeneous matrix transformation can
• GL . TRIANGLES and GL_QUADS in opengl are special polygons With Gl

!l·i'~l
then be expressed as
TRIANGLE_STRIP,GL_QUAD_STRIP,GL_TRIANGLE_FAN · ,
(x' y ' z' 1) = (x Y z 1) {~
Explain the steps involved in general pivot rotation (05 1'1.arlia) b
c. C

Ans. General Pivot-Point Rotation · . .


Rotation about M arbitrary pivot point.is not as simple as rotation al out the origit\. Scaling
The process of scaling changes the dimensions of an object. The scale factor s

T$bj~•wi:•+•Uon~$
The procedure of rotation about a_n arbitrary pivot point is: · . . . .. determincts whether the scaling is a magnificaHon, s > l, or a reduction, s < I.
I. Translate the object so that the pivot-point position is moved to the ongm. Scaling with respect to the origin, where the origin remains.fixed, is offered by the
2. Rotate the object about the origin. .. . . .. transformation '
In matrix form this is
3.
0 OJ
Sy0
0 s.
Cb) (CJ • (d)
Ca) · • r Aotatkln Tran~lation ol
Rotation
O r igl,...I PoeftiOII Tran•l•bO" 0 ~ut . Obj~ao1hat
bf Ob)e« end ObJocrt :,:.~1 Origin 1 Pivot Point
the Rotation in three dimensions is considerably more complex then rotation in two
Pt,OC Point ~ ) la a! ";;~=
:o .
Origin Y,l
(Jt,, dimensions. In 2-D, a rotation is prescribed by an angle of rotation 0 and a centre of
rotation, say P. Three dimensional rotation is prescribed by an angle of rotation and
Mod~le~ 3 an axis of rotation. Tl1e canonical rotations are defined when one of the positive x,

. S. a. Explain the effects of 3D trands~orm~tion1\oordinate system, an ob}!!_t


Ans. With respect to some tltree- 1mens1ona
1~~!
J •
y or z coordinate axes is chosen as the axis of rotation. Then the construction of the ·
rotation transformation proceeds just like that of a rotation in two dimensions about
_the origin as shown in figure:
considered as a . ,e .
set of points. Obj= {P( x,y,z)} ·t· n· we can regard it as a new object Obi' all of Rotation about the z axis
• d t a new post 10 , · · . . . · ·J '
If the obJect ~ove P'( , , z') can be obtained from the ongmal coordinate We know
x : = xcos8 - ysin8
whose co9rdmate po~nts ': ' ·ncation of a geometric transformation.
points P(x,y,z) of ObJ throug t e app . . - . {
y= xsiri9 + ycosfl
z =z
Transl~tion_ . . . distance and direction from its original posi~ion.llx
An O~Ject is dt~placed a g,vefnth translation is prescribed by a vector . R.i.K : .
. Rotation about the y Axis
direction and -displacement o e , , . .
An analogous derivation leads to
V = al + bJ + ~K d .nt can be calculated by using"the transformatioo x ' = xco_s9 + ysln9
The new coordmates ofa trans Iate pot . . y =y
{
as shown in figure below: z · = -xstn8 + s cos9
Ru:
· [x' =x +a ·
z (x+tx+ty,z+tz) Rotatio:~~~t the x Axis Similarly:
TV: y 1 =y + b . L,P'(x',y',z')
z1 =z+c ·
{
y:= ycos9 - zstn9
~.... P(x,y,z) z = ystn8 + z cos9
.... y RO.I:
a
The. direction of po~itive angle of rotation is chos~n in accordance to the rioht-hand
0

X 11
comp(M,e-r _1:1' "'1-'' """"" vv, vvv ' v " ~l-0-i-v
VI senv (CSE I ISO
C13CS - !vfodel,Q~LOYI/Pa"pu - l
rule with respect to the axis of rotation. ·
OR
Re.K =
sin8 0)
The corresponding matrix transformations are
cos8 6. a. Explain atleast one color model. (08 Marks)
( ~sin8 cos8 0
Ans. Color Model
0 0 1
• A color model CMY is used for hardcopy devices as we produce picture by coating
cos8 0 -sin8)
a paper with color pigments, we see the color by reflected light a subtractive
Re.J = ( 0 1 0
stn8 o· cos8 process. .
· • When white light is reflected from cyan colored ink the reflected light must have
b. Use the Liang-Barsky line clipping algorithm to clip the line Pl(-15, ~30) ,
no red component that is red light is absorbed or subtracted by the ink.
P2(30, 60) against the window having diagonally opposite corners as (0, 0) a nd
• . Similarly magenta is subtracting.green component. ·
(15, 15). (10 Marks)
• Unit cube for CMY model is shown in figure below.
Ans.
wo.60>
yello:
'
fco,0,1)· .A red
green
y
I •· .
I .· \
p:-~a~s~ le
I magenta
/ white · -
cyan
C / c '~,0,0) blue
X
Fig. Tl~e CMY color model.
• Point (l,1,1) represents black because all components are subtracts and origin
represents white light. · .·
• Gray can be produce among main diagonal by using all three color_in equal
· amount.
P1(- (5, -3 0)
• Printing process often use CMY model generates a color points with a collection ·
Line coordinates Pl(-15, ~30), P2(30,60) . of four ink dots, one for each primary color C, M, and Y and one dot is black.
Window coordinates xmin =.0, xmax = 0, ymin = 15, ymax = 15.
b. Explain the types of light source. (06 Marks)
dx = 30-(-15)=45 dy=60-(-30)=90 .
di= -dx = -45 ql=xl-xmin =-15-0=-l5, · ul=ql/dl=l/3 Ans. Ans: The simplest model for light source is point source. Rays from the source then
d2 = dx = 45 q2=xmax-x I= 15-(-15)=30 u2=q2/d2=2/3 · follows radial diverging paths from the source position. ·
d3 = -dy =-90
d4 = dy=90
q3=yl-ymin = -30-0=-30 · u3=q3/d3 =1/3
q4=ymax-yl=l5-(-30)=45 u4=q4/d4=1/2
for (di< 0) ul = MA~IMUM of(l/3, 1/3, 0) = 1/3 for (di> 0) u2 = MINIMUM of
"i~
7·~
(2/3, ½, J) = ½
Since uI < u2 there iS' a visible section Fig. :- Diverging ray patl,s from a point ligl,t source.
Computing new end points • This light source model is reasonable approximation for source whose size is
x'I =xi + dx xul = - 15+(45x l/3)=0 small compared to the size· of object or may be at sufficient distance so that we
y'I = yl + dy x ul = -30 + (90 x l/3) = 0 can see it as point source. For example sun can be taken as point source on earth.
x'2 = xi + dx x u2 = - JS+ (45 x l/2) = 7 ½ • A nearby source such as the long fluorescent light is more accurately model!ed as
y'2 =y2 + dy X u2 = • 30 + (90 X 1/2) = J5 a distributed light source.
Z- P.ut#ff
12 s~ e-- '1)4f/,161 S""4t411
13
VI 5e,rw ( CS'E I !SE) vv .. r --- . - ,v
.,,
• In this case the illumination effects cannot be approximat~d with point cBCS • MOM-VQ~wn,Pcq,er - l
because the area of the source is not small compare to the size of object. 1'1:e The solution involves the determination of the closest ·visible surface along each
• When light is falls on the surface the part of the light is reflected and Part projection line.
the light is absorbed. Amount of reflected and absorbed light is depends on t~f There are many different visible -surface detection l\lgorithms. Each can be
. shiny surface reflect more light Wh'It
property of the object surface. For example te characterized as either an image-space method or an object-space method. An
object-space method compares objects and parts of objects to each other within the
dull surface reflect less light. scene definition to determine which surfaces, as a whole as visible. Surface visibility .
c. Perform a 45 degree rotation of a triangle A(0,0),B(l,l),C(S,2) i)about the is determined using continuous models in the object space (or its transformation)
ongtn (06 Marks)
without involving pixe.1based operations;
Ans. We represent the triangle by a matrix formed from the homogeneous co-ordinates of In an image-space algorithm, visibility is decided point by point at each pixel position
the vertices: . ,. ' on the projection plane. Most visible-surface algorithms use image-space methods
0 I S in which the pixel grid is used to 'guide the computational activities that determine
0 I 2 visibility at the pixel level. ·
I I I c. Explai·n the role of gluLookAt in Opengl (08 Marks)
i) The matrix rotation is Ans. It is used to define a viewing transformation
Declaration : void gluLookAt( ·I GLdouble eyeX,
R45° = cos 45° -sin45° 0
Sin4S• cos 45° 0 GLdouble eyeY,
·0 I GLdouble eyeZ,
Since the coordinated A'B'C' ofthe rotated triangle ABC can be found as GLdouble center}(,
[A'B'C']=R45°[ABC] = 0 0 /2 GLdouble centerY,
0 /2
GLdouble centerZ,
I
-Module-4 GLdouble up}(,
GLdouble upY,
7. a. What is viewing-transformation? Explain . , (04 Marks)
Ans. Conversion ofobjection descriptions from world to viewing coordinates is equivalent GLdouble upZ);
to a transformation that superimposes the viewing reference frame onto the woM
frame using the basic geometric translate-rotate operations: eyeX, eyeY, eyeZ - Specifies the position of the eye point:
I. Translate the view reference point to the origin of the world-coordinate system. center){, centerY, centerZ - Specifies the position of the reference poi11t.
2. Apply rotations to align the x., Yv• and zv axes (viewing coordinate system) witli upX, upY, upZ - Specifies the direction of the up vector.
Details: giuLookAt creates a viewing matrix derived from an eye point, a reference
the world xw' yw' zw axes, respectively. ·
• hwYv.Vj
point indicating the center of the scene, and an UP vector..
v
~Yv -• •. . The matrix maps the reference point to the negative z axis and the eye point to the
origin. When a typical projection matrix is used, the center of the scene therefore
z
maps to the center of the viewport. Similarly, the direction described by the UP
V
xw _ . xw w
yector projected onto the viewing pla?e is mapped to the positive y axis so that it
zw . z V
points upward in the viewport. The UP vector must not be parallel to the line of sight
(a) w (b) zw (c)
from the eye point to the reference point. ·
b. Explain, why there is a need for visible surface detection? Differentiate between Let F = centerX- eyeX centerY - eyeY centerZ - eyeZ_
object precision and image precision methods for detecting visible surface, Let UP be the vector upX upY upZ .
· (08 Marks) Then normalize as follows: f= FF
Ans. The surfaces that are blocked or hidden from view must be "removed" in order to UP " = UP UP Finally, let s = f x UP " , and u = s s x f.
construct a realistic view of the 3D scene. The identification and removal ofthese
surfaces is called the visible surface detection or hidden - surface removal problelll,
14 S""4/M·&x,.,,,, 'P~ S""4t4I,, e- p""'- . 15
V .L .) ewtt l ~c / J..:, ~/ ..... v,r~ v-----· - · -- r · · -o - ~ ~
M is then constructed as follows: c13CS - Mode,l,Q~Pt;tptW • 1
I 2 0 0 • The z-value of a polygon can be calculated incrementally.
I u O2 0 -f D 0-:-f D I • No pre-sorting of polygons is needed.
0 0 0 0 I • No object-object comparison is required.
and gluLookAt is equivalent to glMultMatrixf(M); • Can be applied to non-polygonal objects.
glTranslated (-eyex, -eyey, -eyez); • Hardware implementations of the algorithm are available in some graphics
workstation.
OR • Por large images, the algorithm could be.applied to, eg., the 4 quadrants of the
8. a. Describe Depth Buffer Hidden Surface Elimination Method. · (10 Marks) ' image separately, so as to reduce the requirement of a large additional buffer.
Ans. Depth-Buffer Method (Z-Buffer Method) · b. Explain the types of Projections supported in three dimensions. (10 Marks)
This approach compares surface depths at each pixel position on the projection pliine Ans. In the 2D system, we use only two coordinates X and Y but in 3 D, an extra coordinate
Object depth is usually measured from the view plane along the z axis of a view in~ Z is added. 3D gr,aphics techniques and their application are fundamental to the
system. entertainment, games, and computer-aided design industries. It is a ·continuing area
This method requires 2 buffers: one is the image buffer and the other is called the of research in scientific visualization. ·
z-buffer (or the depth b.uffer). Each of these buffers has the same r~solution as the Furthermore, 3D .graphics components are now a part of almost every persoi1al·
·. r:.
image to be captured. computer and, although traditionally intended for graphics-intensive software such
z-buffer
oblaln lho depth as games, they are increasi11gly being used by other.applications.
end tho colour d
~the
.,.e:7 .·· .
-
1111
As surfaces are processed, the image buffer is used to store the color values of ea9h
pixel position and the z-buffer is used to store the depth values for each (x,y) position.
/
c.?7
"' '
Algorithm: ..
1. Initially each pixel of the z-buffer is set to the maximum depth value (the depth· Parallel Projection ',
of the back clipping plane). Parallel projection discards z-coordinate and parallel lines from each vertex on the
i. The image buffer is set to the background color. object are extended until they intersect the view plane.. In parallel projection; we
3. Surfaces are rendered one at a time. specify a direction of projection instead of center of projection.In parallel projection,
4. For the fitst surface, the depth value of each pixel is calculated. . the distance from the center of projection tci project plane is infinite. In this type of
5. If this depth value is smaller than the corresponding depth value in the z-buffe'r . projection, We connect the projected vertices by line segments which correspond to
(ie. it is closer to the view point), both the depth value in the z-buffer and the color
connections on the original object. Parallel projections are less reaiistic, but they
are good for exact measurements. in this type of projections, parallel lines remain
value in the image buffer are replaced by the depth value and the color value of
parallel and angles are not preserved. Various types of parallel projections are shown
this surface calculated at the pixel position. ·· · in the following hierarchy.
6. Repeat step 4 and 5 for the remaining surfaces.
7. After all the surfaces have been processed, each pixel of the image buffer'
represents the color of a visible surface at that pixet
• This method requires an additional buffer (if compared with the Depth-Sort
Method) and the overheads involved in updating the buffer. So this method
is less attractive 'in the cases where only a few objects in the scene are to be
rendered. · .
• Simple and does n9t requ·ire additional data structures.
~e-;z:,'""- 17
16 S~$Z4M!p-
·f · _
VI Se-+W (CS£ I ISE)
C....-111,(,t°u G r ' ~ ~ -( M'\«/
v .. .,... . . . ·
-
c-sCS t-,tode-vQIM¼tfhrvf'Ot.pe¥ - 1
y....l
y ,
-
P'""'·•·v·,-·r··· ·
71
b
)- I ;) X X
a
p;u.11lcl
Proicction
1-§%111 Z -"
·cavalier Projection
z ·-·cabinet Projection
Isometric Projections
. . .
Orthographic projections. that show more than one side of an object are called
axonometric orthographic projections. The most common axonometric projection •
~s !l,P isometric proj_ection where the projectio~ plane inters~cts e~ch ~oordinate ~is
111 lhe model coordmate system at an equal distance. In this pr0Ject1on parallelism
Orthographic Projection .
In orthographic projection the direction of projection is _normal to the projection of . of lines are preserved but angles are not preserved. The following figure shows
the plane. There are three types of orthographic projections - ·, . isometric projection -
. • Front Projection y
• Top Projection
• Side Projection
Perspective Projection
In perspective projection, the distance froi;n the center of projection to project plane
is finite and the.size ofthe object varies inversely with distance which looks more
realistic. '
The distance and angles are not pre~erved and parallel lines do not'remain parallel.
a
Instead, they all converge at single point called center of projection or projection
reference point. There are 3 types of perSpective projections which are shown in the
following chart. · · ·
• One point perspective projection is simple to draw.
• Two point perspective projection gives better impression of depth: .
Fronl view • Three.point perspective projection is most difficult to draw.
o-~~doo . . · 1. point.. 2 point. 3 po t nt. ·
In orthographic projection, the direction of projection is not normal to the projection
of plane. In oblique projection, we can view the object better tha11; orthographic
projection.
.6-'0----'0-
. projec-t.1.,pn . p la ne
There are two types of oblique projections -:-- Cavalier and Cabinet. The Cavalier.,.
projection makes 45° angle with the proje<:tion plane. The projectiqn of a line
perpendicular to the view plane has the same length as the line itself in Cavalier One Point
e
projection. In a cavalier projection; the foreshortening factors for all three principal . .
' . 1·
Two Point
directions are equal. · · .
• Th~ C~bine~ projection ?1akes 63.4° angl~ with the projection plane. In ~abinel Three Polnt. ,
proJectJon, Imes perpendicular to the viewing -surface are projected at ½ their actual
length: Both the projections are shown in the following figure - . .
The following figure shows all the three types of perspective projection
18 ~E-iD'"'-
s_.. s--1J"'1" 19
.::..:.=-.:~:...:::..:.:..---_,;_-------.:...:
VI Se+w (CSE ( ISO compcAt"u Gn;iphic¼-~V~ c8CS - Model!QW¼t"tm11Pvtper- - l
Modulc-5 . ..---......;
9. a. What is Bczier Surface? How is it related to Bezi~r curve? . (08 l\1ar1<s
- The infonnatiori returned to the program includes ASCII value of the ke~ pressed and _
the position (x,y) of the cursor when the key was pressed. Programmmg keyboard
Ans. A surface defined by mathematical fonnulae, used m computer graphics. A surra~) event involves two steps: · •d k
P(u v) where u and v vary orthogonally from Oto l from one edge of the surfac e I. The keyboard callback function must be _define~ i_n the form: voi my ey
the'oth~r, is defined by a set of(n+It(m+l) "control points" {X(i,j), Y(i, j), Z(i~j\~ (unsigned char key, int x, int YJ is written by t~e ap~ltcat1on programmer.
For example, void mykey(uns1gned char key, mt x, mt y)
for i = 0 to n, j = 0 tom. {
P(u, v) = Sum i=0 .. n Sum j=O .. m [ (X(i, j), Y(i, j), Z(i, j)) * B(i, n, u) * BG, m, V)] _
if(key= 'q' II key= 'Q')
B(i, n, u) = C(n, i) • u"i • (1-u)"(n-i) · exit(0);
C(n, i) = n!/i!/(n-i)! ·
Bezier surfaces are an exten~ion of the idea ofBezier curves, and share mljY.of their The above cod~ ensures when 'Q' or 'q' key is pressed, the execution bf the prog.ram _
properties. gets terminated. · · _ . . _
he Bezier surface is fanned as the cartesian product of the blending functions oftw0 A window event is occurred when the corner of the wmdow 1s dragged to new
orthogonal Bezier curves. _ position or size of window is minimized or maximized by using mouse. !he
. Ni! i NH NJI yi({ - v)NJ,- J information returned to the program includes the height and width of newly resized
B(u,v): L._ L_ Pt,J 1! (Nl _ t)I U (1 - u) . JI (NJ - }JI window. Programming the window event involves two steps:
i:O J=O O s. u s. 1 I. Window callback function inust be defined in ·the form:
0 s. Y s. 1
void myReshape(GLsizei w, GLsizei h) is written by the application programmer.
Where Pij is the ijth control point. There are Ni+ l and Nj+ l control points in th 1, Let us consider drawing square as an example, the square of same size must be
andj directions respectively. The corresponding properties of the Bezier curve app~ drawn regardless of window size.
to the Bezier surface. y void myReshape(GLsizei w, G_Lsizei h)
3. The surface does not in general pass through the control points except' for th {
corners of the control point grid. e glMatrixMode(GL_PROJECTION); glLoadldentityQ;
4. The surface is contained within the convex hull of the control points. Along th gluOrtho2D(0,(GLdouble) w, 0, (GLdouble) h); glMatrixMode(GL_MODELVIEW);
edges of the grid patch the Bezier surface matches that of a Bezier curve through the glLoadldentity(); . 1
control points along that edge. e glViewPort(0,0,w,h) /*save new window size in global variables*/ ww=w;
5. Closed surfaces can be formed by setting the last control point equal to the first: wh=h:
If the tangents also match between the first two and last two control points then th }
closed surface.will have first or_der continui e . z.The window callback function must be registered in the main function,
glutReshapeFunc(myReshape);
c. Explain the concept of picking and selection mode in OpenGL. ·· (06 Marks)
-Ans.
• The difficulty in implementing the picking is we cannot go backward directly
from the position of the mouse to the primitives. · ·
• OpenGL provides "selection mode" to do picking. Th~ glRenderMode () is used
to choose select mode by passing GL_SELECT value. ·
, • When we enter selection mode and render ·a scene, each primitive within the
clipping volume generates a message called "hit" that is stored in a buffer called
b. What are Keyboard,and Window events in Opengl? Explain (06 Marks)
"name stack".
Ans. Keyboard devices are input devices which return the ASCII value to the user program,
• The following functions are used in selection mode:
Keyboard events are generated when the mouse is in the window and one of the keys
• void glSelectBuffer (GLsizei n, GLuint *buft): spe~ifies array buffer of size ' n' in
is pressed or released. GLUT supports foilowing two functions: which to place selection data.
• glutKeyboardFunc() is the callback for events generated by pressing a key • void gllnitNames () : initializes the name stack.
• glutKeyboardUpFunc() is the callback for events generated by releasing a key.
S""4t<w z- P""'- 21
20 s~e--'P111""'
VI Se,m, (CS£ ( IS£) COfl'I.PIM,~ '-'' vvr-• ---v
· -ir"'-1,.
cecs Modcl,,Q~tm'\IP~u - 1 '. •
• vo;d glJ>ushN,mo(GLu;,1 ru,me) , pushes oame on th• name staok. - ; When the data are to be input and which deyice_is to be used at that time to deliver
• void glPopNameO : pops the top name from the name stack. a particular input type to the specified_data variables.
• void glLoadName(GLuint name): replaces the top of the name stack with .
• o·penGL allow us to set clipping volume for picking using gluPickMat;arne. Input Modes · · · . . d
Functions to provide input can be struct?red to op~rate in vanous input mo es,
· which is applied before gluOrtho2D. · . IX ( ) h' h specify how the program and mput devices interact. Input could _be
• gluPickMatrix(x, y, w, h, •vp) : creates a projection matrix for picking that rest .• :it~:ted by the program, or the program arid input devices ~oth could be oper~tmg
drawing to aw x h area and centered at (x. y) in wi11dow coordinates withi;lctg simultaneously, or data input could be initiated by the devices. These three mput
viewport vp. · the ~odes are referred to as request mode, sample mode, and event mode. _
OR In request mode,_the application program !nitiates da~a entry. Input value~ are
. requested and processing is suspe?ded_ until the ~equ~red values are receiv~d.
10. a.Explain the concept of display list and modeling in openGL, (06 Marl(S) This input mode corresponds to typical mput operation m a general pr:ogrammmg
Ans. Display list can call other display list. Therefore, they are powerful tools for buildin language. The program and the inpµt devices operate alternately. ~ev1c~s are put
hierarchical models that can incorporate relationships among parts of a m6de~ into a wait state•until an input request is made; then the program waits until the data
Consider a simple face mod_fe.g system that can produce images as follows: · 0 are delivered. · · ·. ·. .
In sample m~de, the application program and input devices operate i~dependen!ly.
Input devices may be .operating at the same time that the program 1s process mg
other data. New input va_lues from _the input devices are stored, replacing previously
Figure: Silllple animated face ··_input data values. When the program requires new data, it sampl_es the current values
from the input devices. In event mode, the input devices initiate data input to the
. . ·d t·ca~I eyes two identical ears, one nose, one mouth &;an application program. The program and the input devices again operate concurrently,
Each. face has two
. J·ryenth se parts' through display hsts
1 • • h· ·
wh1c ·
1s given be Iow: . .. - · but now the input devices deliver data to ·an input queue. All iriput data are saved.
outlme. We can spec1 e . .· . When the program requires new data, it goes to the data queue.
...
Any number of devices can be operating at the same time in sample and event modes.
. glNewList(EYE}; /"eye code"/ glEndListry; . · Some can be operating in sample mode, while others are operating in event mode.
//Similarly code for eai:s, nose, mouth, outhn But only one device at a time can be providing input in request mode.
#define FACE 2 An input mode within a log_ical class for a particular ·physical device operating on a
glNewList(FACE}; specified workstation is declared with one of six input-class functions of the form
//code for outline . set . . . Mode (ws, deviceCode, inputMode, echoFlag) · ·
glTranslateft...}; where deviceCode is a positive integer;1sinputMode is assigned one of the values:
glCallList(EYE}; //left-eye request, sample, or event; and parameter echo Flag is assigned either the value echo
glTranslateft... }; or the value noecho;
glCallList(EYE); //right-eye
c. What is a Bezier Spline ? Explain (04 Marks)
glTranslatef{... }; · ·
Ans. In the mathematical subfield of numerical analysis, ·a ~spline, or basis spline, is a
glCallList(NOSE); .
//similarly code for ears and mouth . spline function that has minimal support with respect to a given degree; smoothness,
glEndList(}; ~nd dontain_ pa~ition. Any _spline function of given degree can be expressed as a
hnear combmatlon ofB-splmes of that degree. · .
b. What are the various input mode functions that specify how the program and Cardinal B-splines has knots that are equidistant from each other, B-splines can
input devices interact? · (10 Marki) ~e used for curve-fitting and numerical differentiation of experimental ·data. ln
Ans. Graphical input functions can be set up to allow users to specify · the following computer-aided design and computer graphics, spline functions are constructed as
options: . · linear combinations of B-splines with a set of control po!nts. ·
• Which physical devices are to provide . input within . a particular logical
classification (for example, a tablet used as a stroke device).
• How the graphics program and devices are to interact (input mode). Either the
program or the devices can initiate data entry, or both can operate simultaneously.
e- iD4'Uft 23
22 S<IM4/A4£--'P~
c;1JcS - Mode-ltQ~Pe;tper - 2
Sixth Semester·B.E, Degree Examination Iv) User Interfaces . ·- _
cacs - Model Question .Paper • 2 • -Most applications that run on PC and workstations have user interface that re\y on
COMPUTER GRAPHICS AND VISUALIZATION desktop window system to manage multiple simultaneous activities.
1 • These .user interfaces will be working with' computer graphics. ·
Time: 3 hrs. Max. Marks:
Not,,...,.,...., FIYEf#U ........, ..,_, ONE/•ll ••-from ,ach modul~ <l<) b. With a neat block diagram, explain the atcbite.cture of raster,scan display ·,
Mention any 2 advantages and disadvantages. . (08 Marks)
MODULE-I Ans. Raster scan display
G
w
.1. L Define Computer Graphics, also brie8y explain the various applications ~f
graJ>hics. · . (08 Mari(&) . ,' .
Ans, Computer Graphics rema.ins one of the most existing and rapidly growing computer
fields. Computer graphics may be defined as the pictorial representation or graphical
representation of objects in a computer or computer graphics is concernt:d with all .
aspects of producing pictures or images using a computer. !l~ction (Dlsf•v
Applications of Computer Graphics datJ) comlnand
Applications of computer graphics are divided into 4 major areas
i) Display ofinformation ii) Design
OisiiuYI
I Keyboard I
iii) Simulation and animation iv) User lnterfaces Cll!Cl'ollu _ 'Y --
i) Display ofinformation
• Architects, mechanical designers and drafts persons use computer graphi +--. ~
system to generate useful information like floor plans of building etc.. cs
• Graphics can be used to develop and manipulate maps to display ·geographicat
~IQ-
-
~
·
00000111111100000 . CRT 1
and celestial informaili;in . . ·
• Workers in the field ofstatistics uses graphics system(computer plotting pac~g· )
for generating plots that aid the viewer in understanding the information in a es
00000000100000000
00000000100000000
I VldQo arttrolltr I___.
·CJ-
. .
Refrtshbuffer
• 3-D data generated by CT (computer tomography),MRl{Magnetic Reson '
Imag~g),Ultrasound and PET(position-emission Tomography) uses co~p~ce- .. Fig. ArcMtecture of a raster display. .
graph1cs. · er • Fig shows the architecture of Raster display. It -consists of display controller,
• ~ield of Scientific Vis~liz.ation provides graphical tools that helps research~rs CPU, video controller, refresh buffer, keyboard, mouse and CRT.. ·
interpret the vast quantity of data that they generate. · • The display image is stored in the form of l:s and O's .in the refresh buffer.
ii) Dc;sign . • The video controller reads this refresh buffer and produces the actual image on
screen .
.r: 7~
. • TQ(lay, the use of interactive graphical tools in computer aided d . (CA .
--·
6 inchid~ as trchitectul'e, mechanical engineering,des::fV~ · • It will scan one line at a time from .top to bottom & then back to the top.
. . r . . . . --.....
co1:;~te;°graph~c::':;~nc~::rs .ff~~ .animations,in all these applications
":\ s· . . r O ways. .. . :i , \
w, unulataon and Animation · '
• ?nee graphics systems evolved to be ca bl Of . . ·. '.· ' • : J /1
mreal time, engineers and research :a e generatmg soph,stlcated images . \. . . ·!" t
', .
impo_rtant use has been in the tra· _ers fg~I to use them as simulators, one of tho ·,:.z. •
• Th . . . mmg o pt ot. . .
. . e success offl,ght simulators led to th . .
· a vertismg industries. · .

. mtelevision,hiotion picture and ·d . us~ of computer.graphics far animation
. ,
·----.------ .--- .
.. --------------~-·
')
-•, ...
...
' I r ~-~! • ~•.1 •,.,, f r l"-f J
24
S111141ME.- ·'P.-,
Fig•. Raster scan CRT. .:·~
,.
25
-
L----- 0
V
VI SetW {CSE I ISE) co,rtpcdU (ir"~~(Nt'ld, v ~ .
. . .• I
cacs - M ~ Q ~ p a p e r -2
• In this method the horizontal and vertical deflection s1gna s are generated to .
vertices. • . . ..
the beam all over the screen in a pattern shown in fig. 1.4. Here beam is sw rnllve IVertex2i(Glint x1, Ghnt y1),
back & forth from left to the right. . tpt !1vertex3ftGlftoat x, Glfloat y, Glftoat z);
• When beam is moved from left to right it is ON. When beam is moved froin . Glfloat vertex[3];
1
to left it is OFF and process of moving beam from right to left after compl;~~ht Some of the Primitives are
of row is known as Horizontal Retrace. . llQ 1) GL_POINTS
• When beam is reache_d at the bottom o~ the screen. It is made_ 0 ;F an<;! rapil!J 2)GL_LINES
· retraced back to the top left to start again and process of moving back to top .~ 3) GL_LINE_STRIP
4) GL_LINE_LOOP
known as Vertical Retrace. · · · "
• The screen image is maintained by repeatedly scanning the same image. lo~ . S) GL_TRIANGLES
6) GL_QUADS
process is known as Refreshing of Screen. 001
• In raster scan displays _a special area of memory is dedicated to graphics 7) GL_POLYGON.
This memory is called Frame Buffer. Frame buffer holds set of intensity va1/ st GL_TRIANGLE_FAN
for all the screen points. _That intensity is retr!eved from fram~ buffer and dispi: 9) GL_QUAD_FAN
on screen one row at a time. Eac~ screen pomt referred as pixel or Pel (Pictu Y glBegin(GL_LINES);
Element). Each pixel can be specified by its row and column numbers. It ca 1't' g1Vertex2f(xl, yl);
simply bl•d< ~d white sy,tem o, eolo, sys!~- In simpl~ blaek and While
each p1~el 1s either 0~ or OFF, so only one bit per pixel 1s needed. Additional b.1
,y;;.
bo111 g1Vertex2f(x2, y2);
glEND(); . . · · _ _
are required when color and intensity variations can be displayed up to 24-bit · ~ Define a pair of points as: glBegin(GL___POINTS); g1Vertex2f(xl, y l ); g1Vertex2f(x2,
pixel are included in high-quality display systems. . sPer y2J; glEND(); . • '
1
• On a black and white system with one bit per pixel the frame buffer is com OR
ea//~ a Wtmap. An~ fo, systems wW, multiple bits pe, pixel, the frame bu';;;°'~ ,.
2. a. Describe the working ~fan output device with an example. (06 Marks)
often referred as a Pu:map. · · · · . er ts
Ans; .The most predominant type of display has been the Cathode.Ray T!!be (CRT).
,,.
Advantages: .
1) In raster scan display the beam is moved all oyer the screen one sea 1,
· fi · n ine y deflect
"m~ rom top to bottom and then baek· to top, hence the refresh proee
independent of the complexity of the image. ss IS
2) Implementation costis Low . · ·
Electron~
Disadvantages:
· 1) Graphics primitives
· th · are specified
· in tenns of their endpoints and must be sc
· ·conve ed mto elf corresponding pixels in the frame buffer.
rt , . an
2)
. JS
:71emore.
Scan conversion for each primitive appoximates the drawing d . . .
' · · an time taken
Focua
c. ~batis
h an OpenGL? Explain the different OpeilGL Primitives w1'th , Various parts of a CRT:
• Electron Gun ...: emits electron beam which strikes the phosphor coating to emit -
An& OpenGL is a :"'ftware inteiface to graphics hardw . . (04 Marioi light. .
about 150 d1stmct .commands that th e user spec1'fi esare.
to thThis b'interface consists
. . OI • Deflection Plates - controls the direction of beam. The output of the computer
nee e to produce mteractive three dim . I . . . . e o ~ects and operations is converted by digital-to-analog converters o voltages across x & y deflection
dd
a streamlined, hardware-independent in;;~ona appl!catJons.OpenGL is designedas · plates. •
.hardware platforms. ace to be implemented on many different •.
• Refresh Rate - In order to view a flicker free image; the image on th~ screen has
OpenGL primitives · ~be -~
OpenGL supports several basic primitive . . • retraced by the beam at a high rate (modem systems operate at 85Hz)
ao d general polygons. All of th . tyf~S, mcludmg points, lines, quadrilaterals, • 2 types of refresh: · ·
ese prun1hves are spec1'fi ed using• a :sequence.of
26 · ~~;z:,~
~t-1J"""' 27
VI se,,n, (CS£ I ISE} -----vv~~
0
. C<mlP~ <:,r-<,>,,prw,v.y ~· - - _· -
th CBCS - Mode-vQ~P"'PV 2
• Noninterlaced display: Pixels are displayed row by row at e refresh rat;-,--.
y Plotting_ e_oints (Rounded to lnteger)
• Interlaced display: Odd rows and even rows are refreshed_alternately. K
I
X
o+l=l (I , 1)
b. WiCb t.he necessary algorithm explain the digital differential analyzer(l)l) · o o+0.66=0.66 --'-
I 0.66+0.66= 1.32 1+1=2' (1,2)
method for scan converting line. · (OS l\ta.,~)
2 11.32+0.66=1.98 2+17'3 (2,3)
Ans. DIFFERENTIAL ANALYZER (DDA) ALGORTIHM )
3 1.98-+-0.66=2.64 3+1=4 (3,4)
Algorithm 4+1=5 , (3,5)
#define ROUND(a) ((intXa+o.5)) ~.64+0.66=3.3
voidlineDDA (int xa, int ya, int xb, int yb) RESULT: .
{ int dx = xb xa, dy = yb :-.Ya, steps, k; "6 + - - - - - - - - - - - - - - - - - A - ' -_ _ _ · r.•1
floatxlncrement, ylncrement, x = xa, y = ya;
if(abs (dx) > abs (dy) steps= abs (dx); 5
else steps = abs dy); . 4
xlncrement = dx / (float) steps; .
ylncrement = dy / (float) steps 3
setpixel (ROUND(x), ROUND(y)) :
for (k=0; k<steps; k++) 2
{
,1
x += xlncrement;
y += yfncrerrient; 0
setpixel (ROUN_D(x), ROUND(y)); 1 2 3 4 s
0
,l
J
} .
Algorithm Description: Advantages of DDA Algorithm
Step 1 :Accept Input as two endpoint pixel positions · . : 1. It is the simplest algorithm
-~
Step 2: Horizontal and vertical differences between the endpoint positions 2. It is a is a faster method for calculating pixel positions
assigned to parameters dx and dy (Calc~late dx=xb-xa and dy=yb-ya) . . Disadvantages ofDDAAlgorithm
Step 3:The difference with the greater magnitude determines the value of param~te
.. , r , I. Floating ·point arithmetic in DOA algorithm is still 'time~consuming
. .· . .
2. End poin~ accuracy is poor
Step 4 :Starting with ~ixel po~~tion (xa, ya), ~eterinine the offset needed at eac_ ti ~lep ,
c. What a~ Control functions in OpenGL? Explain (06 Marks)
to generate the next pixel pos1t1on along the lme path. · Ans. Window - A rectangular area of our display. ·
Step 5: loop the following process for steps number of times a. Use a unit of
Modern systems allow many windows to be displayed on the screen (multi window
increment or decrement in the x and y direction · environment).
b. if xa is less than xb the values of increment in the x and y directions are I and m The position of the window is with reference to the origin. The origin (0, 0) is the top
c. if xa is greater than xb then the d~rements - I and - m are used. ,· left corner of the screen. • . ' ..
· -Example: Consider the line from (0,0) to (4,6) :i,. glutlnit ( ): allows application to get command line arguments and initializes system.
1. xa=0, ya =O and xb=4 yb=6 The function is basically used for initializing the glut library and also t~. initiate a
2. dx=xb-xa = 4-0 :a: 4 and dy=yb-ya=6-0= 6 session _with the windows system. The function does not take any arguments and .
3. x=0 and y=O should be the first function to be called _within the.main program. ·
4 > 6 (false) so~ steps=6 glulnitDisplayModeQ requests properties for the window (the rendering context)
5. Calc_uiate xincreme~t = dx/steps = 416 = 0.66 and ylncrement = dy/steps ~t/6=1 _RGB color- specified l>y the argument GLUT_RGB. lt specifies that a 3 color mode
~-Setp,xeJ(x,y) =Se_tp,xel(0,0) (Starting Pixel Position) :' , · needs to be. used.
7. Iterate.t~e calculatmn for xlncrement and ylncrement for steps(6) number-~f tim~ Single buffering- GLUT_SiNGLE: .specifies that the images are static and only a
8· Tabulation of the each iteration · single frame buffer is required to ·store the pixels
·29
28 ~SJIAlllf).
-
VI Sem- (CSE I IS£) CO'f>'IPIMM' "1 ' "'1-'' ~ w - o--~'-Vl-\,
c-acs - M~QIM¼t'WfllPetper- - z
GLUT DOUBLE: specifies that the image; are animations and · two~
buffers~front and back are required for rendering a smooth image. Properties logica~; 3) Inside and Outside Test : This method is also known as counting number method.
While filling an object, we often need to identify wheather a particular point is inside
ORed together the object or outside out. The two methods involved here are a)Odd-Even Rule b)
glutWindowSize in pixels
glutWindowPosition from top-left comer of display Nonzero _winding number rule.
glutCrcateWindow create window with a particular title b. Discuss the 2D transformation matrix equation and homogeneous co-ordinates
Module-2 for the following v) Shear
iii) Scaling iv) Reflection
i) Translation ii) Rotation
3. a. BricHy explain various methods involved in filling polygons, also provide the · (06 Marks)
opcngl polygon fill area functions. (08 Marks) i) Translati_on : Translation is applied to an object by repositioning it along a straight
Ans.
Ans. Various methods involved in filling polygons are: line p;1th from one coordinate location to another. xl=x+Tx yl=y+Ty (Tx,Ty) -
1) Scan-Line translation vector or shift vector. .
2) Flood Fill r ii) Rotation: A two dimensional rotation is applied to an object by repositioning it
3) Boundary Fill
4) Inside-Outside Test .
1) Scan-Li,nc Algorithm: This algorithm works by intersecting scan line with
polygon edges and fills the polygon between pairs of intersections. The follow_ing

along a circular path in the xy plane.


Pl;~-G:os8 · -sine
tn8cos8
J ·
8- rotation angle
· steps depicts the working of algorithm. iii) Scaling: A scaling transformation alters the size of an object .
SI: Find out the Ymin and Ymax from the given polygon. xl=x.Sx yl=y.SySx and Sy are scaling factors. There are two types of scaling they
S2: ScanLine intersects with each edge of the polyon from Ymin to Ymax·.Name
are ·
each intersection of the polygon.From the diagram it is named as PO,Pl,P2,P3.
a) Uniform Scaling: Here Sx and Sy are assigned the same value.
S3: Sort the intersection point in the increasingorderofX coordinate i.e(PO,P I ),(P 1,P2)
b) Differential Scaling: Unequal values for Sx and Sy._
and (P2,P3). . iv) Reflection:' J:,. reflection is a transformation that produces a mirror image of an
S4: Fill all those pair of coordinates that are inside polygons and ignore the alternate
object. ·· .
pairs. · _ · By line y=0(x-axis)
2) Flood-Fill Algorithm : Flood Fill Algorithm makes use of four~connected and
Transformation Matrix is 1 0 ·o
eight connected method for filling the pixels. AccordingJo this technique instead of
0 -1 0
looking for a boundary color, it will look for all adjacnt pixels that are part of the
0 0 l
interior. · . By the X axis , the transfomation matrix is -1 0 - 0
4-Conncctcd Region: According to 4-connected region, the steps are
0 I 0
a) Initialize the value of the seed point(seedx,seedy),fcolor aiid dcol.
0 0 l
b) Define the boundary values of the polygon. Shear: A transformation that distorts the shape of an object such that the transformed
c) Check if the current seed point is of the default color,then repeat the steps 4 and 5
shape appears as if theobject is composed of internal layers thai had been caused to
till the boundary pixels reached. - slide over each other is _called shear.x-direction shear relative to x axis
d) Change the default color with the fill color at the seed point.
e) Recursively follow the procedure with four neighbourhood points. [t O -
8-C~~n~cted Region: According to this 8 connected region we have
a) Imtiahze the value of the seed point(seedx,seedy),fcolot and dol.
b) Define the boundary values of the polygon. · · .
~-d1n:cuoo sbcnt n,lalivc LO other rdcrr liars
1 slu -sh:r.yref
J
c) Check if the ~urrent seed point is of 4efault color then repeat the steps 4 and 5 till
the boundary pixels reached.
d) Chanf~he default color with the fill color at the seed point.
1 y-din:,,tion shc:ir n,lalh,: 10 i<=x.r

0
0
l

l
0
O

0
1
shy· I -shy,rrrf
O
·
J
e) Recursively follow the .procedure with 4 neighbourhood poms. . t 0 0 1
30 S""'""' e-, 'fJ4'1(g, S~E-P""- 31
VI Se..111 ( CSE I ISf. ) .... v .. r•·~· -: _:-\ _ __
,. 12 :11
' c. With a neat sketches

computer graphics system.
. .
explam the vanous types
ofviewsthatareemp0
(O 6 J\t~eq 1
.1
~t~l
c13CS
-
=-----------------------.;._-
1,.~-1·Q··-•H,.,..,,,p
._,.,,OtM:W"
OR
~=•v ••,.,e,r- •
2

1
Ans. ,1 With suitable examples explain some of the fill area attributes. (OS Marks)
4. 11,
Options for filling a defined region include a. choice between a solid color or a
lanar geometric projections
P . I Ans, patterned fill and choices for the particular colors and patterns. These fill options can

p.L., .1 ,. .· be applied to polygon regions ot to areas defined with curved boundaries, depending

,p•rr•ve
on the capabilitites of the available package, In addition , areas can be painied using

· I lr various brush styles,colors and tran.sparency parameters.


Fill Styles:Areas are displayed with three basic fill styles: hollow with ~ col9r border,

j
7
3 Point
filled with a solid color,or filled with a specified pattern or design . A basic fill style is
selected in a PHIGS program with the function : setlnteriorStyle(fs). Values for the
1 point · 2 point
fill-style parameter fs include hollow,solid and patten.Another value for fill style is
~ W axonometric · oblique hatch, which is used to fill an area with selected hatching pattems-pan1llel lines or
orthographic
I 7 crossed lines as shown in the figure:
. b. What is meant .by composite and concatenation of transformation? Illustrate
isometric gjJruttri,Q trim~rhe
with suitable e~amples. (08 Marks)
Fig Types of Views Ans. Composite Transfor~ations A composite transformation is a sequence of
Perspective and parallel projections: Parallel viewing is a limiting case . transformations; one followed by the other. We can set up a matrix for any sequence
perspective viewing Perspective projection has_ a COP where all t~e pro~ector lin: of transformations as a composite transform·ation matrix by calculating the matrix
converge. Parallel projection has parallel pr?Jec~ors. Here _the_viewer 1s assum product of the individual transformations ·
to be present at infinity. So here ~e have a "D1rect1on ofpr0Ject1on (DOP)" inste: If a transformation of the plane TI is followed by a second plane transformation T2
. of center of projection (COP). then the result itself may be represented by a single transformation T whfoh is th;
composition of Tl and T2 taken in that order. This is written as T = Tl ·T2.
Com?osite transformation can be achieved by concatenation of transformation
matnces to obtain a combined transformation matrix. ·
A combined matrix -
. . . . [T]_[X} = [X] [Tl] [T2] [T3] [T4] ... . [Tn] ·
'--->4--__J Proje~lion plane
Where [T1] 1s any combmation of
' • Translation ·
• Scaling
Fig (a) Perspective Projection (b) Parallel Projectio!J • Shearing
Orthographic Projection · • Rotation
Projectors are perpendicular to the projection plane. Projection plane is kept p~rallel • Reflection
to ~ne of the principal faces. viewer needs more than 2 views to visualize what an
obJect looks like from its multi view orthographic projection •
!n
The :hange ~he ~rde_roftransformation would lead to different r~sults, as in eneral
matr~x ?1ul~1phcation I~ not cumulative, that is [A] . [B] i- [B] . [A] and the !der of
:ult1phc?t1on. 1:he basic purpose of composing transformations is to gain efficienc
y _applymg a smgle composed transformation to a point rather than a 1 . y
senes.oftransformation, one after another. . ' PP ymg a
For example, to rotate an object about an arbifrary point (X y' h .
out three steps - . P' P'' we ave to carry

• Transla~e point (\, YP) to the origin.


• Rotate 1t about the origin.
• Finally, translate the center of rotation back where it belo~ged.

32 .33
VI se-m, (CSE I ISE) co-mputiw 1.:1 r~• """'d · -· ...
. · ing functions.
BrieRy explain the opengl 20 vie,~ . - line intersect the extension of boundary k as u = qk / pk. . . .
c. • · fi nct1ons are
Ans. Some of the bpenGL v,ewmg u bl . right,GLdouble botton~,GLdoub . e calculate values for parameters u I and u2 that define the part of \me
I) glOrtho(GLdouble left,GLdou e · It For eac h Im ' ·' · · d b I k" h
that lies within the clip rectangle. The value of ul 1s d~termmeh . y _doo (mg a)t Ft e
top,GLdouble zNear,GLdou?le ~Far). the clipping volume being [left,right) . rectang· 1e edges for •which the line .proceeds from outside to t ·e ms1 e p< . . or
0
2) lltis produces a parallel pr0Jett1on wit1t •n these edges we calcula_te rk = qk / pk. · .·. . . · .
· the x direction . .· F ] in the z direction.Only objects falti The value of u I is taken as largest of set consist mg of~ and vano~s v~lues of r. The
3) [bottom,top] in the Yd1rect1on [zNear,z ar . ng value of u2 is determined by examining the boundaries for which Imes proceeds
in this region will ~e dra~vn. . ,luPerspective(GLdoubl~ fovy,GLdoub\ from inside to outside (P>0). · ·. . . .
4) Setting a Perspective view mcludes g ,e A value ofrk is calculated for each of these boundaries and value ofu~ 1s !he minimum
aspect,GLdouble near,GLdouble ~ar) . ti xz plane and must be between 0 an . fthe set consisting of I _and the calculated r values. If u l>u2, the lme 1s completely
5) Fovy is the angle of the field ofv1ew Ill 1e . ;_ . d ~utside the clip window. and it .can be rejected. Line intersection parameters _are •
180. . . . I /I . I t) . initialized to values ul=.0 and u2=1. for each clipping boundary, the ~ppropnate
6) Aspect is the aspect rat1o(w1dt I ie~g l ·nt· to the near clipping plane(ahvay values for p and q are calculated and used by function Clip test to determine whether
7) Near is the distance from the v_1ewpo1 : .s the line can be rejected or whether the intersection parameter can be adjusted. When.
positive), GLdouble eyey GLdouble eyez,GLdoub\e p<0, the parameter r is used to update u I. When p>O, the parameter r is used to
8) gluLookAt(GLdouble eyex, GLdouble upx GLdouble upy,GLdouble upz) update u2. If updating u I or u2 results in u l>u2 reject the line, when p=O and q<O,
atx.GLdoubl~ aty,G_Ldouble ::•is the \ookFro~ point,the at point (atx'.,aty,a1z· discard the line, it is parallel to and outside the boundary. If the line has not been
. Here eye pomt(eyex,eyey,ey )_ ) is the view up vector.This ' ) rejected after all four value of p and q s have been tested, the -end points of clipped
. . ti e lookAt point.The up pomt(upx,upy,upz .t . . can lines are determined from values of u I and u2.
is I . . • t ·x and applies it to the current ma nx. .·
creates the approximate ma n . . . .. The Liang~Barsky algorithm is more efficient than the Cohen-Sutherland algorithm
Module-3 since intersections calculations are ·reduced. Each update of parameters u I and u2
.·. . e Lian -Bar~y Line Clipping algorithm . (_OS Marks) require only one division and window intersections of these lines are computed only
5. a. Explam m deta~I thf . gt . equation ofa line segment, faster l111e clippers have · once. Cohen-Sutherland algorithm, can repeatedly calculate intersections along a line
. Ans. Based on analysis o parame nc ; . . · ·
. been developed, which can be written Ill the form . . - . path, even though line may be completely outside the clip window. Each intersection
x= xi+ uAx y= yl + uAy0<=u<=I where A~= (~--x·l) and~~ - (~2 -yl) calculations require, both a division and a muitiplication. ·
In the Liang-Barsl-.-y approach we first the pomt chppmg condition Ill parametric . b. Expl~in the conce~t of Polygon Clipping. · · · · . (04 Marks)
form: Ans. To cltp polygons, .we need to modify the line-clipping procedures. A polygon
xwmin <= xi + u Ax<=. xwmax . boundary processed with a line clipper may be displayed as a series of unconnected
ywmin-<=yl +uAy<=ywmax . li1~e segme~ts (Fig.), depending on the orientation of the poiygon to the clipping
Each of these four inequalities can be expressed as µpk <= qk. k= 1,2,3,4 the w~nd~w. Display·~( a polygon processed by a line clipping algorithm. For polygon
parameters p & q are defined asp I =-Ax q I = xi - xwmin · clippmg, we requir.e an algorithm that,will generate one or more closed areas that
· p2 = Ax q2 =: xwmax - x I · are then scan converted for t~e appropriate _area fill. The output of a polygon clipper
P3 = -Ay q3 =yl-ywniin should be a sequence of vertices that defines the clipped polygon boundaries. ·
P4 = Ay · q4 = ywmax - y I

vc
Any line that is parallel to one of the clipping boundaries have pk=O for values of
k corresponding to boundary k= I, 2, 3, 4 correspond to left, right, bottom and top
boundaries. For values of k, find qk<0, the line is completely outside the boundary. I
I

If qk>=0, the line is inside the parallel clipping boundary.


.,·•
I

When pk<0 the infinite extension of line proceeds from outside to inside of the I I
- - -- - - - · - - - - - ... - I
infinjte extension of this clipping boundary. If pk>O, the_line proceeds from inside to ·Before. Clipping
Aftor Ctiop, n g
outside, for non-zero value of pk. ··
Calculate the value of u, th_at corresponds to the point where the infinitely extended · ·~pplying Suth~rland-Hodgeman concept polygon clipping can be achieved. The
diagram below illustrates the concept

34
35·
vrsem-(esc/ISE) . compi.auG~~(M'lNV v~ ¾
. GB Model b) Phong Lighting~
c. Write explanatory notes on . a) R . (081\f od,1
_at~)
· OR
. a. Explain the concept ofnormalization and viewport transformations. (08 Mal'~)
Ans. Colors are indices into tables of RGB values 6
• Requires less memory · Ans. Constnacl Conyer1 MaD Vlewl..g
· • indices usually 8 bits . MC
wortd-Coordln•••
scene Using we
Workt ·
Coordinat.a
Coordinat•• 10
NormaHzed
• not as important now M,odatlng-COOrdinate
Tr•n•forn...t lon•
___,._ to
Viewing
Vi...,\ng Coord•~•-
using Window•Vl.,.,.,-pc>f'\:
Coordinate, Speclftc..tlon•
• Memory inexpensive _ .
• _Need more colors for shading . d. ifthere are k in'dices then there ca ~- The viewing transformation in several steps, as indicated in Fig. First, we construct
In indexed mode, colors are stored as bn~ '.ces. d green and blue. This yields a hn "'I the scene in world coordinates using the output primitives. Next to obtain a particular
·kn-I ·colors that could be got by com inmg re ' . . llgc · orie~tation for the window, we can ser up a two-dimensional. viewing-coordinate
· t IRGB mode
color palette .as compared tot ,e norma . d .di system in the world coordinate plane, and define a window in the viewing-coordinate
Phong developed a simple model that can be compute rap• y .
.system. The viewing- coordinate reference frame is used to provide a method for
It considers three components setting up arbitrary orien\jltions for rectangular windows. Once the viewing reference
• Diffuse frame is established, we can transform descriptions in world coordinates to viewing
• Specular coordinates. We then define a viewport in normalized coordinates (in the range
· • · Ambient · from Oto 1) and map the viewing-coordinate description of the scene to nprmalized
And Uses.four vC9tors · · coordinates. At the final step all parts of the picture that lie outside the viewport are .
• To source represented by the vector I .
clipped, and the contents of the viewp,ort are transferred to device coordinates. By
.• To viewer represented by the vector v
changing the position of the viewport, we can view objects at different positions on
• Normal represented by the vector h
• Perfect reflector represented by the vector r the display area of an output device. . . . · .
. n V
b. Scale a triangle with vertices at original coordinates (10,25,5), (5,10;5), (20,10,10)
by sx=l.5, sy=2, and sz=0.5 with respect to the origin. For verification, roughly
r plot ~be x and y values of the.original and resultant triangles, and imagine the
locations ofz_va!ues. _ . · _ (08 Marks)
Ans. Ap~ly the prmc1ple of scaling a 3D object with respect to the origin by setting the
We need 9 coefficients to characteri~e the light source with ambient, diffuse and scal_n~g factors_sx, sy and sz, which are multiplied to the original vertex coordinate
th pos1t1ons (x,y,z): · ·
specular components. The Illumination array for the i light source is given by the

.·1iiJf'Li)_
Jr:~
matrix:
Lira 37.205 7.51
:ol=l~~
Liga Liba
· Li = Lird Ligd Libd 10
Lirs Ligs

and diffuse components.


Libs. .
T,he intensity for each color source can be computed by adding the ambient, specular
.
l ~J l 1 0 0 .
1 1 I .
l
5
1
5
I

_E.g. Red intensity"that we see from source I: c. With a neat diagram explain the CMY color models . . 04 M
lir = RiraLira + RirdLird+ RirsLirs = Ira+lrd+lrs Ans. A color model d_e~ile_d with the primary colors cyan, m~genta, and ello~ ~r~) .
Since the necessary computations are same for each light source, I = la+Id+ls us~ful for desc~1bmg color output to hard copy devices. . - y (CMY) Ul
I~ is a subtractive color model (i.e.,) cyan can be formed b . addin
hght. When white light is reflected from cyan~colored ink ythe rele~;::n,.,ghantd bluet
have no red . component . .i.e., red 1·ight _-1s
. a.bsorbed .or subtracted
, by the link mus
~hagbelnta mk subtracts the green component from incident light and yellow. subtracts
e ue component. - ·

36 37
.
-------
_· Mod.e,ltQ~lhr\!Pt;ifJU ; 2
VI Semt ( CSf I IS£) cscs · t·
h. i· .
we can remove them before t e c 1ppmg process
.
M
anywnY; to save processmgrf: 1me,ha normal vector. \fthis vector · ·1s pom
· fmg ·m the
with a simple test. Each su ~ce . s. \ ·s a front face and can be seen by the viewer.
direction of the center of pro{ct1on, I If rojection it is a back face and cannot be
If it is pointi~g away Jrom t. e cente~ o r ·r the z'component of the n9rma\ vector
seen by the v1ew~r. _The test i; ve~;~~: ze~~mponent of the vector is negative;·it is .
is positive, then, it is a ba_ck a~e._ ue onl .caters we\\ for non-over,lapping convex
y a front face. Note that this t~c _hmq th ey are concave polyhedra or overlapping .
h d I for other cases w ere · er b d
. Module-•4 po1_Y e ra . ti' ll need to apply other methods to further determine where the o scure
. . 3D viewing pipeline . _(04 ~arks) objects,arewe s or ,ompletely hidden ~ ther ob',ects._ .

L , ---
· "fac,,; pactfa,_ ~-==:::.i:.~~-----'2'1
7 aWith a neat diagram explam t_he Id to viewing coordmates is equ1vate111
· · . • d 'pt1ons from wor. ·11g reference "',rame i;>nto the Wortct
Ans, Conversion ofobJect1on escn · ,poses the v1ew1 Hidden surface
to a transformation .that supen~1 translate-rotate operations: .
frame using the basic geometric . It . . of the world-coordmate systen,
. ti point to t e origin . .
I. Translate th_e view re_erence nd zv axes (viewing coordmate system) With
2. Apply rotations to altgn the xv, ~v, a OR
the world xw, yw, zw axes, respectively. . .
. . E 1 • the mapping of a given view volume to 8. 11, Explai~ Parallel Projection in detail . . . . (06 Marks)
b. What is canonical vi~w volume? xp am . . .(08 Marks) -Ans, Perspective projection is done in 2 steps: Perspective tr~nsforma~ion and Paral_lel
the canonical form, . . ss · projection. These steps are described in the followmg section .. Pers~ect~ve .
Ans. The diagram shows the normahz.at1on p=,rop,.far) Transformation and Perspective Projection To pro<luce perspective v1ewmg
effect; after Modelling Transformation, Viewing Transformation is carried out

<'1'. _ .51·-'l r ·.
to transform objects from the world coordinate system to the viewing coordinate
system. Afterwards, objects in the scene are further processed with Perspective
Transformation: the view voiurrie in the . shape of a frustum becomes a regular
. parallelepiped. The transformati~n equations are shown as follows and are applied
(/elt,bottom,-neo,j (-1,-1, 1) . , to every vertex of each object: ·
First the view volume ,specified by the glortho function is mapped to the canoni1:al . x'= x * (d/z), ·
y'-=y * (d/z), .
~;:nical ~orm : default view volume centerd at the origin and having sides o( z'=z
length 2. Where (x,y,z) is the original position of a vertex, (x' ,y',z' ) is the transformed position
This involves 2 steps : of the vertex, ·
- Move center to origin and d is the distance of image plane from the center of projection.
T(-(left+right)/2, -(bottom+top)/2,(near+far)/2)) Note that: . Perspective transformation is different from perspective projection:
- Scale to have sides of length 2 Perspect~ve . projection projects a 3D object onto a 2D pl~ne perspectively.
S(2/(left-right),2/(top-bottom),2/(near-far)) . Perspective tra1~sformation converts a 3D object into a deformed 3D object. After
The result~nt matrix is a product of the above. 2 matrices i.e. the transformation, the depth value of an object remains unchanged. .
P =ST = 1000200020002 near far near far far near bottom top bottom top bottom · Befor~ th~ persp~ctive transformation, all the projection lines converge to the center
top left right left right left right · · of proJectlon. ·
After the transformati~n, ~II the pr~jectiori lines are parallel to each other. Finally we
c. What is meant by back face detecti<m? Explain in detail. (08 Marlu)
can _ap~ly P,aral\el pro~ectlon to proJect the object onto a 2D image plane. Perspective
Ans. In a solid object, there are surfaces which are facing the viewer (front faces} and ProJectton = Perspective Transformation + Parallel Projectfon · · ·
there are surfaces · · ·· ·
Which are opp~site to the viewer (back faces). These back faces contribute to
approximately half of the total number of surfaces. Since we cannot see.these surfaces

38
VI sewv(CSE ( ISE) l,Vmyvvv-• -, -- cJ""\,C"~
u-..J-1.,,.,~p~e,- · 2
b Classify the visible surface detection algori~hmds. (~
caCS - rv10lMW'"'
. · ations for perspective projection and describe the specifications or a
. . . S rf d t fon algorithms are c\ass1fie as oenve equ , · (06 Marks)
c. tive camera view in open GL. · . . .
Ans, ~:~~t~;::e ~:~~ods: Compare objects and p~rts of objects to each other Withi perspec . d' te system is specified by a translation and rotation ~1th respect to
~he s~ene definition to determine which _surfaces, as a whole, we should labe\ Ans, 111e new cood~ ma t , .
the old coor mate sys em:
visible: For each object in the scene do · · . v'-= R (v - v0) vo·is displacement vector . . b h , coordinate
R is rotation matrix. R may be decomposed into 3 rotations a out t e-
~:ennine those part of the object whose view is ~nob~tructed by 0ther pa115 ofit
axes:

u ....:.,11
or any other object with respect to the viewing spec1ficatlon. Rx ·• 0
2. Draw those parts in the object color. · cosu
-slnu ·oo•u
~~:mpare each object with all other objects to det~rmine the visibility of the object

r·l.,!p 1
par.ts. . Ry= 0
1 . 0
- If there are n objects in the scene, complexity= O(n2) 0 c01p
• Calculations are performed at the resolution in which the objects are defined
(only limited by the computation hardwure). · · Rz ·• cos1 slny O
- Process is ~nrelated to display resolution or the individual pixel in the image and . , -slny cosy · 0 -
the result of the process is appjicable to.different display resolutions. · ·, . 0 0 ·'
- Display is more accurate but computationally more expensive as compared to image .By mulfiplylng the 3 matrices Rx, Ry and Rz, one gets

1
space methods because step I is typically more complex, eg. Due to the possibility ~ '
R=lcospcosy , cos\\slny -1lnp
intersection ·between surfaces. · ·
- Suitable for'scene with small number of objects and objects with simple relationship slnusln pcos y-cosusln_y •~nasln psl_n y+cosaco1 l llnacosp
with each other. • cosasln pcos y+slnusln y coausln pain y-alnacos y cosc.cos P
ii) Image Space.Methods • . . . · .· For formula manipulations, one tries to avoid the trigonome~ric functions and takes
Visibility is determined point by point at each pixel position on tl1e projection, plane.
For each pixel in the image do
Begin .
R= lrr2, .
11
- · _r12
r22 - r23
r1
13

1. Determine the object closest to the viewer that is pierced by the projector through·. r31 ·r32 r33
the pixel · · · ·
2. Draw the pixel in the object colour. . A rotation matrix is orthonormal: R RT= I (unit matrix)
End Module-5
- For each pixel, examine all n objects to determine the one closest to the viewer.
-.If there are p pixels.in the image, complexity depends on n and p (O(np) ). . 9. a. Which are the six classes oflogicalinput devices? Expiain. . . (08 Marks)
- Accuarcy ofthe calculation is bounded by the display resolution. Ans. Locator: return a position; Placing the inouse pointer at any location on the screen
- A cliange of display resolution requires re-calculation would return the correspondi~g x and y coordinates ofthe location~Mouse acts as a
locator device. · .· . · . ·
Application of Coherence in Visible Surface Detection Methods: .
- Making use of the results calculated for one part of the scene or image for other. -_Pi~k: return 1D of an object. When there are several graphical objects on Ute screen .
nearby parts. · p1ck~ng one of them and that would occupy the entire screen. This is a pick operation.
- Coherence is the result of local similarity Agam the mo.use can act as a pick device. · . ·
-As obje~ts have continuous spatial extent, object properties vary smoothly within a - ~eyboard: return. stri_ngs of c~aracters. ·Typing on the keybo~d would keep
small local region in the.scene. Calculations can then be made incremental. . sto~mg t~e typed )etters mto a buffer and on events like pressing on enter key, the
entire_stnng would be returned to the graphics system. Keyboard itse\fis the device
for this purpose. · · · · · · ·. ·
in
_- Str:oke: retri~ array of positions. Basically used paint applications where w~~n
a pamt brush 1s moved across the editor a strok~ is generated. All the locations
. . .
·40 ~Z--P'"'- 41
VI semv (CS£ I IS£) comptAtU '1t'C\f''"-VK ""' ""' ,, ----
;n,olv«I ;n the stroke '" mum«!""" aaay. Mouse""' ,ct" •strokedev,ce . ..,_ iv)Local Modification Scheme: changing \be position of control point l' only
- Valuator: retum floating point number. · ( · affects the curve C (11) on interval lu,, 11,,,,. 1) . '
- Choice: retum one of n items. When there are several items on the scree b) QvenGL Quadric Surface function11
selecting one of they are the purpose of this device. lt could be selected by an th~~ Some of the GLU functions are
click which retums the id.associated with a particular object. moll¾ gluSphere (name,r,nLongitudes,nLatitudes);,
uCylinder (name,rBase,rTop,height,nLongitudes,nLatitudes),
b. Suppose that the openGL window is 500 X SO p;xels and th~ dipping window . g!uPartialDisk(name,rin,rout,nRadii,nRings,Ang\estart,AngleSweep);
a unit square with the origin at the lower left corner. Use simple )(QR mode ~ OR
draw erasable lines. _ · · (06 Mar~)
10. a. What is the functionality of display lists in modeling'? Explain with an example.
(OS Marks)
Ans. void Mouse Move (int x, int y)
{ Ans, Display lists help in avoiding redundant code by storing the compiled code i~ a
if(FLAG"~ 0) . buffer and then re executing it again and again. .
{ • F~r cg:1:he most efficient way of _ defining text is to define the font o,nce, using a
X = x;Y=winh-y; Xn=x;Yn=winh-y; FLAG =-1; d_1splay hst for each char, and then store the font on the s~rver using these display
} -hsts ·
else if(FLAG = 1) • A function to draw ASCll characters
{ void Ourfont(char c)
glEnable(GL_COLOR_LOGIC_OP);
{ switch(c) ·
glLogicOp(GL_XOR);
{
glBegin(GL_LlNES); case '0':
g1Vertex2i{X,Y); glTranslatef(0.S,0.S,0.0); /* move to the center•/
g1Veriex2i(Xn,Y n); g!Begin(GL_QUAD_STRlP) . · ·.
glEndO; glflushO; t•Old line erased•/
for (i=0;i<l2;i++) 1• 12 vertices•/
glBegin(GL_LINES); { .
. g1Vertex2i(X,Y); g1Vertex2i(x, winh -y); angle= 3 -141 59/6.0 •. i; /* 30 degrees in radians */
glEnd(); glFlush(); Xn = x; Yn = winh -y;
} }
c. Write a) Bezier Spline Curve b) openGL Quadric Surface functions (06 Marks)
·f glVertex2f(OA*cos(imgle)+0,5,0.4*sin(angle)+0.S)
Vertex2f(O.S*cos(angle)+0.S,0.S•sin(angle)+o.S)

Ans. B-spline
a) Beziercurves
Splineshare
Curvemany important properties with Bezier curves, because the g\End();
break;
former is a generalization of the later. Moreover, B-spline curves have more desired }
properties than Bezier curves. The list below shows some of the most important }
properties of B-spline curves.In the following we shall assume a B-spline curve C(u)
. A b. What are polygonal surfaces, meshes and Tables? Explain (08 M . ~)
o~ degree p is defin~d by n + _1 control points and_ a knot vector U = { u0, u 1, ...., u. }
ns. P?lygon Su~aces: This method.simplifies and speeds up the surface renderinara d
with the firstp+l and lastp+l knots "clamped" (1.e.,u0=u, =... =up and u11-p= u. ..,,.,
?'splay of objects. For other 3D objection representations they ft ·g nd
= ... = u.JSome of the properties are · · mto polygon surface~ before rendering. . ' are o. en converte
i) . B-spline curve C(u) is a piecewise curve with each component a curve of degree
Polygon Mesh: Using a set of connected · \ \\ ·
· represent an object which m h dpo ygona Y bounded planar surfaces to
p. • d. \ '. ay ave .curve surfaces or curved edges. The wireframe
ii) Equality m = n +p + 1 must be satisfied. Clamped B-sp\ine curve C(u) passes
s:~a: :~r:~;:r:b::!t~~ be dlsp_layed quickly to give genera\ indication of the
through the two end control points PO and Pn' · . . is IC ren ermgs can be produced by interpolatin shadin .
iii) Strqng Convex Hull Property: AB-spline curve is contained in the convex hull
:::r::'.e~e polygon surfaces to eliminate or reduce the presence o\ polygo!
?f_its control polyline. More specificaUy, if u is in knot span lu;,u;+ 1), then C(u)
lS m the convex hull of control
· points P ,, P1~1 , ..., P1. · ·

A.?
VI 5e,w11 CWt: 1 .1-J'-/ • _ __ ,_ _

'Ia hies• This is the specification of polygon surf~ces using vertexcoord· .


.Po1ygoo . • · · •na.te, .
and other attnbutes: · . · · Sixth Semester B.E. Degree Examination, CBCS - June / July 2018
I. Geometric data table: vertices, edges, and polygon surfaces. . . . ,
_ Attribute table: eg. Degree of transparency . and surface reflectivity etc. Soll\ . Computer Graphics and Visualization
2 ·Max. Marks: 80
consistency checks of the geometric data table: · e Tinie: 3 hrs. · ONE II ,,estiorr rom eacll module.
Note : A11swer a11 FIVE 111/ uestio11s, selecti11
• Every vertex is listed as an endpoint for at least 2 edges. 11

• Every edge .is part of at least one polygon. Module-1


• Every polygon is closed. · With neat diagram, explain basic design and operation of cathode Ray tube.

A' 1, a.

ADS,

Focusing
Syste m
Magnetic
, Deflection Coils
·
'(08 Marks)

Ph osphor-
Coated
Screen

._. . EVE. ..
v. E lectron
POLVGON-SURFACE Beam
I.
I VERTEX TABLE EDGE TABLE TABLE

v,: y,.z, E.,: v,. v. 5 1 : E,.E 2 ,E3

v.: "•· ,.,,. z,,.


x,. E, : v,.. ·v> Sz: Ea,,. E 4 ..-E,,.~ E 0
E3: v,.. v,
">• y~. z,,

..~-
V>:
v.: "•· y,.. z, E. :. v • . v. Fig (a) : Basic design of a ~agnetic deflection CRT
"•· ,, The above figure shows the basic operation of aCRT. A beam of ~lectron emitted by
.v ., Ea : v • . v.
E. : v., v,
an electron gun, passes tl1rough focusing and deflection system that direct the beam
fowards specified positions on the phosphor coated screen.
c. With the necessary illustration, expJahl the blobby obj~ts; . (04 Mar~)
The phosphor then emits . a small spot of light at eac~ position contacted by the
Ans. · Irregular surfaces can also be generated using some special formulating 3ppr~ac~,
electron beam. Because the light emitted by the phosphor fades very rapidly, some
to form a kind of blobby objects - The shapes showing a certain degree of ftutdi~ ..
method is needed for maintaining the screen picture one way to do this is to store the
Thebelowe picture infonnation as a charge distribution with in the CRT.

Heating
Filament

Fig (b) Operation of an electron gun with an accelerating anode


This charge distribution can then be used to keep the phosphors activated the most
common .method now employed for maintaining phosphor glow is to redraw the

~l\t..f-Ar et<AM ~MW' 1


VI se,m, (C~t:J l~t / -r - . ' . .

---
'-N ·: - u v~ , .. . .~ -

picture repeatedly by quickly directing the electron beam back over the sa . cBCS . ;,Mte!Jtily 2018
points. This type of display is called a refresh.CRT, and the frequency : :S\:.\
picture is redrawn on the screen is referred to. as the refresh rate.
The primary components of an electron gun m a CRT are the heated metal
h1ch I
Slope(m)=!:l.y/ !:l.x= 8/10=0.8 ·
Thisllneha_saslopeofO.~ · 1
I
. . · 1· d t · th th d cath
and a control grid sho~n in ~he _fig. Heat is supp ie. ? e ca e ?Y direc~ The initial decision parameters has the value
a current through··a coil of wire, called the filament 10s1de the cyhndncal c h, Po=2!:l.y-!:l.x .
structure. This causes electron to be "boiled off" the hot cathode surface. ai ~ ,,;2x8-10 •
In vacuum inside the CRT envelop ~he· free, ~egativ~lt charged electron are th :::16-10
accelerated toward the phosphor coatmg by a high pos111ve voltage. The accelerartii
P0 =6 .
voltage can be generated with a_positively charged met~l coating on the insi~e of~
· and the increments for calculating successive decision parameters are
CRT envelop near the phosphor screen, or an acceleratmg anode as show~ mfig(~
2/J,,y = 16, 2!:l.y :-: 2!:l.x =--4 . _
can be used to provide the positi:ve voltage sometimes the electron gun is d~signed
we plot the initial point (x0,.y0)= (20, 10), and determine successive pixel position
that the accelerating anode and focusing system are within the same unit. ·
. Intensity of the-electron beam is controlled by the voltage at the control grid, whi along the line path from the decision parameter are ·
is a metal cylinder that fits over the cathode. A high negative voltage applied tot K P. (x ..... ,, Y•• ,)
control grid will shut off the beam by repelling electrons and stopping them fro 0 6 (21 ,lij ·
passing through the small hole at the.end of the control-grid structure. I 2 (22, 12)
. A smaller negative voltage cin the controlgrid simply decreases the number. 2 -2 (23, 12)
electrons passing through. The aniotintof light' emitted by the phosphor coati . ·
3 14 . (24, 13)
· depends on the number of electrons striking the screen, the brightness of a displ
point is controlled-by varying the voltage on the control grid. · 4 JO (25, 14)
b. Write Bresenham's line.drawing Algorithm for l~I< 1.0 Digitize the line ~it s 6 (26, 15)
endpoints (20, 10) and (30, 18). · . . · (08Mark., 6 2 (27, 16)
Ans. . Bresenham's Line-Drawing Algorithm for jml <· 1.0 · . · 7 -2 (28, 16)
. I.Input the two line endpoint and store the left end point in (x0, y0). . 8 14 (29, 17)
. 2. Set the color for frame- buffer position(~ yJ, i.e., plot the first point ;- .,
9 10 (30, 18)
3. Calculate the constants rue, !:l.y, 2!:l.y and 2!:l.y-2 !:l.x, ·
and obtain the starting value for the decision parameter as r
.P0 =2!:l.y-!:l.x .
4. At each xk along the line, starting at k = 0, perfonn the following test. 18 II

-
. ifpk <0,thenextpointtopl_<?tis(xk +l;yk)and . ,. -
• -

-
II '
+ 2/J,,y
pk+I ::; pk

otherwise, the next pointto plot is


15
, •
••
J

(xk + l,}'k + I)andPk+I =Pk +2!:l.y--2!:l.x :

5.perfonnstep4!:l.x-l times_.
I
Wedigitiz~ the li~ewith endp~int( 20, IO )and (30, 18) 10

· (20,IO)and(30,18) 20 21 22. ,25 30

Xo=20, x,=30· yo;::)0, Y,=18 Fig: pixel p~sitio~s alo~g ~e line paih, between e~dpolnt (20, I0) and (30, 18)
!:l.x=~-~ pl~tted with_ Bresen sham line algorithm
30-20 18-10
·2 !:l.x=IO dy=8
3
OR CS . JIM'\£/Jv.}.;y 2018 _
CB . . 1. ly caHed a bitmap and a frame buffer with multiple
. It t rand Random scan displays based on television l'~h with one bit per pix~ 1s common _ ·
·2. a.. Briefty exp1am as e . . l\11111,,. bits per pixel is a pixmap.
. d on\y t o th ose
Ran d o m - scan display . CRT has the electron· beam direde
·
.

. 1 .
Ans. Raster scan displayt · . h
the electron beam 1s swept across t e screen, one ro ·1n a random - sca_n d1sp ay u~1t, a . t be displayed. Picture are generated as \ine
In a raster scan sys em, S ·r '" parts o f the screen where a bpicture 1sT o out the component \mes
. one aft er th e oth er.
time, from· top .to bottom. Each row is referred to as a cre~n m~. . .. drawings, with the ~\ectron e,am tr:1rrmedg to as vector display. The component lines
As the electron ·beal1l moves across a scan li~e, the bea~ _mte~s1ty is ~rned on d scan monitors are a so re,e . "fi d
·off to create a pattem o f '1lluminated spots · Picture definition 1s stored . Ran om- d d fi hed by a random-scan system m any spec, e
_ f ·ma Illell\ of a .picture can be rawn an re res
th
area called the refresh buffer or frame butler, where e term rame refei:s to ·order. As shown in below fig. . ·
total screen area. This memory area holds the set of color values for the sc
points. These stored color values are then retrie:ed from the refresh buffer and_
to control the intensity of the electron beam as it move~ fr~m spot t~ spot across
screen. In th_is way, the picture is "pointed" on the screen 1s shown m the fig

(a)

(c) (d)
'-
.Fig: a random .- scan system'. d~ws the component lines of an .obj~~t in specified any
· , · · _· _ ·,: , .· _ · order: ·
Refresh rate on a random .:scan SY.Stem depends on the numbers of lines to be
(c) (cl) displaye_d on that system pictur~ defihition is now stored as a set of line-drawing
Fig: a raster-scan system displays ;ind object as a set of discrete points across ea commands ·in an area of memory referred to ·as the display list, refresh displayed
- scan line. · vector file, or display program. · _ t ·•
Each screen spot that can 6e illuminated by the electron beam is referred to as b. Write midpoint circl~ Algorithnt Given 'a :circle with' radius rdtO demo'n strate
pixel or pel.the refresh buffer is used to store the set of screen color values, it isa the midpoint circle algorithm by determining positions along circle octant in
sometimes called a colo_r buffer alt the different buffer area are sometimes refe first_Quadrant from x=O to x=y . · ·1 ' '· ; ' (08 Marks)
to collectively as the "frame buffer" Ans. The initial value of the decision parame,er is · ,-. ' · 1' · • · • '
Aspect ratio is another property of video monitors, which is now often defined as P=l-r=.:.9 ·-· - ., · -,, ·. . ,.
, 0. . - .. , .

numbers of pixel columns divided by the numbers of scan lines that can be display . For the circle centered on the coordinate origin the in~ti'al p·o int is· (x , y O) = (0, 10)
by the system. Aspect ratio can also be described as the number of horizontal po' and initial increment terms for calculating the decision parameters art • ·
2x =O '>y· ='>O · · . ·i -.,_ · ... -:" ·. , ,,: . _
to vertical points necessary to produce equal length lines in hath directions on
a
0 · ' - 0 - ' .
screen .. The numbers of bits per pixel in frame buffer is sometimes referred to Su~cessive midpoint decision parameter ·values ' and the cori-espondi~g ·d 1ordinate
either the depth of the buffer area or the number of bits planes. Also, a frame buffi positions along the. circle path are listed 111 'the following table ·' ' . ., '
. . I .· . . , • , , 'I\

4 5
VI Se-tW ( CSE/ISO - cBCS -J~Ji,wy 2018
K· P, . (x. , Yu .),
( l, l 0)
2 X. ~
.2
2y,., ,
20 - ---closed ·poly Jine.
0 -9 20
(2, 10) 4
l -6 20
(3, 10) 6
2 -1
8 18
6 (4, 9)
3 l () · 18
-3 (5, 9)
4 16 £
(6, 8) 12 -
5 8 ..
14. 14
5 (7, 7)
6 -
B
.,
V
,,= X
y
Fig : Odd-Even Rule . .
10
9
III •-- ;
;
; "·
;
,, ;
. ·2) Non zero winding numbers rule
Another method-for defining interior regions is the-non zero winding number ru~e,
which .counts the numbers of times the boundary of an· object ..winds" around a
-

ii
7
;
,, I particular point in the counter clock~is~ direction. This count is called the winding .
number and the interior points of a two dimensional object can be defined to be
6
, "· those that have a nonzero ·value for the winding numbers. We apply the non zero
5
, \ winding numbers rule by initiaiizing the winding number to O and again imagining .
,4 ;
; a line drawn from ariy position P to a distant point beyond the coordinate extents of
;
3
,, ; ,· the object. The 'line we choose must riot pass through any_endpoint coordinates. As
2 - ;
- we move alongthe ' lin1; from position P to the distant ·point, we count the number
i ,, ;
·of object line segment that cross the reference line in each dir~ction. We add l to
,/ -
0
0 ·1 2 3 4 5 6 7 8 9 ' Ig . X. .
. the wind.ing number every time we intersect a segment tllat crosses the line in the
4irection from right to left, and we subtract l every ,ime we intersect a segment that
fig pixel positions along a circle·path centered on the origin and with radius r ==Io, cross~s from left to right. The final -value ~f the winding numbers, after·all boundary
as calculated by the midpoint circle algorithm. Open circles show the symmetry crossings have been counted, determines the relative position of P is taken to be an
· - - positions in the first quadrant. _, _ exterior point shown in below. · . ·· - · · . .
Modul~2 A

3. a. With neat :diagram 1 · eiplaiil the two commonly ·used algorithm for identifying
interior area of a plane figure. · (081\:farks)
Ans. Two cpmmonJy used algorithm for identifying interior areas of~ plane figure are the

, I - , _, •

1) Odd ".' even rule ., · . -


-2)Non - zero winding - number rule.
1) Odd - even rule .
Odd - even rule, also called the odd- parity rule or the even- odd rule~,by tint .£

_conceptually drawing a li_n_e from any position p to a distant point outside tho
. coordinate ententes of the <;losed poly line. Then we count the number ··of lino- B
segment crossings along this .-line if the number of segments crossed by ti{is tine•is
od°:, then p con.sider to be ari interrior point otherwise, we must sure ~t the line path , Fig: NQnzero Winding-Number Rt1\e
~e c~oose does ~ot int~rsect any_ line segment endpoints shown in the above fig tho
mtenor and exteno_r regions obtatned using the odd - even·rule for a self intersectin& '\

You might also like