0% found this document useful (0 votes)
117 views

CG End-Sem

computer graphics

Uploaded by

aryanjadile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
117 views

CG End-Sem

computer graphics

Uploaded by

aryanjadile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 61
SUBJECT CODE : 210244 Choice Based Credit System University - 2019 / 2020 SYLLABUS S.E. (Computer / Al & DS) Semester - Ill COMPUTER GRAPHICS Atul P Godse MS. Software Systems (BITS Piloni) B.E. Industrial Electronics Formerly Lecturer in Department of Electronics Engg Vishwakarma Institute of Technology Pune Dr. Deepali A. Godse ME., Ph.D. (Computer Engg.) Head of Information Technology Department, Bharati Vidyapeeth's College of Engineering for Women, Pune ]Z Written by Popular Authors of Text Books of Technical Publications Z Covers Entire Syllabus [2 Question - Answer Format © Exact Answers and Solutions Z Chapterwise Solved SPPU Questions Dec. 20111 to June 2022 SAVITRIBAI PHULE P| ‘SOLVED SPPU QUESTION PAPERS Dec. - 2016 May - 2017 «Dec. - 2017 + May - 2018 + Dec. - 2018 May - 2019 *Dec, - 2019 «June - 2022 ‘A Guide For Engineering Students Unit II Chapter - 4 Polygons and Polygon Filling (4 - 1) to (4 - 8) 4.1 Introduction to Polygon .. 4-1 4.2 Inside Test... aie 4.3 Polygon Filling ... =o Chapter - 5 Windowing and Clipping (5 - 1) to (5 - 9) 5.1 Introduction. 5.2 Viewing Transformations .... 5.3 2D Clipping... 5.4 Cohen-Sutherland Line Clipping Algorithm... 5.5 Polygon Clipping... 5.6 Weiler Atherton Polygon Clipping Algorithm... Unit III Chapter-6 2D Transformations (6 - 1) to (6 - 19) 6.1 Introduction .. 6-1 6.2 Two - dimensional Transformations 6.3 Homogeneous Co-ordinates .. 6.4 Composite Transformation... 6.5 Reflection and Shear Transformations... 6.6 Inverse Transformation... Chapter - 7 3D Transformations and Projections (7 - 1) to (7 - 19) 7.1 3D Translation... sD od (vi) 7.2 3D Scaling 73 3D Rotation... 7.4 Rotation about Arbitrary Axis. 7.5 Concept of Parallel and Perspective Projections... 7.6 Types of Parallel Projections... 7.7 Types of Perspective Projections ... 78 3D Viewing... 7.9 View Volumes and General Projection Transformations......... Chapter-8 ColourModels ~—~«(8- 1) to(8- 8) 8.1 Properties of Light eB 1 82 CIE Chromaticity Diagram... vB 2 8.3 RGB Colour Model..... B= 4 8.4 HSV Colour Model..... 8.5 CMY Colour Model 91 9.2 9.3 94 95 Chapter -9 Illumination Models and Shading Algorithms (9 - 1) to (9 - 8) Light Sources .. Ambient Light... Diffuse Illumination and Reflection... Specular Reflection... Shading Algorithms ... (vil) Chapter-10 Hidden Surfaces (10 - 1) to (10 - 5) 10.1 Introduction .. 10-1 10.2 Back Face Detection and Removal Algorithm 10.3 Z-Buffer Algorithm. 10.4 Painter's (Depth Sort) Algorithm... 10.5 Warnock's (Area Subdivision) Algorithm. Chapter-11 — Curves and Fractals (11-1) to (1 11.1 Curve Generation... 11-1 11.2 Interpolation ...... 11.3 Spline Representation 11.4 Bezier Curves... 11.5 B-Spline Curve... 11.6 Fractals... 11.7 Fractal Lines..... Uni ——_S Ss Chapter-12 Segment (12 - 1) to (12 - 12) 12.1 Introduction .... 12.2 Segment Table.... 12.3 Functions for Segmenting the Display File... 12.4 More about Segments... 12.5 Display File Structure: (wil) 12.6 Image Transformation... 12-10 12.7. Raster Technique.. 2-11 SS Chapter - 13 Animation (13 - 1) to (13 - 6) 13.1 Introduction . 13-1 13.2. Conventional and Computer Based Animation... 13-1 13.3. Design for Animation Sequences .. 13-4 13.4 Animation Languages.. 13-4 13.5 Keyframes and Morphing... 3-5 13.6 Motion Specification... 13-5 SS Chapter - 14 Gaming (14 - 1) to (14 - 6) 14.1 Gaming Platforms... 14-1 14-5 14.2 Advances in Gaming —————_——— Solved SPPU Question Papers (S - 1) to (S - 16) (x) 2D Transformations 6.1 : Introduction | Q.1 Explain image transformation with example. OS [SPPU : May-15, Marks 3] Ans. : © Almost all graphics systems allow the programmer to define picture that include a variety of transformations. j4 © For example, the programmer is able to magnify a picture so that detail j appears more clearly, or reduce itso that more of the picture is visible. The programmer is also able to rotate the picture so that he can see it in H different angles. 6.2 : Two - dimensional Transformations Q.2 Scale the polygon with co-ordinates A (4,5), B (8,10) and C (8,2) ) by 2 units in x-direction and 3 units in y-direction. Find the transformed A, B and C points. OS [SPPU : Dec.-14, Marks 6] A’ 4 5 1jf2 0 0] [8 ist B’| = |8 10 1]/0 3 0/=|16 30 1 c 8 2 1/10 0 1) lie 6 a The transformed points are A’ = (8, 15), B’ = (16, 30) and C’ =(16, 6). Q3 Write 2D transformation matrices of translation, scaling. Give the derivation of 2D rotation matrix. 0 [SPPU : May-14, Dec.-14, Marks 4] (OR Describe w.r.t. 2D transformation : 4) Scaling if) Rotation iii) Translation SS [SPPU : Dec.-07,09,18, May-12,15, Marks 8] (6-1) Computer Graphics 6-2 computer Graphics 6-3 Ans. : Translation : © We can translate 2 two dimensional point y’), as shown in the Fig. Q.3.1 X=xt+y are @ # The translation distance pair (t, t,) is called a translation vector o, shift vector. Fig. 0.3.1 ‘It is possible to express the translation equations (1) and (2) as a single ‘matrix equation by using column vectors to represent co-ordinate positions and the translation vector : aa Vy, y This allows us to write the two dimensional translation equations in the matrix form P=P+T 6) Rotation Let us consider the rotation of the object about the origin, as shown in the Fig. Q3.2. y’ =rsin(9+8)=r ‘* The original co-ordinates of the point in polar co-ordinates are given 25, } =) y=rsing eecooss A Guide for Engineering Students 20 Transformations « Substruting equations (S) into (4), we get the tan for rotating a poi through an angle 6 about the origin as =¥sind | y’ +ycose | ~O ‘Toe above equations can be represented in the max form as given below , cos8 sin @” =the Ww vIe lee = P=P-R where R is rotation matrix and it is given as co cos® sin @) -sin® cos6) “O ‘st is important to note that positive values for the rotation angle define counterclockwise rotations about the rotation point and negative values rotate objects in the clockwise sense. ~O ‘*For negative values of 8 i.e. for clockwise rotation, the rotation matrix Scaling * This operation can be cartied out for polygons by mukiplying the co-ordinate values (x, y) of each vertex by scaling factors S, and S, 10 produce the transformed co-ordinates (x, ¥) X = x5, y' =y5, + (10) = y-Sy the x direction and sealing factor S, Non, The equation (10) can be writen in the 2D Transformations = [eS y8y] oy | Fig. 0.3.3, Q4 What is homogeneous co-ordinate syst 2 Explain need of homogeneous co-ordinates. Compare homogeneous and normalized | co-ordinates. 6&[SPPU : Dec.-05,16,18, May-07,12, Marks 8] OR What is the need of homogenous co-ordi homogenous co-ordinates for translation, rotation Ams. : + In order to combine sequence of transformations we have to eliminate the matrix addition associated with the translation terms in My To achieve this we have to represent matrix M, as 3 x 3 matrix instead of 2x 2 introducing an additional dummy co-ordinate W. Here, points are specified by three numbers instead of two. This co-ordinate system is called homogeneous co-ordinate system and it allows us to ‘express all transformation equations as matrix multiplication, ole emeneneres Co-ordinate, is represented by a triplet (Xy, Yue Wh - Xw Yw SSW ened cer eect Computer Graphles 6-5 5 ee «For two dimensional transformations, we can have the Pe ay et Noe Be mag W = I. Therefore, each two dimensional position ‘can be swith homogeneous co-ordinate as (x, y, 1). alee) « Summatizing it all up, we can say that the homogeneous Sie ombinedwanematoe ane amege oats jediate co-ordinate values and thus save required time for transformation and memory required to store the intermediate co-ordinate values. «The homogeneous co-ordinates for translation are given as, R= 8 sin@ 0} sin @ cos® ‘| --Q) o 01 ©The homogeneous co-ordinate for scaling are given as, a) s=|0 sy 0 oot @ 6.4 : Composite Transformation Q5 Explain the concept of 2D rotation about an arbitrary point IS [SPPU : Dec. ‘Ans. : To rotate an object about an arbitrary point, (x, y,) we have to Carry out three steps : 1. Translate point (x, ¥,) tothe origin rr pe gg St “6 2D Transformations Compt Gopes y 7 wey) . im Oe) < - ee) an) 8p Taal pt Sateen pom ap pene cra y en . 9) op : (6) Stop 2: Rotate it (d) Step 3: Translate back women 12th Site pecton Fig. 8.1 ‘Matrix multiplication is not commutative, ie. multiplying matrix A by matrix B-will not always yield the same result as multiplying matrix B by matrix A. Therefore, in obtaining composite transformation matrix, 1s mst be cael order the mae 0 tat they comespond to te ‘*The translation matrix to move the center point back to its original position is given as, —————— oy “ A Guide for Engineering Students ; cosO+y,sin8+x, xp sin@-y, cos8+y, | (1) Q6 Prove that two 2D Totti sat he rg commu a (0,0), B(O,1), ©(2,1), D(2,0) The translation matrix is, 00 AY 100 _ oe 7 yl Here, = 1, y= 1 100 Tejo10 rid The overall transformation matrix is 05.00 ST.=|0 10 ee 05 0 =|0 10 1 1 By applying this transformation to triangle (0, 0 (> Sen Fig. Q.7.2 Final state Q8 Fig, Q81 and Fig. Q82 show basic 2D blocks. Apply o translation and scaling transformations to get the Fig. Q.8.3. Draw 1 diagrams of all intermediate steps. 1 (GE[SPPU : May-10, Marks 18) 1), 2,0) we Bet ‘AGuide for Engineering. apes f compe rapt eu 20 Transfomatons ‘pe rotation matrix for clockwise rotation of poet about the given a6 [* sin R Computer Graphies $4 0 0 17f05 0 0 Reale 111{/0 1 of =/1s 21 S7Ohigl1 174 ae gy After applying scaling transformation to Fig. Q.8.2, Ah oe a ‘After applying translation transformation to above figure, va No transformation is applied to Fig. Q.8.1 +. By applying overall transformation we get, 2.9 Consider the square A(1, 0), B(0, 0), C(0, 1) and DG, 1). CompuerGraphis CD enero Q.10 Consider a square P(0, 0), Q(0, 10), R(10, 10), S(10, 0). Rotate the square anticlockwise about fixed point R(10, 10) by an angle 45°, e@r[SPPU : May-19, Marks 4] sin ® 0 cos 8 0 -xy0os8+y,sinO+K, xp sinO-ypcosO+yp 1 cos 8 Ans.: T= sin ® Note : Here, rotation is anticlockwise Given : 6 = 45, x, = 10 andy, = 10 1 = 0 v2 1 a= vi —<- = 0 42 2 10 -10(V/2)+10 1 1 1 10 410 [A RCT | bee ae 2 v2 -10 =10, Qype wy fal aetio Se ei0. | 10 10 1}| 2 2 A an 1 sg} lo o af] yo =20410 1 10,49 210. —=+10 +10 L 2 a Q.11 Magnify the triangle with vertices A(0,0), B(L,1), C(S,2) to twice its size as well as rotate it by 45°. Derive the translation matrices. S@ISPPU : Dec.-11,13, May-13, Marks 8] Aas. : sy 0 0 samc 5-8 ay ‘~ 0 01 cos@ sin@ 0 Rotation matrix is given byR = [ee cos 8 O75 520 ik A Gulde for Engineering Studen® 6-13 sx 0 0] [cos® sing o) f i $< c088 sr=]0 Sy O}|-sin® cose of =| 5 cg Sxsne 4 0 9 IL 0 oa} yyne syems8 0 o 22, sy = 2and 0 45° i where Sx [ 2eos45 2sin4s 0] SR = |-2sing5 2e0845 0) eo o 4 f 0 1 2cos45 2sin45 7 fo on 1 1 1} |-2sin45 2cos45 0) =| 9 2998 1) 521 0 0 1) [42426 9.866 1! ‘m scaling on a triangle (1, 1), (8 1) and (1, 9) with jor of 2 in both x and y directions. Find the final SS ISPPU : May-17, Marks 2] Q.43 For origin centered unit sq factor 2 in x-direction. Find resultant co-ordinates of square (write required matrices). S@[SPPU : Dec.-17, Marks 4) cos 45 -sin 4S 0 Ams: R= | sindS cos 45 | 0 o 1 + [2.0 0) S=|o10 001 eae ‘Qxoory “Guide for Engineering Smdens Q.44 Rotate origin Ans: about the origin. 1a td -1-1 1-1 Rg, “11 -1 -1 at | feos 8 sin® cos 0 [ 10 centered square with 2 unit length of each side, in clockwise direction with rotation angle of 90°. ES[SPPU : May-18, Marks 3] = S@[SPPU : Dec.-19, Marks 6] | A Guide for Engineering Student cnt aN b-18 i he rotation matrix is, Reflection Transformation Original image” Reflected image matrix 4 By fe + ‘A Guide for Engineering Student y Shear athe y shear preserves the x co-ordinates, but Fe ass changes the y values which causes horizontal lines "t to transform into lope up or down, as shown in the Fig. | «The transformation y shear is given as 1 Shy 0 T * ysh=|o 1 0 ae 0 01 ’ x = x and y= y+Shy-x a) oe ' — er 4 7" es 60 Computer Graphics ob 2D Transformations computer Sean! 2» a) = «The inverse transformation uses the matrix inverse of the transformation, a a0 A ecaeg ratrix to get the original point (x, y). The inverse of @ matrix is another pe 0| “aigl]-> a 0 matrix such that when the two are multiplied together, we get the By eee identity matrix If the inverse of matrix T is T“, then Trt =TT=1 O where I is the identity matrix with all elements along the major iagonal having value 1 and all other tlements having value zero, ‘©The elements for the inverse matrix T ~' can be calculated from the elements of T as tet = OT deem a det oe whee ty? isthe element inthe i* row and j* column of T~? and My is the (a ~ 1) by (n~1) submatrix obtained by deleting the j" row and ‘* column of the matrix A. The det M,, and det T is the determinant of the M, and T matrices. ‘A Gulde for Engineering Student® stant to note that the elements of inverse matrix T~! eae from the element of T as can be cy, CDM! det Mj Fe det 6 In the above equation the term det T is in the denominator. Hence, we can obtain an inverse matrix if and only if the determinant of the tmatrix is nonzero. t if END... S=S— ein 3D Transformations and Projections 7.1: 3D Translation Q1 Obtain the 3D transformation matrices for translation, "a [SPPU : Dec.-05,07,08, May-05, , Marks 2] ‘Ams. Three dimensional transformation matrix for translation with homogeneous coordinates is as given below. It specifies three coordinates with their own translation factor. i+, yty zty oo) Q2 Obtain 3D transformation matrix for scaling, pease May-06,07, 08, 16, Dec.-06, 07, 08, 16,18, Marks 2] Livy dewey ed = [eS yy 7.3 : 3D Rotation Q3 Obtain the 3D transformation matrix for rotation about z-axis. SE[SPPU : May-11,19, Marks 3] ~() OR Explain the rotation about all co-ordinate axis. 1S SPPU : May-06, 07, Dec.-16,18, Marks 8] ‘OR Give homogenous transformation matrix for 3D rotation with respect to y axis. 5a [ SPPU : May-16, Marks 2] Ans, Three dimensional transformation matrix for each co-ordinate ‘es rotations with homogeneous co-ordinate are as given below. FH NK, ° Fig. 0.3.4 Rotation about x axis eee ecoory “1 Guide or Engincerng Soden rapes TemAt en Pty Sree rt sonnet ete bjt 10 tt rotons yg ‘© The positive value of angle @ indicates counterclockwise rotation. For 1+ passes through the coordinate origin. (See Fig. Qa iy ont clockwise rotation value of angle 6 is negative. o) i de pa 4 oo eee Fig. 44 Sa [SPPU : May-11, 12, Marks 10 Dec.-11, Marks 12] OR Explain the concept of 3D rotation about any arbitrary axis. 5 [SPPU : May-06,06,12,14, Dec.-06,07,08,14, Marks 8 June-22, Marks ‘Aus. : + When an object is to be rotated about an axis that {s not u : ‘orientation. to one of the coordinate axes, we have to perform some additional . bring the rotation axis back to its original sis back 10 iS transformations. The sequence of these transformations is given below... Apply the inverse translation to move the rotation Computer Graphies 25 4D Transformations and Projections Derivation of transformation matrix ‘The translation matrix is given as re 8.o8 F oR oe Be asi oe et! €0 ™ -y1 -%1 1. 7 in ong ra el ay stating wales of 68 & and snc te ms Linearly interpolate the vertex normals over the surface of thy polygon. ; 3. Apply an illumination model along each sean line to determing projected pixel intensities for the surface points. #-The first steps in the Phong shading is same as first step in the Gourayg shading. in the second step the vertex normals are linearly interpolated over the surface of the polygon. This is illustrated in Fi shown in the Fig Q.11.1, the normal veetor N for the scan line intersection point along the edge between vertices 1 and 2 can be obtained by vertically interpolating between edge endpoint normals : Y-¥2 yy Fig. 0.11.1 Calculation of Interpolation of surface normals along # polygon edge tik, Gouraud shading, here also we can use incremental methods 1 ‘aluate normals between scan lines and along each individual scan liné SO Sos A Guide for Engineering Side the difference between Goursud shading md FHISPPU : Dec..19, vane oh Phong’s shadiag In this shading model, he surfice normal vor Ny interpolated, instead of imensiy 1k greatly reduces the mach - band effect, 1 requires more calculations, increasing the cost of | inesig shading. 13 Explain halftone shading. e@[SPPU : May-17, Marks 4] 7 hat pixel ffone patterns to create number of intensity levels | unie iv) May-07,08,12, June-22, Marks 2) are needed to determine which lines op sauces of the objects are visible, so that we can display only te vibe lines or surfaces. ‘02 Explain, how hidden lines and surfaces are removed ? a> [SPPU : May-11, Marks 6) Aus. : There are two approaches to remove hidden lines and surfaces are called object-space methods and image-space methods, respectively END... | °beet'Space Method + Obj 's and parts of objects to each other within the scene termine which surfaces, as a whole, we should label as ‘space methods are generally used in linedisplay Image-Space Method “Image space method is implemented in the screen co-ordinate system In which the objects are viewed. algorithm, visit mn the view plane. Most hidden line/surface algorithms use imagespace mets [Es Sos "A Galan for Engineering Sede is decided point by pint at ech Computer Grapes 2 Maden Surface Computer Graphs 10 Sere 10.2 : Back Face Detection and Removal Algorithm 3 Explain backface removal algorithm. ew [SPPU : May-05,06,08,12,13,18, Dec.-07,11,12,13,16,19, Marks 8) ‘Ans. : « If a polygon is visible, the light surface should face towards yy ‘and the dark surface should face away from us. ar The direction of the light face can be identified by examining the result NV >0 where YN: Normal vector to the polygon surface with Cartesian components (A, B, C)- swing direction from the eye jon (Refer Fig. Q3.1) # We know that, the dot product of two vectors, gives the product of the lengths of the two vectors times the cosine of the angle between them. This cosine factor is important to us because if the vectors are in the same direction (0 $ @ < 7/2, then the cosine is dot product is positive. However, if the directions are opposite (n/2< 6 <7) then the cosine and the overall dot product is negative. Fig. Q.3.2 Cosine angles between two vectors ‘If the dot product is positive, we can say that the polygon faces towards ‘the viewer; otherwise it faces away and should be removed. ee Sens ‘A Guide for Engineering Studer es te if object description has been converte and our viewing direction is parallel rej, Poston 0, V,) and Mewing 2 axis, penny Ne VC ave oly ave f0 casi te Sen 0 he compen ft vets the viewer, if negative, it faces away. Polygon so gor faces 10 10.3 : Z-Buffer Algorithm 4 Explain Z-butfer algorithm. 5 [SPPU : May-10,11,14,16,17,18,19 Dec.-11,12,13,16,18, Marks 8; June-22, Marks 6) ans. : Z-buffer Algorithm " 4 1, Initialize the Z-buffer and frame buffer so tha positions ca Z-buffer (x, y) = 0 and frame-buffer (x, y) = 2, During scan conversion process, for each position on each polygon surface, compare depth values to previously stored values in the depth buffer to determine visibility. Calculate z-value for each (x, y) position on the polygon If z > Z-buffer (x, y), then set Z-buffer (x, y) = 2, frame-buffer (%, y) = Tee ( Y) ung iS the value for the background intensity and lyse intensity value for the surface at pixel position (x, 9). After processing of all surfaces, the Z-buffer contains depth values for the visible surfaces and the frame buffer contains the conesponding intensity values for those surfaces. *To calculate z-values, the plane equation Ax + By + Cz+ D = 0 4 bs where (x, y, z) is any point on the plane and the coefficient A. thesia ate constants describing the spatial popes of the plane, . Appendix A for details) Therefore, we can write ~Ax-By-D z= — ‘SoD; cee for Engineering Seiden’ vr Computer Grape Hidden Sur —ee ir «Note, if at (x, y) the above equation evaluates to 2), then at (x + 4g, the value of z, is 4-4 © Only one subtract since the quotient constant and Ax = 1. A calculation can be performed to determine the first value of 2 on the next sean line, decrementing by B/C for each Ay. Q5 Explain Painter’s algorithm. 1a [SPPU : Dec.-07,08,11,14,15,16,18,19, in order of decreasing depth. 2. Determine all polygons Q (preceding P) in the polygon list whose z-extents overlap that of P. 3. Perform test 2 through 6 for each Q a) If every Q passes the tests, scan convert the polygon P. b) If test fails for:some Q, swap P and Q in the list and make the indication that Q is swapped. If Q has already been swapped, use the plane containing polygon P to divide polygon Q into two polygons, Q, and Q,. Replace Q with Q, and Q,. Repeat step 3, 10.5 : Warnock’s (Area Subdivision) Algorithm Q6 Explain Warnock's algorithm. Sa [SPPU : Dec.-05,07,10,14,16,19, May-06,07,17,18,19, Marks ‘Ans. : Algorithm lay: 17,18,19, Marks 8] 1. Initialize the area to be the whole screen. 2. Create the list of polygons by sorting them with their z-values of vertices. Don't include disjoint polygons in the list becaus® they are not visible. 3. Find the relationship of each polygon. ee eecoos ‘A Guide for Engineering Student cont the visibility decision test 1, Perform 2) If all the polygons are disjoint from ‘area with background colour. 'p) If there is only one intersecting or polygon then first fill entire area with ec coi and then fill the part of the polygon containeg ‘olour area with the colour of polygon. im the c) If there is a single surrounding polygon, jut imesectng or contained polygons, the Si ean yon the colour of the surrounding polygon, the area, then i 4) If surrounding polygon is closer to the viewpoint thn all other polygons, so that all other polygons ae hidden by it, fill the area with the colour of the snowman polygon. ©) If the aren is the pixel (x, y) and neither a,b, , nor d applies, compute the z co-ordinate at pixel (x, y) of all polygons in the list. The pixel is then set to colour of the polygon which is closer to the viewpoint. 5, If none of the above tests are true then subdivide the area and go to step 2. Q7 What are the advantages of Warnock's algorithm. Sar [SPPU : May-18,18, Marks 3] Ans. : Advantages lows the divide-and-conquer strategy, therefore, pari ‘computers can be used to speed up the process. 2. Extra memory buffer is not required. Q8 Why Warnock's algorithm is also called as area subdivision ‘gorithm 2 1a [SPPU : Dec.-10, Marks 4] Aus. : Wamock's algorithm sub divides each area into four equal squares and at eact in the recursive-subdivision process, the a each polygon and the area of interest is checked hips. Because of this Warnock’ algorithm is algorithm. END. = ro 14 Guide, Curves and Fractals 11.1 : Curve Generation 0.1 What is true curve generation ? Write a Pseudo code t implement DDA arc generation. 5 [SPPU : May-06, Dec.-07,10,11, Marks 19] ‘OR Write short note on True curve generation. ua [SPPU : Dec.-10, Marks 2} Ans. : In a true curve generation algorithm, rather than approximating a curve by small line segments, we use digital differential analyzer algorithm to determine points those lie on the curve. Algorithm / Pseudo Code Algorithm 1, Read the centre of a curvature, say (xy, Yo ): 2. Read the arc angle, say 6. 3. Read the starting point of the are, say (x, y)- 4, Calculate 48, 48 = Min (0.01, 1 / (3.2x((x-xJ + y-yoD)) 5. Initialize Angle = 0. 6. While (Angle < 6) 60 {Plot (x, y) x=x-(y-yq) x40 y=yt+@-x)x 40 “Angle = Angle + 46 } 7. Stop. ai-t ued Cores dF jn True-Curve oreeien Approach ‘a curve, we need more inf formation than jut is eg to apply transformations, For in only a direction becomes meee nly circular are gener our limited. tion then ability ithm is required to clip arcs, generation algorithms for curves other than cin such as airplane wings or cars or human ica 11.2 : Interpolation az Write a short note on blending functions. EE[SPPU : Dec.-13, Marks 4] dos: suppose we want @ polynomial curve that will pass through o sample eis (Yip Bs Oa Yon 2s 5 Oy Yor 2) We will construct the function as the sum of terms, one term for each sample point. These functions can be given as £0) = D x Bw) im 50 = YB ie fy = 3 2,30) a called ‘blending function’. For as ding fumction determines how much in affects the position of the curve eee words we can say ta each smal pois st © MS its direction and the function By) gives Sor Computer Graphics u-3 Curves and Et *f for some value of u, B(u) = 1 for unigue value of i (i for other values of i) then i sample point has complete contr curve and the curve will pass through i® sample point. the * For different value of u, some other sample S through that pony control of the curve. In such case the curve wil as well ‘In general, the blending functions give control of the curve to each the sample points intumn for different values of u. 3 What is interpolation ? Explain Lagrange interpolation method, SS[SPPU : May-07,08,09,16, larks 8, June-22, Marks 6] Ams. : In a curve generation, f determining the’ intermediate points between the known sample points is acheived using interpolation, The blending functions give control of the curve to each of the sample points inturn for different values of u. Dec.-05,10,11,12,13,16, Let us assume that the first sample point (x,,y;,2) has complet control when u = — 1, the second when u = 0, the third when u = 1, and so on. ie. © When u=~ 1 = By(u) = 1 and 0 for u= 0, 1, «When u=0 => Bu) = 1 and 0 foru=-1,1, ... © When u = (n — 2) = B,(u) = 1 and 0 foru=-1,0,.., atu=— 1 and 0 foru=0, 1, 2, ... 1) can be given as (u-2)... fu-(n-2)] Ci =a) n= 2, the expression where denominator term is a constant used. In general form i® blending function which is 1 at u = i - 2 and 0 for other ~G-2)] ‘A Guide for Engineering Suiden® Graphics Care en rac yf the curve usin, soprosimation| OF Move exprenion is cxteg a range interpolation. 11.3 : Spline Representation apna the term control points and order of conoay i a sd SB [SPPU : May-11, 12, Marks 4g ecify a spline curve by giving a set of co-ordinate posons ‘ control points, which indicates the general shape of the curve al i lynomial sections are fitted so that the curve passes through al Men Points, as shown in the Fig. Q44., the resulting cuve is sd 0 jpterpolate the set of control points. “ ~L Interpolation spline Fig. 4.4 To ensure a smooth transition from one section of a piecewise yrametric curve to the next, we can impose various cootimsty Conditions at the connection points. We see parametric continuity sod geometric continuity conditions ‘ln geometric continuity we require parametric derivatives of wo sections to be proportional to each other at their common boundary instead of equal to each other. « ‘Parametric continuity is set by matching the parametric derivatives adjoining two curve sections at their common boundary. he ‘In zero order parametric continuity, given as Cit means simpy uve meet and same is for zero order geometric Conus ‘In first order parametric continuity called 8s —_ Parametric derivatives of the coordinate functions arom Curve sections are equal at the joining point and seme OO, ‘ontinuity means the parametric first derivative ar proporten 'metsection of two successive sections. Se _ Computer Graphics ues Curves and py ‘* Second order parametric continuity or C2 yo entity means that both the fist and (a) Zero ordorcominuy, the two Za (b) First order continuity a (6) Second order continuity Fig. 0.4.2 and for second order geo ‘or C* continuity means that both the first and second parametric derivatives of the ‘two curve sections are proportional at their boundary. Under C? continuity curvature of the two curve sections match at the joining positions. QS What is convex hull ? Ans. : ‘+The convex polygon boundary that encloses a set of control points is called the convex hull. One way to envisi is to imagine a rubber band stretched aro points so that each control point is either on the ure for the deviation of a curve or surface from the region bounding the control points. Some-splines are bounded by the convex null, thus ensuring that the polynomials smoothly follow the control points without erratic oscillations. Also, the polygon region inside the convex hull is useful in some algorithms as a clipping region. Q.6 Why is cubic form chosen for representing curve ? E[SPPU : Dec.-10, Marks 6] continuity Ans. : ‘*Polylines and polygons are first-degree, piecewise linear approximation to curves and surfaces, respectively. But this lower degree polynomials give too litle flexibility in controlling the shape of the curve. * The higher-degree polynomials give reasonable design flexibility, but introduce unwanted wiggles and also require more computation. For this reason the third-degree polynomials are most often used for representation of curves. These polynomials are commonly known a cubic polynomials, SS ‘A Guide for Enahecartee Cnsdguttt u-6 ee ees : [24 Beer curve jer curve. C&[SPPU ; or Explain me Bea used ,, three control points generate 2 parabola, four points For example eae cubic curve and so on. This is illustrated in Fig Q7.1 gen ‘The Bezier curves can be specified with boundary condoms, wis » characterizing ‘or with blending functions. Out ofthese, bending function specification is the most convenient way for general Benet curves, ) “Consider thatthe curve has n + 1 control points: Pk = (Ark 74 Where k varies from 0 ton. The co-ordinates of these comet ee ze roduce position vector P(u), which gives ad py TE jezier polynomial function between Po an be given by, Peo) = S$ py BEZ, alu OS US! Ko o . the Bens The Bezier blending functions BEZ.n() Polynomials. They are specified as, mo —— eee Computer Graphics ue? Curves and Frac, BEZ, (u) = Ck) uka-uye-* where the C (nk) are the binomial coefficients. Binomial coe are given by, Ck = icieny nt a-W! + Equivalently, we can define Bezier blending functions with the recusyy calculation as, BEZy, n(v) = (1-u) BEZ,, p-1(u) + UBEZy- niu, n>kea . with BEZ,, = u* and BEZ), = (Iu), The position vec equation represents a set of three parametric equations for the individual curve co-ordinates x(u) =D x. BEZy, a(t) Ko yo = yeBEZ, n(u) io au) = > 2.BEZ, ,(u) we (4) Keo ‘© The successive binomial coefficients can be calculated as Cin) = Eh Cm k-1) Q8 What are the properties of Bezier curve ? SH [SPPU : May-05,06,14,17,19, Dec.-08,14,15] 2. Bezier curve always passes through the first and last contro! points i. curve has same end points as the guiding polygon. 3. The degree of the polynomial defining the curve segment is ont Jess than the number of defining polygon point. Thereiore, for 4 control points, the degree of the polynomial is three, i.e. cubic sotyaam 4. The curve generally follows the shape of the defining polygon. eect Curves and Fractals Giration of the tangent Vecor a the end points .ctor determined by first and 's the same last ‘Segments, tively within the convex hull formed by fog s ant of the ve ‘te curve Ties em control points f eto ex ull property for a Bezier curve ensures Te oma smoothly follows the control points aa Pt surve Tre he curve does not oscillate about any straight line more ‘often than the defining polygon. ‘The curve is invariant under an affine transformation. exhibits the variation diminishing propery. This 11.5 : B-Spline Curve 9 Write short note on B-splines. e{SPPU : May-10,11,13,15,17,18,19, Dec.-12,13,17, Marks 8] og Explain B-splines for curve generation. tap [SPPU : May-16, Dec.-16, Marks 4] ans. There is another basis function, called the B-spline basis, which ‘contains the Bernstein basis as a special case. ‘The B-spline basis is nonglobal. It is nonglobal because each vertex By is associated with a unique basis function. Thus, each vertex affects the shape of the curve only over a range of parameter values where its associated basis function is nonzero. ‘The Bespline basis also allows the order of the basis funtion and hence the degree of the resulting curve is independent on the number of vertices, ‘IL is possible to change the degree of the resulting curve without shanging the number of vertices (control points) of the define Polygon, IEP) be the position vectors along the curve as # function of Parameter u, a B. curve is given by nat Plu) =) BN) .(U) Umin SY < Umax’ om 2sksne} U9 Curves Computer Graphics A hay —— where the B, are the position vectors of the n + I defini ts Nj. are the normalized B-spline basis function the it normalized B-spline basis function of order k, the 4.” function Nj, ,(u) are defined as i, (1 if x Su oF defining polygon (with certain limitations), 7 1 po! al control over the curve surfice because the shape of a curve only over a range oy hhere its associated basis function is nonzero, rrison between Bezier and B-spline carves, ESTSPPU : Dec.-9, Marks 6] Bezier curve ‘The degree of the polynomial defining the curve segment is| fone less that the number of defining polygon point (Control points). Therefore, for 4 control points, the degree of the polynomial is 3, ie, cubic polynomial Bezier curve can't be forced to| interpolate any of its n control of defining polygon Besplines can be forced 1) interpolate any of its points without repeating it. | control prints without repeating it 3 | Bezier -curve requires less| Bspline curve requires} computation. more computation : ‘i : offers mote less flexible. | B-Spline cune Bezier curves are ere requ 5 : ine curves se B-Spline Bezier rel ae less s : degree of the cuve aad Lo pee — _ ee SS Tete 13 Define Fractals. OR Write short note on Fractals. E@ISPPU : Dec.-12,13,15,16,18, May-13,14,17,19, Marks 6) ‘Ans. : Rough, jagged and random surfaces are called fractals Classification of Fractals ‘©The fractals can be classified as «Self similar + Self affine and = Invariant ‘olf similar fractals ‘© These fractals fave parts those are scaled-down versions of the entire object. ‘¢In these fractals object subparts are constructed by applying a scaling parameter s to the overall initial shape. It is a choice of user to use the same scaling factors for all subparts, or use different scaling factors for Gifferent scaled-down parts of the object. ‘Another sub class of self similar fractals is a statistically self-similar fractals, in which user can also apply raridom variations to the scaled-down subparts. These fractals are commonly used to model trees, shrubs, and other plants, Self-affine fractals ‘These fractals have parts those are formed with different scaling Parameters, 5,8, $, in different co-ordinate directions. ln these fractals, we can also apply ran i eee also apply random variations to obtit ‘These fractals are commonly used to model water, clouds and terrain. a Tater Bahan A Guide for Engineering Studer He Cores an Frcs Is Coes nonlinear transformation is used, Is such as the Mandel squaring fracta rt se, Se cies oe a with ich inversion procedures, you mean by topological and fractal dimension > att Me PPL : May-05, 06, 08, 09, Dec.-05, 07, 10, Marks 4 oem smposed of elastic or clay. Ifthe object can aps # COM! line segment we assign its dimension D, = | te deforms lane or half plane or disk we assign its oD jeforms into all space or half space or sphere dine Fractal Di sion 7 : ree the second measure of an object dimension. Imagine that a ine 1 ot of length L is divided imo N identical pices. The length of Shine segment / can be given as L l= N ‘The ratio of length of original line segment and the length of each part cf the line segment is referred to as scaling factor and is given 1s L eo 7 ‘From above two equations we can write Nes ie Nes! *n other words we can say that if we scale a line segment by 8 Gee 4s then we have to add N pieces together to get the orginal ies Sament. If we scale square object by a factor 1/s we will get ® ‘square. In case of s = 2, we require 4 pieces of square to get ‘quire. In general we can write Neg | \ yr Grapes se in Hilbert’s curve and give its fractal dimension car [SPI . Computer Graphics ues (Square Fig. 0.14.1 Scaling of objects in various dimensions Fig. 0.15.1 The first approximation to Hilbert's curve approximation to the Hilbert’ curve can be drawn by iding each of the quadrants and connecting their centres + Similarly for cubical object we have, (Refer Fig. Q.14.1) ‘ere moving to next major quadrant (see Fig, Q15.2) Nes ‘ ‘We have seen that we can specify the dimension of the object by variable D. Here the exponent of s is a measure of object dimensis. Thus we can write Nee extend the approximations to the Hilber’s cure, 1¢ smaller quadrants but never crosses itself every point in the square © This D is called fractal dimension. = ——_—_—— — | & nae eos “A Gul for Engineering ose? “a Ge for Engine Solving for D we get D = log Nilog s Computer Graphics 1s Cur ves 24 Prey bes t Fig. @.15.2 Second approximation to Hilbert's curve t Fig. @.15.3 Third approximation to Hilbert’s curve 3. The curve passes through a point on a grid, which becomes twit as fine with each subdivision. 4. There is no limit to su infinite. excooss ions and therefore length of curve ¥ “A Gulde for Engineering Sule U-16 Curves and Fractals n length of curve increases by factor of 4 seale changes by 2 but length « curve topological dimension meet ion of Hilbert curve. 5a [SPPU : May-18, Marks 2) ause of this locality property, the Hilbert curve is widely wed science. For example, the range of IP addresses used by ‘can be mapped into a picture using the Hilbert curve. Code to computers Cvjmage would map from 2D to ID to find the color of each seer ‘bert curve is sometimes used because it keeps nearby IP each other in the picture. 17 Explain koch curve in detail giving the fractal dimension, [&[SPPU : Dec.-07,15,17,18, May-08,09,17,19, June-22, Marks 6] ans: ¢ The Koch curve can be drawn by ‘dividing line ‘into 4 equal Rauents with scaling factor 1/3 and middle two segments are so adjusted fur they form adjacent sides of an equilateral triangle as shown in the Fig.Q17.1. This is the first approximation to the koch curve _/\_ Fig. Q.17.1 First approximation of the Koch curve ‘To apply the second approximation to the Koch curve we have to repeat the above process for each of the four segments. The resultant curve is shown in Fig. Q.17.2. TD Fig. Q.17.2 The second approximation to Koch curve SS 1 Guide for Engineering Soden Computer Graphies wey oo eS Cureton 5 a + The resultant curve has more wiggles and its length is 16/9 q. original length. ‘imesh ‘From the above figures we can easily koch curve Ly note following points abou the 1. Each repetition increases the length of the curve by factor J 2. Length of curve is infinite It doesn't deviate much from its original shape. . If we reduce the scale of the curve by 3, we find looks just like the original one; but we must as curves to make the original, so we have 4-0 Solving for D we get D = log, 4 = log 4 / log 3 = 1.2618 ‘Therefore for Koch curve topological dimension is 1 but fracal dimension is 1.2618. the curve semble 4 ae «From the above discussion we can say. tha surfaces which give a fractal dimension gre dimension are called fractals. The Hi greater than their topological dimension which is 1. 11.7 : Fractal Lines Q.48 Write short note on fractal lines. 53 [SPPU : May-10, 11, 12, Dec.-12,13, Marks 4] OR Explain fractal lines with example. (@[SPPU : Dec.-15, May-16, Marks 3] Ans. : ‘* Fractal line can be generated by performing following steps : —_——_—— oro “A Guide for Enginceri joi Curves and Fractay ——e——aoe Bratt x2 Yit¥2 Zitz 2 2 (ey 2) (a. Ya. Z9) Ca nae Mid point Fig. 0.18.1 4g an offset to the midpoint such that the resultant midpoint se on the Ii This can be achieved by adding ‘ordinate as follows : each Yity2 2 ae Offset Wey Yn Za (Xp. Ye. 22) Fig. 0.18.2 In order to get random effect calculate the offset as shown below. dx = Lx Wx GAUSS dy = Lx Wx GAUSS dz = Lx Wx GAUSS ke +dx, +dy, 1522 442) + Length of the segment W : Waiting function governing the curve roughness (Ge. fractal dimension) GAUSS : Gaussian variable which returns random values between -1 and 1 with 0 mean, i.e. retumed values consist of equal amount of positive : and negative values. Tis shifted midpoint divides the original line into two parts : Repeat the same process for each part separately. Repeat the process 1, 2, 3 until the segments become small Sinith. By following the above procedure we can get fractal line * shown in the Fig, Q.18:3. = A Guide for Engineering Students we Computer Grapes Curves Sn, ‘The above implementation can easily be achieved using q procedure Ey Fig. 18.3 —_ “A Guide for Engineering Swe at What is segment : {SPU : May-05.0 ivny do we need segments ? USISPPU : Doc.11,13, Marks 2] practice, the image on the display screen is often composed sms of information. sit may also contain close up view of a particular component. For Tanpl, we may wish to difplay an intemal plan of a living room. The plan may contain various objects such as sofe-st, T.V., showease, teapot, show-pieces, wall hangings and so on. ‘Eich object has a set of attributes such as size, colour and its postion inthe room. ‘We might wish to see all these objects simultaneously or a single object ata time. ‘To view the entire image or a part of the image with various atibutes ‘we need to organize the image information in a particular manne. information is stored in the display file. ture of the display file does not satisfy our requirements of image. Hence the display structure is modified to reflect the structure, To achieve this display file is divided into corresponds to a component or an object of the overall associated with a set of attributes. ——— (2-2) Computer Graphics aed egment is also associated “sca doa rotation and shearing ‘Therefore, presence of segment allows : + Subdivision of the picture. Visualization of a particular part of the picture : + Scaling, rotation and wanslation of «particular part of the peng Q2 Explain a segment table with example. ESTSPPU : May 05,0607, 08,12,19.18, D86-06,16.15,10, Mary ‘OR Give the structure of segment t Ams. : To access a particular segment and the information associgeg ‘with it we must have a unique name assigned to each segment, ‘Along with the mame we must have its display file position and jg attribute information. * The structure used to organize all this information related to segment — called segment table Seopa Segre Segment Setex Seley Coury * Fach row in the segment table represents information of one segmett paramere MM: Position, size, attributes and the image information <= A Gulde for Engineering Suet, Sey Hy checks the ents and it interprets only those, "2 28 vise ‘OMENS which ae fhe algorithm for change of yisiy lity attribute “ FSISPPU : Dee.-11,13, Mart 3 ‘aguments SEGMENT-NAME ON-OFF oiobal VISIBILITY constant NUMBER-OF-SEGMENTS BEGIN IF SEGMENT-NAME <1 OR SEGMENT.NaAME> NUMER.OF-Sequewrs Visibility seting array of visibility fags the size of segment table THEN . RETURN ERROR 'INVNUD SEGMENT: ‘NAME; VISIBILITY [SEGMENT-NAME] < ON-OFF. IF NOT ON-OFF THEN NEW-FRAME; RETURN; END; Q4 Write algorithm to create a segment. (@ [ SPPU : Dec.-19, Marks 6) + Create Segment ‘any segment is open; if so display enor message en" and go to step 9. ‘ead the name of new ‘segment. 3. Check whether the new segment name is valid; if not display enor "Not a valid segment name"and go to step 9. “1 Guide for Eginecring Sten Computer Graphics et Sexy display file thy 6. Initialize size of this segment equal to zero 7. Initialize all attributes of segment to their default values, 8. Indicate that the new segment is now open. 9 Stop. QS Write the algorithm for the following : 1) Delete a segment —_ii) Delete all segments. EISPPU : Doct1,13.17, Marka 9 ‘Ans. : Algorithm : Delete A Segment 1, Read the name of segment which is to be de 2. Check whether that segment name is v ‘message "Segment not valid” and go to step 3. Check whether the segment is open, if yes, display eror mess “Can't delete the open segment" and go to step 8. 4. Check whether the size of segment is greater than 0; if no, po processing is required, as segment contains no instructions. Therefore, {20 t0 step 8. 5. Shift the display file elements which follow the segment which is t be deleted by its size. 6. Recover the deleted space by resetting the index of the next fice instruction. 7. Adjust the starting positions of the shifted segments by subtracting the ‘size of the deleted segment from it. 8. Stop. Algorithm : Delete All Segments ‘or I = 0 To NUMBER-OF SEGMENTS DO BEom SEOMENT-STARTII| «1; ‘SEGMENT-SIZE{I] «0; END; NOW.OPEN « 0; FREE «1; Se a 1 Guide for Engineering Ste Res es ee gon OME: gx rite an algorithm to rename a segment, ESTSPPU : Dec.-17, ‘algorithm : Rename Segment her as May-19, Marea 6 (OR How do we get crest segment. ESSpPU : Dec-t3, Mara 2] ‘As: Basic operations performed on segments are : + Create segment + Close segment + Delete segment + Rename segment Segment Creation ‘ln a segment creation process, initially, we have to check whether some sther segment is still open. Its not al time because itis hen difficult aes sone ees ea segment. Hence, ‘Sement must be created or opened when no other semen