0% found this document useful (0 votes)
39 views33 pages

CG Notes

Uploaded by

Tarun Jain
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)
39 views33 pages

CG Notes

Uploaded by

Tarun Jain
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/ 33
ee, —:-— «|—s «| =—F[——xFr _=—~—~*—=CsF=F= BDA “gosithe — Digital Differential Analyzer. (Base on technique’ —~ The vector generation algossthn dn which steps along hes ine Jo determine the pixel which ghould be Junned. on ane sometimes called DDA. . - _—» Tk “is bobed on the principle : (ass yp) ane aimulraneously incremented by tet Va ‘Question gaat. 2, yisse Hgontm ararat a ar weer oko bo OG q num. metheds qf D*E). Shor She duo end "points Cay) 2 At & cones ponding dy. Scanned with CamScanner ard thee aiSe it US Se A | &: Consider a dine Anom (0,0) fo (4,6) . Use dhe simple DAA algoiithm Me ocintovuze | She pom : : & Guy) = (Ge) 8 Garga)= (He) Cee a @ \ength = Ay 6 é ' @- Bing = AEH > 40 2 2 = 0-667 | © + Aength 6 1 : es yw = 8's a 6 ® Rizk 4 6. Sk inno) YE. Yur 0 5 & Sigen (Ay) te} > x= 0520: => x= O°5 $0667 *. 22 a 1.20 1-3 — x= \ 167 +0667 1834 %@)- Scanned with CamScanner Steps g DA Aljonithen + G&) Read the dine and points Guy) @ Anz \o-a] Ay= ly-ui] @® it (ax > dy) then length = Aa else length = Ay & Select the aster unit, ie. by Wo aye yoy: length length T ound the value te the 1 2 Gas ys) The sign function make the algorithm work in ol 4 guadsonts. Tt orelurns 1,0 vol. >The factor 0-5 makes it possi ble fo earnest inlegot mathen than duncaling them. © Now plot the points foCiz while Cig length) ; plot (Inte te Nofes Either, Ati, ot Atyine wall be 1 becaiie} 7 “ a integer) : R= K+ BX length is either (aa) ot Cy- yp) (&) X= XK + OS & sign(A%) y= y, +05 % sign(Ay) Scanned with CamScanner 2 Yee WS 2S a5 4s “SS 66: aay . : ae : iy: Gay. OD, G2) OME Oe) O09 aye > NE! ica a Scanned with CamScanner SESS AALS A, Advantages gy DDA Algsiithnn : —> Te is faster than the dinect Use af Une eqyiation. —> Since, J+ caleulate points on fhe -Mne withouk ony Hloabin point mulfiplicabion. a zd —> Simple to implement , doe nat stequine any Special skills go implementation. : : ie Disadvantage 3 DD4 Algo - > Feesracy is poor. 3 TE is ostentation dependent , due to his end point accuragy is poor: ae joong poiat addi tion is SHY needed in delormining each is time Consusning - Successive point which . —> (umalive euro due fo Limited precision in Hoabing point, areprresen tation. Scanned with CamScanner G-) Dashed Une! Dashed tine con Asian ly usiag the DDA’ ald by leaving 0 gpoce, ate evasty 6 pixels. @) Dotted Line * Dotted dine can be drown osing ppa algonithe by leoxing a Space aren evayy ®D piel. : | The Scanned with CamScanner ~ Bresenhams Line Dacousing Ali —> Tr is on acoole £ efficent woy fe nasterising (ine. — The main puinciple on which this algostithin wars is sto Find our the distance between the actual dine Jocation ond the Neayest pixel. —> The distance is Rnoun 0 decist on vantiable] ever. ee wee) wie “Guia 3a a Scanned with CamScanner QO: hz (20, 10)... Be (0,12), Tiustaate Baesenham' Assit \ Given, two end points +” & Qo,10) B (20,18) @ Find into) decision “potameter > -@) Fd’ An 2 Ay TRo= 2Ay — Art. : AW = Wy -X, = 80-20% 10, [ ©. Ay'='Y27 gi = ‘\g-10 = 8, (3) Find decision posia meta : Cose T “Oger Scanned with CamScanner Algaxithen + (6) Read she Une 8 pees C8) and Gay) | Buch thot they axe not equd. @) & CGlodote ; cals al) & & “Ags ya a @®) Tnifiolize the shanting point (Cae, ep @) Coloulok the. intHol decision paxameter Po = 244 - Ax = @) TF &<0v" else on a ie (Re 70 t Suyv= tet ho he 20 QE Aes = %& tl Ge F 5 Yet Ror = fet 204-244 ~Plot Cau ster 4 Scanned with CamScanner CoseT + panes ytl. p> = = - 7 ed? ean \ xe st ft omer a + Increase eo 244-2] hoga usme unit, increment oR” An a | foeeye ae] wer. Durse aT Nikal na Padega Scanned with CamScanner -2 V4 lo or 22 23 a4 25 26 27 28 24 30 GA.) (ou \N) Gn) (23, 12), (24: 1a) (25, 14) (a6, 15) Qu) (28, 18) (08,1) (30, 18) Scanned with CamScanner Ly En Ye tQe- | ' ' a Ye jo tenm & tsme Floohi ; point av Bhar e a SE oer gow | me ay ) cpp eeneestaas: ed Ad cas) 7 : , a oh di-d2 = 2Ay (tutt) 24, +2 a ae c ane ok bt ' ao «% : ps ——— ysodigens dele = 2hy(aer!) —Qawy + 2cda > Aa Gog) = abyee + 28g = 2, + pee ae | — . . 3 Gt konsa > Decision Pomnncies Sethe el — aay i oe (a4) BM hia el (e- 1): pixel lend > konsa 2Ay Ay — DAXYu 1 Scanned with CamScanner > oa ab A, oF ten? Yaz My 1G . vale a yc oe oa mal\ oz AY <\ At a? Scanned with CamScanner ( Mid Point Girdle Poraming [gestibe « Grde TH Symmebiic Higune Sar a | i Tet erty Ge snoeel g woy Syramebory (8 “octank) sok eS a Scanned with CamScanner atl Ye mar GT (awe) HE) next point i. om (wetls Ye) ae qa a ¢t | : Said To apply the mi wee Sect Coy) - at * Junction = can be = 6 inside point ' * eo we delne cische function : ede point method , Tre vole 4 yhis i} | Cod =o. aoaee foe SO , ourside point oe Scanned with CamScanner Coloslati ng this Function of the mid porar : &- teste Ca ue 7 4) = Cage i) : (yet) . — = & Ris. te is the decision rw jou “this ‘adgorit thin. 2 ~ - —-v Re a dant) tye et ¢ . ees = & eat yo F 2m “oe 4 noah : Cose I> PB <0 => the mid - point to inside She: duce boundaxy oe waar [gen = de | Scanned with CamScanner Peet 2 R. a ® -8 7 . = 2GREN Oe poe cH ye I) — ; (oe ae Cm ok 248) = (m2, e (eeayo a S arth ha rye th 7 3g ' | . +28 < (y) : _— +8 Yay ~ By Scanned with CamScanner Alganithm : @ Thpt vodius and civoumfenence 4. oa. Crcle centered ‘ob srarhing esd. Gey oh. is. an to(C ee Plat cenine Ger <) and obtain the First point on the Jgin (0,0) , the initial sn y Pot CHER egy if (peo) AE S Aearl pe przardyrl “Hrd ca wpe pret 3 while (<9) == AE derernine the Sym. > poinks jn. ath» Seven octants. ~~ SToP Scanned with CamScanner Er ®) - ® Ra R= = (ao rye + Par aE) (at eye + da,.~ wu 4 = | Scanned with CamScanner Scanned with CamScanner Ecce eeceeeeee cc eee ©. Using mid point civcle algonithm plot a cirde whose ovadtus js equal to NO 5 Centered - af She osiigin. i _ Go.) = (0,0): oF ie [Prot (19.9)..+ (0,-10) (-to,0)_ |: T —> Colaate. She initial deciston Posrameter s p= 6-v 5-10 =~ 85 Pen = Py + 2m 25 MT Py LPF ets] SAY Scanned with CamScanner R= DAy %& — DAayn +d Pet [ 2AY Bers ~ RA 2A AYe +d to [days ~ AY en +a z [pays oa . adyteed— 2A Yoo wf Aye * hay. “p = 2hy (ax *!) 7 DAAYwr — DAyt + 2hayu yar Fe ' nny 209 =~ 2xYyen 7 26% ets cd ke ‘ = 2dy - 2A4 (yee 7 yx) a _ . ‘ Lo Pet YT ane (460 98) | Scanned with CamScanner ai R Re => ~ve then get Eee — er then yee Yet ae Scanned with CamScanner The initial p volue 4 decision pasiommelen con be coleuloted os: 4 Anat = = 2a Cot) = dy, f 2c 7 —. ox (arad = aa dy Cat) -2Aaye F2bKE ~ 4 : =A -0 > [Ps Hed = Dbayo + 24%HG OA ye marc? Hot © 7 ay Ss yr Adw tc > gt Ye =m Scanned with CamScanner \ ‘, Ne Scanned with CamScanner Boundoory Ru } ostthm oe) — > Te ts used where We have to do an sntonachve painting ” Computer and dhe — interiot point con be easily Selected. fied boundary ina Single color, then the cll aloow Mn unl ounday color is eh encountertd gt - Black ) Q tor sre neighbowr'"g Red 4 Boundary colour. olowt and desk theix Gaaphics —>TF we have a gpect pmoceeds pixel by pixel Steps for Brudony ELL ffgeaithrn | \-Stont Joon any intention pixel uy pixels fo defermin whethot they ante a: Te not, then poiot the pixel with FL © af neignbowting pirels. a This process continues until all the pixels upto the boundary has een rested - ot wy 4 -cgnnected “ayy &- connects} er gestion t Bound any —Fi\I Cink a, tnt ys { it (getpixel Cay) \= beolor 24 gerpiel(my) | § putpixel ay, Lileolor) 5 - LL El (aa yy Hileolor, beolor) ; int Filleolor , tat beolot) = Filleolor ) Boundesty ~ / Boundexy- BW Caoyrh Filleolor, beolox) ; Boundary RU Cob yo Hucolor, beolox); | Boundary Ha, yh EMeolor, bcolor) 5 4 _Jnesbacks 1 — Oy FAR, Pehle se hi GG _intenion point (pixels) _gillcoler ia se Fu & at usse | geounsive Call terminake he jasge! EB) ty-connected 2 “B — connected methods invole heavy wecnsion urhich, Moy consume memory & Hime | | ee ee ee ee | Flood Fill A\gonitthm + — > Tr fs used to HU on otea where ty * 3 with a Gngle color. 2 boundary 1s not Specified —> we stot jeer a pixel valued Tha ore the desined jh color, the nea has mae ghon one intenior color We Con first He agsign pixels hove She Same cola. epeciFed inte vion pixel Guy) and xe assign all cusnen tly ser Jo a given intestor colot with ot pixel value so thot ali inteniot erther U-connected ot g- connected: approach » we fhen Shep —> Using ond od interior pose have been nepainkd. trough pixel positions Alooxitinm + i—— void Flood Hill Cink a, inky int oldcolor, int newcolot ) 4 if (get pixel (my) = = oldcolot ) ' put pixel G, 4, neweolos) 5 eae Mood bl Carl, 4, oldcolor, newealot) + Hood. Fill (a1, J) oldcolor, newcols) ; Nood- Ku a, yl, oldcola, newcol ot) : Rood Hd) Cats grt, oldcoler, newc¢olot) ; Rood FU Catt, yrb oldeolor newcolor) 5 Hood- HU Cath yt oldcclor, aewcoler) 5 Pood HU (HtL, Yel, old color, nawicols) Hood-Filk Ca-i, yes old color, newcolor) + Velyaon Filling F{gesitne ‘ => FiXing a polygon iso proces af colovning each 2 every pinel 4 that comes inside dhe polya Jregion ane two basic approaches used qe polygon filling [= seed FY algosithm c ‘ > Scan # ne” Algonitars peg @ Seed EN algoxithe + (seed dad att ar figure ka bich aT point) be Bourdany Fill algoaither ee\ 3 -—> Flood fidd algpaithre — There — > The inital etep te tM oa polygon ts fo test whether the point vs inside outside the polygon . —> For ‘resting juo methods ane used -S Trside out test = Non- Zeno winding number vule ‘inside Out Test + —> Thc ss a Simple draw o Line segment belween She point p to be sested and a paint outside Counr how mony tn bonsechion \ ay the dine with fhe polygon boundan, the polygon: Now , i Secu ‘ ff the number is even then point Po ovs e@chyor point @ cise ce ds an tnteniot perar — Tr is also called ==° ODD PARITY CHECK". Pp Dean Line Pelygen Falling ) Hfyeuttien s —> Tr is used for solid colot Filhing jn alge pobyarne > 46 B 12 HIE IB Xo * “Trrengecttong = 8) 1B 1a, FAS. — Sort ont = A, eyia ie => Pon GAT = “ale Garg) ; U Take Bich jitne ar pixel e use HA aT FT! ee a Ae ty Fo each Scan Aine , do @) Obtain intenseclion point % Bean dine with polygon edges. tb) Sot the Satersectt ons ge" Saft fo dyght- @) Fair form the pois 9 intersection aa the List. FY within palrs, whe poels beburan the cooidinates ~ ond y- © Intersection points we updated fr each Scan Line. &) Stop when the Scan dine neaches Yea . ON ee eDota Structure Used * os J Lis Edge Table Cer) ~ 7 Ls qerve edge Table (aeT)

You might also like