Sie sind auf Seite 1von 28

-------------------------------------------------------------------------------------------------------------------------------------

Course Code MCS-053 Course Title Graphics and Multimedia Assignment Number (5 !053!Assign !"0#3 Ma$imum Mar%s &eightage (ast )ates *or Submission : #00 : "5' : #5th +ctober, "0#3 (-or .ul/ "0#3 Session #5th April, "0#0 (-or .anuar/ "0#0 Session

: : Computer : MCA

There are *i*teen 1uestions in this assignment2 Ans3er all the 1uestions2 "0 Mar%s are *or 4i4a-4oce2 5ou 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 #: Differentiate between following: (i) Painting and Drawing Ans3er: The di**erences bet3een 6ainting and )ra3ing 6ainting 6ainting functions, on the other hand, dont create objects. If you look at a computer screen, youll see that its made up of millions of tiny dots called pixels. Youll see the same thing in a simpler form if you look at the colour comics in the Sunday newspaperlots of dots of different colour ink that form a picture. Unlike a drawing function, a paint function changes the colour of indi idual pi!els based on the tools you choose. "n a photograph of a persons face, for example, the colours change gradually because of light, shadow and comple!ion. #ou need a paint function to create this kind of effect; theres no ob$ect that you can select or mo e the way you can with the 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 programs allows placement of such predefined shapes as rectangles, polygon and can as. (ny part of the can as can be edited at the pi!el le el. )ra3ing )ra3ing is a software application means using tools that create objects, such as s uares, circles, lines or te!t, which the program treats as discrete units. "f you draw a s%uare in PowerPoint, for e!ample, you can click anywhere on the s%uare and mo e it around or resi!e it. Its an ob$ect, $ust like typing the letter e in a "ord processor, i.e., (8 Mar%s

a drawing program allows a user to position standard shape (also called symbols, templates, or ob$ects) which can be edited by translation, rotations and scaling operations on these )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 le els of sophistication, but they tend to specialise in one or the other. (ii) *omputer +raphics and (nimation Ans3er: The di**erences bet3een 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

-------------------------------------------------------------------------------------------------------------------------------------

(iii) Printer and Plotter Ans3er: The di**erences bet3een printers and plotters: (a) Plotters print their output by mo ing 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 mo ement of pen. (b) (nother difference between plotter and printer is that the printer is aimed primarily at printing te!t. )hus, the printer is enough to generate a page of output, but this is not the case with the line art on a plotter. (i ) ,andom Scan Display De ices and ,aster Scan Display De ices Ans3er: The di**erences bet3een ;andom Scan )ispla/ )e4ices and ;aster Scan )ispla/ )e4ices: (a) "n ,andom Scan system the Display buffer stores the picture information, further the de ice is capable of producing pictures made up of lines but not of cur es. )hus, it is also kno"n as #ector display de$ice or %ine display de$ice or &alligraphic display de ice.

(b) "n ,aster Scan system the -rame buffer stores the picture information which is the bit plane (with m rows and n columns) because of this type of storage the system is capable of producing realistic images, but the limitation is that the line segments may not appear to be smooth. 7uestion ": Mar%s (5

.rite a program in */*00 to generate line segment between two points, by using DD( line generation (lgorithm. #our program should map each and e ery step of pseudo algorithm, in the form of comments. Ans3er: #include <windows.h> // Header File For The Windows Library #include <gl/glut.h> // Header File For The OpenGL32 Library #include <math.h> // Header File For The Math Library #include <stdio.h> // Header File For Standard Input/Output const float PI=3.14; void draw ine!int "#$int %#$int "1$int %1&' line end(oint and gl)egin!* +P,I-./&; store the left end(oint in !"#$ %#& gl0olor3f!1.#$1.#$1.#&; and right end(oint !"1$%1& dou1le m=!dou1le&!%12%#&/!"12"#&; // calculate the values of x and y dou1le %=!dou1le&%#; using x = x1 x0, y = y1 y0 dou1le "=!dou1le&"#; if!m<1& ' // if the value of x <= x1 assign values of while!"<="1& ' ste(s as x otherwise the values of steps as y gl3erte"4d!"$floor!%&&; (rintf!56f 6f7n5$floor!%&$"&; // in(ut the

-------------------------------------------------------------------------------------------------------------------------------------

9 9

%=%8m; // calculate the values of " and % increment "88; and assign the value "88 and %=%8m

-------------------------------------------------------------------------------------------------------------------------------------

else ' dou1le m1=1/m; while!%<=%1& ' com(ute the (i"el and gl3erte"4d!floor!"&$%&; increment and "="8m1 %88; "="8m1; 9 9 gl:nd!&;

// while !% <= %1& (lot the (i"el with %

void init!void&' // init!& method to set the color and (ro;ection gl0lear0olor!#.#$#.#$#.#$#.#&; gl<atri"<ode!* +P=,>:0.I,-&; gl oadIdentit%!&; gl,rtho!#.#$1##.#$#.#$1##$#.#$1##.#&; 9 void dis(la%!void& // method to draw the line ' gl0lear!* +0, ,=+)?@@:=+)I.&; draw ine!1#$1#$A#$A#&; // value of the line according to coordinates glut/wa()uffers!&; 9 int main!int argc$ charBB argv&' // main function glutInit!Cargc$argv&; // calling glutInit!& method glutInitDis(la%<ode!* ?.+D,?) :E * ?.+=*)&; // calling gultInitDis(la%<ode!& method glutInitFindow/iGe!1##$1##&; // /etting of the windows siGe glutInitFindowPosition!4##$1##&; // setting windows (osition glut0reateFindow!5DDH ine DrawingI5&; // creating windows header name init!&; // calling init!& method glutDis(la%@unc!dis(la%&; // calling dis(la% method to draw the line glut<ain oo(!&; return #; 9 +utput:

-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------

7uestion 3: Mar%s Draw line segment $oining (12, 32) and (14, 35) by using 6resenham 7ine +eneration algorithm. Ans3er:

(5

-------------------------------------------------------------------------------------------------------------------------------------

7uestion 0: mar%s

(5

+i en a circle radius r 8 4, determine positions along the circle octants in 3st 9uadrant from ! 8 2 to ! 8 y. Ans3er: (n initial decision parameter p 8 3 ' r 8 3 ' 4 8 ' 5 2 origin the initial point ( x , y ) 8 (2, 4) and initial increments for -or circle centred on coordinate calculating decision parameter are: 1x 8 2, 1y 8 32
2 2 2 2

Using mid point algorithm point are: k p 2 'k 3 1 5 ' : 5 ; ' 4 ; <

(x

, k9#

/ (1, k<# 4) (:, 4) (5, 5) (4, 5) (;, :) (=, 1)

"x k 95# ; < 3 2 3 1 3 5

"/

k< 32 32 < < ; 5

7uestion 5:

(5 Mar%s

>ow *yrus 6ack line clipping algorithm, clips a line segment, if the window is non?con e!@ Ans3er: *onsider the Figure below, here, the window is non?con e! in shape and P9 is a line segment passing through this window .>ere too the condition of isibility of the line is tma! A tmin and the line is isible from P 0 tma! (9 ' P) to P 0 tmin (9 ' P), if tma! tmin then re$ect the line segment. Bow, applying this rule to the Figure 13, we find that when P9 line segment passes through the non?con e! window, it cuts the edges of the window at 5 points. 3 ( PCD 1 ( P7D : ( PCD 5 ( P7 . "n this e!ample, using the algorithm we re$ect the line segment P9 but it is not

the correct result.

-------------------------------------------------------------------------------------------------------------------------------------

*ondition of isibility is satisfied in region 3?1 and :?5 only so the line e!ists there but in region 1?: the condition is iolated so the line does not e!ists.

7uestion 8: Mar%s

(5

-ind the normali&ation transformation B, which uses the rectangle .(3, 3)D E(4, :)D #(5, 4) and F(2, :) as a window and the normali&ed deice screen as iewpoint. Ans3er:

-igure: =$ample Trans*ormations

-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------

7uestion >: Mar%s

(5

Show that two successi e reflections about either of the coordinate a!es is e%ui alent to a single rotation about the coordinate origin. Ans3er: 7et (!, y) be any ob$ect point, as shown in Figure (a). )wo successi e reflection of P, either of the coordinate a!es, i.e., ,eflection about !?a!is followed by reflection about y?a!is or viceversa can be reprosecuted as:

-------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------- By: Mr !o"esh #handra $ingh %0&''()**+0),

-------------------------------------------------------------------------------------------------------------------------------------

7uestion ?: (8 Mar%s ,e$ect the Diamond?shaped polygon whose ertices are (('3, 2), 6(2, '1)D *(3, 2) and D(2, 1) about (a) >ori&ontal line # 8 1D (b) the ertical line E 8 1D (c) the line # 8 E 01. Ans3er: .e can represent the gi en polygon by the homogeneous coordinate matri! as

-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------

7uestion @: Mar%s

(5

-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). Ans3er: ,otation about the y?a!is with angle of rotation 0 . /' :2G) is

-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------

"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

-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------

7uestion #0: mar%s

(5

+i en p2(3, 3)D p3(1, :)D p1(5, :)D p:(:, 3) as ertices of 6e&ier *ur e. Determine : points on 6e&ier *ur e. Ans3er: .e know *ubic 6e&ier cur e is

-------------------------------------------------------------------------------------------------------------------------------------

)hree points on 6e&ier cur e are , P (2) 8 (3, 3)D P (2.4) 8 (:.4, 1.4) and P (3) 8 (:, 3). 7uestion ##: mar%s Pro e the following:
(a) Ans3er:
n, i 83

(8

b) P(u 8 3) 8 pn

c)P(u82)8 P0

(a) )o Pro e: n, i 83 6y Simple arithmetic we know,

(b)

)o Pro e: P(u 8 3) 8 pn

if P (u)( 8 6e&ier cur e of order n and 9 (u) ( 6e&ier cur e of order m

-------------------------------------------------------------------------------------------------------------------------------------

(c)

)o Pro e: P(u82)8 P0

7uestion #": Mar%s

(0

Distinguish between F?buffer method and scan?line method. .hat are the isibility test made in these methods@ Ans3er: "n &?buffer algorithm e ery pi!el position on the pro$ection plane is considered for determining the isibility of surfaces w. r. t. this pi!el. Hn the other hand in scan?line method all surfaces intersected by a scan line are e!amined for isibility. )he isibility test in &?buffer method in ol es the comparison of depths of surfaces w. r. t. a pi!el on the pro$ection plane. )he surface closest to the pi!el position is considered isible. )he isibility test in scan?line method compares depth calculations for each o erlapping surface to determine which surface is nearest to the iew? plane so that it is declared as isible. 7uestion #3: Mar%s (#0

C!plain the following: (i) (nti?aliasing (ii) Phong shading (iii) Specular reflection (i ) ,ay tracking ( ) ,ay casting Ans3er: (i Anti-aliasing (nti?aliasing is a method for impro ing the realism of an image by remo ing the $agged edges from it. 5hese jagged edges, or jaggies, appear because a computer monitor has s uare pixels, and these s%uare pi!els are inade%uate for displaying lines or cur es that are not parallel to the pi!els and other reason is low sampling rate of the image information, which in turn leads to these $aggies (%uite similar to star casing discussed in pre ious blocks under DD( algorithm). -or better understanding, take the following image of darkened circle:

-------------------------------------------------------------------------------------------------------------------------------------

"t is not possible to completely eliminate aliasing because computers are digital (discrete) in nature. >owe er, it is possible to minimi&e aliasing, the solutions used by ray tracers today in ol e 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 gi en pi!el are then a eraged 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 filtering beha iour, 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 image seem more realistic. *ontinuing the abo e e!ample, the anti?aliased circle might, then, be represented. (ii 6hong shading "n +ouraud shading we were doing direct interpolation of intensities but a more accurate method for rendering a polygon surface is to interpolate normal ectors and then apply illumination model to each surface. )his accurate method was gi en by Phong and it leads to Phong shading on Bormal ector interpolation shading. *alculations in ol ed with Phong Shading: i) Determine a erage unit normal ector at each polygon erte!. ii) 7inearly interpolate the erte! normals o er the surface of polygon. iii) (pply illumination model along each scan line to calculate pro$ected pi!el intensities for surface points.

-------------------------------------------------------------------------------------------------------------------------------------

Figure A

Figure B

"nterpolation of surface normals along the polygonedge between two ertices is shown abo e in Figure. )he normal ector N 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 e aluate normal between scan lines and along each indi idual 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*lection Specular 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 ideal reflector, such as a mirror, the angle of incidence e%uals the angle of specular reflection, as shown below.

7ight is reflected mainly in the direction of the reflected ray and is attenuated by an amount dependent upon the physical properties of the surface. Since t e lig t re!lecte" !ro# t e sur!ace is #ainly in t e "irection o! t e re!lecte" ray t e position o! t e observer "eter#ines t e perceive" illu#ination o! t e sur!ace. Specular reflection models the light reflecting properties of shiny or mirror?like surfaces.

(i4 ;a/ trac%ing 6ay tracing is a method of follo"ing the light from the eye to the light source. 7hereas ray 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 le el of calculations in$ol$ed in ray tracing by considering this example, %ets say "e are rendering /that is, ray

-------------------------------------------------------------------------------------------------------------------------------------

tracing) a scene at a resolution of :12 pi!els wide by 152 pi!els high, for a total of =;,<22 pi!els. 7et it be of low comple!ity, with only 12 ob$ects. )hat means, o er the course of creating this picture, the ray tracer will ha e done 12 intersection tests for each of those =;,<22 pi!els, for a total of 3,4:;,222 intersection testsK "n fact, most ray tracers spend most of their time calculating these intersections of rays "ith objects, any"here from 8- to 9- : of a ray tracers time is spent "ith such calculations. (part from such hectic calculations, there is the good news that there are ways to decrease the number of intersection tests per ray, as well as increase the speed of each intersection test. "n addition to this the bad news is that ray tracing complicates things much more than simply ray casting does. ,ay tracing allows you to create se eral kinds of effects that are ery difficult or e en impossible to do with other methods. )hese effects include three items common to e ery ray tracer: reflection, transparency, and shadows. "n the following paragraphs, we will discuss how these effects fit naturally into ,ay tracing. (4 ;a/ casting ,ay casting is a method in which the surfaces of ob$ects isible to the camera are found by throwing (or casting) rays of light from the iewer into the scene. )he idea behind ray casting is

to shoot rays from the eye, one per pi!el, and find the closest ob$ect blocking the path of that ray ' think of an image as a screen?door, with each s%uare in the screen being a pi!el. )his is then the ob$ect the eye normally sees through that pi!el. Using the material properties and the effect of the lights in the scene, this algorithm can determine the shading of this ob$ect. )he simplifying assumption is made that if a surface faces a light, the light will reach that surface and not be blocked or in shadow. )he shading of the surface is computed using traditional :D computer graphics shading models. ,ay casting is not a synonym for ray tracing, but can be thought of as an abridged, and significantly faster, ersion of the ray tracing algorithm. 6oth are image order algorithms used in computer graphics to render three dimensional scenes to two dimensional screens by following rays of light from the eye of the obser er to a light source. (lthough ray tracing is similar to ray casting, it may be better thought of as an e!tension of ray casting we will discuss this in the ne!t topic under this section. 7uestion #0: Mar%s ("

>ow many key frames does a one minute animation film se%uence with no duplications re%uire, if there are fi e in between for each pair of key frames@ Ans3er: Hne minute 8 ;2 seconds Bo. of frames re%uired per second 8 15 Bo. of in?between frames 8 4 Bo. of frames re%uired in entire film8(15L;2)/481<< )hat is we would need 1<< key frames for a one?minute animation film if the number of

-------------------------------------------------------------------------------------------------------------------------------------

in? between frames is 4.

-------------------------------------------------------------------------------------------------------------------------------------

7uestion #5: Mar%s

(8

(i) Differentiate between 6itmap +raphics M Nector +raphics Ans3er: Aitmap graphics are images which is the collection of bits that form an image. )he image consists of a matri! of indi idual dots (or pi!els) that ha e their own colour described using bits. %ets take 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 of the mountains. (s you can see, the image consists of hundreds of rows and columns of small elements that all ha e their own colour. Hne such element is called a pi!el. )he human eye is not capable of seeing each indi idual pi!el so we percei e 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 right you see the actual lines that make up the drawing.

Cach indi idual 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 cur es. "t is this latter method that generates the best results and that is used by most drawing programs.

-------------------------------------------------------------------------------------------------------------------------------------

)his drawing demonstrates the two principles. )o the left a circle is formed by connecting 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 positi e acceleration M Simulation of negati e acceleration Ans3er: Simulation o* 6ositi4e Accelerations: "n order to incorporate increasing speed in an animation the time spacing between the frames should increase, so that greater change in the position occur, as the ob$ect mo es faster. "n general, the trigonometric function used to ha e increased inter al si&e the function is (3? *os ;) ,2A;A</1 . Simulation o* Negati4e Accelerations: "n order to incorporate decreasing speed in an animation the time spacing between the frames should decrease, so that there e!ist lesser change in the position as the ob$ect mo es. "n general, the trigonometric function used to ha e increased inter al si&e the function is Sin ; ,2A;A</1. (iii) (nalog Sound M Digital Sound Ans3er: An analog recording is one where the original sound signal is modulated onto another physical signal carried on some media or the groo e of a gramophone disc or the magnetic field of a magnetic tape. ( physical %uantity in the medium (e.g., the intensity of the magnetic field) is directly related to the physical properties of the sound (e.g., the amplitude, phase and possibly direction of the sound wa e.) A digital recording, on the other hand is produced by first encoding the physical properties of the original sound as digital information which can then, be decoded for reproduction. .hile it is sub$ect to noise and imperfections in capturing the original sound, as long as the indi idual bits can be reco ered, the nature of the physical medium is of minimum conse%uence in the reco ery of the encoded information ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??

Das könnte Ihnen auch gefallen