Download - MCS 053 Final
-
8/12/2019 MCS 053 Final
1/28
--------------------------------------------------------------------------------------------------------------------------------------
Course Code :
MCS-053
Course Title : Computer
Graphics and Multimedia
Assignment Number : MCA
(5!053!Assign !"0#3
Ma$imum Mar%s : #00
&eightage : "5'
ast )ates *or Submission : #5th +ctober, "0#3 (or .ul/ "0#3 Session
#5th April, "0# (or .anuar/ "0# Session
There are *i*teen 1uestions in this assignment2 Anser all the 1uestions2 "0 Mar%s are *or
4i4a-4oce2 ou ma/ use illustrations and diagrams to enhance e$planations2 6lease go
through the guidelines regarding assignments gi4en in the 6rogramme Guide *or the *ormat
o* presentation2
7uestion #: (8 Mar%s
Differentiate between following:
(i) Painting and Drawing
Anser:
The di**erences beteen 6ainting and )raing6ainting )raing
6ainting functions, on the other hand, dont create objects. Ifyou look at a computer screen, youll see that its made up ofmillions of tiny dots called pixels. Youll see the same thingin a simpler form if you look at the colour comics in theSunday newspaperlots of dots of different colour inkthat form a picture. Unlike a drawingfunction, a paint function changes the colour ofindiidual pi!els based on the tools you choose. "n a
photograph of a persons face, for example, the colourschange graduallybecause of light, shadow andcomple!ion. #ou need apaint function to create this kind of effect; theres no
ob$ect that you can select or moe the way you can withthe drawn s%uare, i.e., a painting program allows the user
to paint arbitrary swaths using a brush arious si&e,shape, colour and pattern. 'ore painting programsallows placement of such predefined shapes asrectangles, polygon and canas. ny part of the canascan be edited at the pi!el leel.
)raing is a softwareapplication
means using tools that create
objects,such as suares, circles,lines or te!t, which the programtreats as discrete units. "f you
draw a s%uare in PowerPoint,
for e!ample, you can click
anywhere on the s%uare and
moe it aroundor resi!e it. Its
an ob$ect, $ust like typing theletter ein a "ord processor, i.e.,
a drawing program allows a user
to position standard shape (alsocalled symbols, templates, orob$ects) which can be edited
by translation, rotations and
he reason why the differences are important is that, as noted earlier, many different kinds of
programs offer different kinds of graphics features at different leels of sophistication, but they
tend to specialise in one or the other.
(ii) *omputer +raphics and nimation
Anser:
The di**erences beteen Computer Graphics and Animation:
nimation is a time based phenomenon for imparting isual changes in any scene according to
any time se%uence, the isual changes could be incorporated through translation of ob$ect, scaling
of ob$ect, or change in colour, transparency, surface te!ture etc., whereas +raphics does not
contain the dimension of time.Graphics 9 )imension o* Time Animation
-
8/12/2019 MCS 053 Final
2/28
--------------------------------------------------------------------------------------------------------------------------------------
(iii) Printer and Plotter
Anser:
The di**erences beteen printers and plotters:
(a) Plotters print their output by moing a pen across the surface of piece of a paper. his means
that plotters are restricted to line art, rather than raster graphics as with other printers. hey can
draw comple! line art, including te!t, but do so ery slowly because of mechanical moement of
pen.
(b) nother difference between plotter and printer is that the printer is aimed primarily at printingte!t. hus, the printer is enough to generate a page of output, but this is not the case with the lineart on a plotter.
(i) andom Scan Display Deices and aster Scan Display Deices
Anser:
The di**erences beteen ;andom Scan )ispla/ )e4ices and ;aster Scan )ispla/ )e4ices:
(a) "n andom Scan system the Display buffer stores the picture information, further thedeice is capable of producing pictures made up of lines but not of cures. hus, it is also
kno"n as #ectordisplay de$ice or %inedisplay de$ice or &alligraphic display deice.
(b) "n aster Scan system the -rame buffer stores the picture information which is thebit plane (with m rows and n columns) because of this type of storage the system iscapable of producing realistic images, but the limitation is that the line segmentsmay not appear to be smooth.
7uestion ": (5
Mar%s
rite a program in */*00 to generate line segment between two points, by using DD line
generation lgorithm. #our program should map each and eery step of pseudo algorithm, in
the form of comments.
Anser:
#include // Header File For The Windows Library#include // Header File For The OpenGL32 Library#include // Header File For The Math Library#include // Header File For Standard Input/Outputconst float PI=3.14;
void drawine!int "$int %$int "1$int %1&' // in(ut the
line end(oint and gl)egin!*+P,I-&;
store the left end(oint in !"$ %#&
gl0olor3f!1.$1.$1.&; and rightend(oint !"1$%1& doule m=!doule&!%12%&/!"12"&;// calculate the values of x and y doule %=!doule&%;using x = x1 x0, y = y1 y0 doule "=!doule&"#;if!m
-
8/12/2019 MCS 053 Final
3/28
--------------------------------------------------------------------------------------------------------------------------------------
%=%8m; // calculate the valuesof " and % increment "88;and assign the value "88 and %=%8m
99
-
8/12/2019 MCS 053 Final
4/28
--------------------------------------------------------------------------------------------------------------------------------------
else 'doule m1=1/m;
while!%
-
8/12/2019 MCS 053 Final
5/28
--------------------------------------------------------------------------------------------------------------------------------------
-
8/12/2019 MCS 053 Final
6/28
--------------------------------------------------------------------------------------------------------------------------------------
7uestion 3: (5
Mar%s
Draw line segment $oining (12, 32) and (14, 35) by using 6resenham 7ine +eneration
algorithm.
Anser:
-
8/12/2019 MCS 053 Final
7/28
--------------------------------------------------------------------------------------------------------------------------------------
7uestion : (5
mar%s
+ien a circle radius r 8 4, determine positions along the circle octants in 3 st 9uadrant from !8 2 to ! 8 y.
Anser:n initial decision parameter p
28 3' r 8 3' 4 8' 5
-or circle centred on coordinate origin the initial point (x2
,y2
) 8 (2, 4) and initial increments for
calculating decision parameter are:1x2
8 2, 1y2
8 32
Using mid point algorithm point are:k
2p
k
(xk 9 #
, "xk
"/
3
(1, 5 32
1 5 (, ; 32
'
(5, < ere too the condition of isibility of the line is tma! A tmin andthe line is isible from P 0 tma! (9' P) to P 0 tmin (9' P), if tma! tmin then re$ect the linesegment. Bow, applying this rule to theFigure 13, we find that when P9 line segment passes
through the non?cone! window, it cuts the edges of the window at 5 points. 3( PC 1 ( P7 ( PC 5 ( P7 . "n this e!ample, using the algorithm we re$ect the line segment P9 but it is not
the correct result.
-
8/12/2019 MCS 053 Final
8/28
--------------------------------------------------------------------------------------------------------------------------------------
*ondition of isibility is satisfied in region 3?1 and ?5 only so the line e!ists there but in
region1? the condition is iolated so the line does not e!ists.
7uestion 8: (5
Mar%s
-ind the normali&ation transformation B, which uses the rectangle (3, 3) E(4, ) #(5, 4)
andF(2, ) as a window and the normali&ed deice screen as iewpoint.
Anser:
igure: =$ample
Trans*ormations
-
8/12/2019 MCS 053 Final
9/28
--------------------------------------------------------------------------------------------------------------------------------------
-
8/12/2019 MCS 053 Final
10/28
--------------------------------------------------------------------------------------------------------------------------------------
7uestion >: (5
Mar%s
Show that two successie reflections about either of the coordinate a!es is e%uialent to asingle rotation about the coordinate origin.
Anser:7et (!, y) be any ob$ect point, as shown inFigure (a). wo successie reflection of P, either ofthe coordinate a!es, i.e., eflection about !?a!is followed by reflection about y?a!is or vice-versa
can be reprosecuted as:
-
8/12/2019 MCS 053 Final
11/28
--------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------- By: Mr !o"esh #handra $ingh%0&''()**+0)
-
8/12/2019 MCS 053 Final
12/28
--------------------------------------------------------------------------------------------------------------------------------------
7uestion ?: (8Mar%s e$ect the Diamond?shaped polygon whose ertices are ('3, 2), 6(2,'1) *(3, 2)and D(2, 1) about (a) >ori&ontal line # 8 1 (b) the ertical line E 8 1 (c) the line # 8 E 01.
Anser:e can represent the gien polygon by the homogeneous coordinate matri! as
-
8/12/2019 MCS 053 Final
13/28
--------------------------------------------------------------------------------------------------------------------------------------
-
8/12/2019 MCS 053 Final
14/28
--------------------------------------------------------------------------------------------------------------------------------------
7uestion @: (5Mar%s
-ind the principal anishing point, when the ob$ect is first rotated with respect to y?a!is by')*+ and !?axis by -+, and projected onto ! . * plane, "ith the centre of projection being /*, *,'4).Anser:otation about the y?a!is with angle of rotation 0 . /' 2G) is
-
8/12/2019 MCS 053 Final
15/28
--------------------------------------------------------------------------------------------------------------------------------------
-
8/12/2019 MCS 053 Final
16/28
--------------------------------------------------------------------------------------------------------------------------------------
-
8/12/2019 MCS 053 Final
17/28
--------------------------------------------------------------------------------------------------------------------------------------
"n order to arify our claim, consider the line segments 6, *D, which are parallel to the !?a!is, where 8 (2, 2, 2), 6 8 (3, 2, 2), * 8 (3, 3, 2), D 8 (2, 3, 2)
If 1, 2, &, 3 are the projections of 1,2, &, 3, respecti$ely, under the projection matrix /)4,
then
-
8/12/2019 MCS 053 Final
18/28
--------------------------------------------------------------------------------------------------------------------------------------
-
8/12/2019 MCS 053 Final
19/28
--------------------------------------------------------------------------------------------------------------------------------------
-
8/12/2019 MCS 053 Final
20/28
--------------------------------------------------------------------------------------------------------------------------------------
7uestion #0: (5
mar%s
+ien p2(3, 3) p
3(1, ) p
1(5, ) p
(, 3) as ertices of 6e&ier *ure. Determine points on
6e&ier *ure.
Anser:
e know *ubic 6e&ier cure is
-
8/12/2019 MCS 053 Final
21/28
--------------------------------------------------------------------------------------------------------------------------------------
hree points on 6e&ier cure are , P (2) 8 (3, 3) P (2.4) 8 (.4, 1.4) and P (3) 8 (, 3).
7uestion ##: (8
mar%s
Proe the following:
(a) n, i 83 b) P(u 8 3) 8pn c)P(u82)8P0Anser:
(a) o Proe: n, i 836y Simple arithmetic we know,
(b) o Proe: P(u 8 3) 8pn
if P (u)( 8 6e&ier cure of order n and 9 (u) ( 6e&ier cure of order m
-
8/12/2019 MCS 053 Final
22/28
--------------------------------------------------------------------------------------------------------------------------------------
(c) o Proe: P(u82)8P0
7uestion #": (
Mar%s
Distinguish between F?buffer method and scan?line method. hat are the isibility testmade in these methods@
Anser:
"n &?buffer algorithm eery pi!el position on the pro$ection plane is considered for determiningthe isibility of surfaces w. r. t. this pi!el. Hn the other hand in scan?line method all surfacesintersected by a scan line are e!amined for isibility. he isibility test in &?buffer methodinoles the comparison of depths of surfaces w. r. t. a pi!el on the pro$ection plane. hesurface closest to the pi!el position is considered isible. he isibility test in scan?linemethod compares depth calculations for each oerlapping surface to determine which surfaceis nearest to the iew? plane so that it is declared as isible.
7uestion #3: (#0
Mar%s
C!plain the following:(i) nti?aliasing (ii) Phong shading (iii) Specular reflection
(i) ay tracking () ay casting
Anser:(i Anti-aliasing
nti?aliasing is a method for improing the realism of an image by remoing the $aggededges from it. 5hese jagged edges, or jaggies,appear because a computer monitor has suarepixels, and these s%uare pi!els are inade%uate for displaying lines or cures that are not
parallel to the pi!els and other reason is low sampling rate of the image information, whichin turn leads tothese $aggies (%uite similar to star casing discussed in preious blocks under DD algorithm).-or better understanding, take the following image of darkened circle:
-
8/12/2019 MCS 053 Final
23/28
--------------------------------------------------------------------------------------------------------------------------------------
"t is not possible to completely eliminate aliasing because computers are digital (discrete) in
nature. >oweer, it is possible to minimi&e aliasing, the solutions used by ray tracers today
inole treating each pi!el as a finite s%uare area (which, in fact, they are), rather than as a
mere point on the screen. "nstead the pi!el should not be considered as a point or area but
should be considered as a sample of image information (higher the sampling is lesser the
aliasing is). Bow let us discuss how appropriately the sampling can be done ? ays are fired
into the scene through the centers of the pi!els, and the intensities of ad$acent rays are
compared. "f they differ by some pre?determined amount, more rays are fired into the
surfaces of the pi!els. he intensities of all the rays shot into a gien pi!el are then aeraged
to find a color that better fits what would be e!pected at that point.
Note: Do not treat a pi!el as a s%uare area, as this does not produce correct filteringbehaiour, in fact a pi!el is not a point, but it is a sample of information to be displayed.
Anti-aliasing, then, helps eliminate $agged edges and to make an imageseem more realistic. *ontinuing the aboe e!ample, the anti?aliased circlemight, then, be represented.
(ii 6hong shading"n +ouraud shading we were doing direct interpolation of intensities but a more accuratemethodfor rendering a polygon surface is to interpolate normal ectors and then apply illuminationmodel to each surface. his accurate method was gien by Phong and it leads to Phongshading on Bormal ector interpolation shading.
*alculations inoled with Phong Shading:i) Determine aerage unit normal ector at each polygon erte!.ii) 7inearly interpolate the erte! normals oer the surface of polygon.iii) pply illumination model along each scan line to calculate pro$ected pi!el intensitiesfor surface points.
-
8/12/2019 MCS 053 Final
24/28
--------------------------------------------------------------------------------------------------------------------------------------
Figure A Figure B
"nterpolation of surface normals along the polygonedge between two ertices is shown aboe
inFigure. he normal ectorN for the scan line intersection point along the edge between
ertices 3 and 1 can be obtained by ertically interpolating between edge end points normals.
hen incremental methods are used to ealuate normal between scan lines and along eachindiidual scan line. t each pi!el position along a scan line , the illumination model is
applied to determine the surface intensity at that point B8 I((y?y1) / (y3?y1)) B3J 0 I((y?y1) /
(y3?y1)) B1J
(iii Specular re*lectionSpecular reflection is when the reflection is stronger in one iewing direction, i.e., there is a
bright spot, called a specular highlight. his is readily apparent on shiny surfaces. -or an idealreflector, such as a mirror, the angle of incidence e%uals the angle of specular reflection, asshown
below.
7ight is reflected mainly in the direction of the reflected ray and is attenuated by an amountdependent upon the physical properties of the surface. Since te ligt re!lecte" !ro# te
sur!ace is #ainly in te "irection o! te re!lecte" ray te position o! te observer "eter#ines
te perceive" illu#ination o! te sur!ace. Specular reflection models the light reflectingproperties of shiny or mirror?like surfaces.
(i4 ;a/ trac%ing6aytracing is a method of follo"ing the light from the eye to the light source. 7hereasray
casting only concerns itself with finding the isible surfaces of ob$ects, ray tracing takes that a
few steps further and actually tries to determine what each isible surface looks like.lthough it will cost your processor time spent in calculations you can understand the leelof calculations in$ol$ed in ray tracing by considering this example, %etssay "e are rendering /thatis, ray
-
8/12/2019 MCS 053 Final
25/28
--------------------------------------------------------------------------------------------------------------------------------------
tracing) a scene at a resolution of 12 pi!els wide by 152 pi!els high, for a total of =;,
-
8/12/2019 MCS 053 Final
26/28
--------------------------------------------------------------------------------------------------------------------------------------
in? between frames is 4.
-
8/12/2019 MCS 053 Final
27/28
--------------------------------------------------------------------------------------------------------------------------------------
7uestion #5: (8
Mar%s
(i) Differentiate between 6itmap +raphics M Nector +raphicsAnser:
itmap graphics are images which is the collection of bits that form an image. he imageconsists of a matri! of indiidual dots (or pi!els) that hae their own colour described using
bits. %etstake a look at a typical bitmap image to demonstrate the principle:
o the left you see an image and to the right a 142 percent enlargement of the top of one ofthe mountains. s you can see, the image consists of hundreds of rows and columns of small
elements that all hae their own colour. Hne such element is called a pi!el. he human eye isnot capable of seeing each indiidual pi!el so we perceie a picture with smooth gradations.
Bector graphics are images that may be entirely described using mathematical definitions.he image below shows the principle. o the left you see the image itself and to the rightyou see the actual lines that make up the drawing.
Cach indiidual line is made up a large number of small lines that interconnect a large
number of or, $ust a few control points that are connected using 6e&ier cures. "t is this latter
method that generates the best results and that is used by most drawing programs.
-
8/12/2019 MCS 053 Final
28/28
--------------------------------------------------------------------------------------------------------------------------------------
his drawing demonstrates the two principles. o the left a circle is formed byconnecting a number of points using straight lines. o the right, you see the same circle
that is now drawn using 5 points (nodes) only.
(ii) Simulation of positie acceleration M Simulation of negatie accelerationAnser:
Simulation o* 6ositi4e Accelerations: "n order to incorporate increasing speed in ananimation the time spacing between the frames should increase, so that greater change in the
position occur, as the ob$ect moes faster. "n general, the trigonometric function used to haeincreased interal si&e the function is (3? *os ;) ,2A;A