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

3 - Computer Graphics

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)
33 views

3 - Computer Graphics

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/ 59
“Tansfor mations in’ 2D | { | J ] i Toanslahion ea 4 Rot i Reflection § me d + Change in 2 ‘ Movement me GaT | Ye agge sitio in Bize. hen a biounga Position Ae € Fae path ~e Transformation: Transformation meant changes in oxientalion » size & shape ~~ the object - They ane ured fo position She object to Change the shape q object an Sot to change how Something ee viewed. The foanic geomebxical dhonsfosmosiod = aie 6) Taraslation X other denived Snongforrnations aye @ Retain { “© ReHlechion @s ealing “23 @ Shewiing ® Tsanslation: —2 T} is repos tiontn an object olong shiaight June por ; ee one coordinate location to another, — > Thanslahion ds stigid body transformation thar moves gn - abject without deformation. ©: her ar Thanelation 7 (ix, 44) 2 erslation veo ol shift veckn Q: Toanslale a point (Qu) where Tit)» Find pt P= (2,4) pe PeT \te) T=(ci4) \r= (1, 18) xO @- Trarslete a palygon with coordinokes 4 (27), BC710), c(10, 2) by Zuni in X dinechion and 4 Som in ¥ dixechion. A= (5,7 ge (to) v c= (3,6) G) Rotabion * Tsme apn object ar ek particular angle 6 a Yotate wae = aon origin. ac yea(8r) y ae = (cob cap ~ sinsing) = ¥c@6 cad - sind sind = acah- y sind y= ssin(8 rd) = = ¥ (sind cop r caBsin ) (610) = ysindemd + ¥cabsinh = asinO + yoad we xed y= xsing Nabstix Repastirbaln m i 5 Rotaion maltix Pe RP : ah ~ sind i [ [me cad y w = acod ~ ysind y = asin§ + youd © peint (4,8) die 4 4s° a uM | bak Vi Yee is Yotated Hal) 2. +2 *E in counter dock wise dineckion -by the Find the siotation malate Rand dhe vesublant pain. : RP (ine ze. eae ol aa [ a Va () Seaking 1 A scaling tnansoxxmabion alas dhe size 4 an object. . aites Scaling 4 a poly gan equines mul Kpying the cdovdinake’ value a4 each verter by She sealing docs to ger fhe new coordinate value. O< Sa, S¥ KIA Size Oo) Sx, Sy ? ] —s ize ® Ba= By. —s pniform scahing Th mabux er it can be sreporecented as * ©: Thonslake a Square Apob, A (0) 5 B(3, 0) , c (3,8) £ D (0,3) ae by d units in both the dinection and then seole if by hoo In y- dinectin ond 0°5 unis in Y> dinectfon « Determine the Hesultant | coor dinale 4 poy —> Taonslotion + Veep en le wood Sealing t AG) Bret) Crs. 28) D'( 28) &: Magni ty the AS with verlice (0.0) > Ch \) a) tto_tuice tts Size A : , = Zo while beeping G2), red. ge Goes Duta A) — Seahing - A\(0,0) 8! (2,2) dws). ; —> Translate > A"(-5,-2) — 8"C3,9) OC ja : on unth Coordinale A (2,5) , BG,10) » C (0,2) by 2 oni g 3 womb in Ye dinection. - Q: Scale 9 pay 9 in X-dinechion —> A (28) oe —> C(io, 2) ee ee > ACs) ‘a4 > Ce) itn) etl & > 4 Bi(t4,20) G- Rotate The Some AX abovk She pivot point ( 22): an le ke OR AS it Sianabeta cee ua) B (4,4) va VB [* | = [és] B! vs ya il" ab ie fell = f-% =f a zy a Yi. Yo Gru Ts 52 fh Teaco * A (318) p(-2) sb-2)_ ¢ (5-2, 58 -2) @ Rerote oa AR angle q 4s’, As |’ Ve Bi= Iv Ve C= he Yo A (00) B(2) C(4,2) @bour the origin by: a9 arrears eran seg ey ay i aN Homogenous Coordinate System : gyster is an absboack, oepresentabion fechnispe = : homogenous, coordinate a-d point P Cary) with a 2 - element in} uihich «we Hepresent oO Vects Ph Cah, yh, b) with the, su@laWvenship « oe i is Tre fern h is the homegeneots Facts 2 can take any ‘ero voluo. Fo eg potat (2,4) has homogenots comidinates (6.82). coordinate ay Taanslote, Rotose , Seale ae ef ae \gro a ar isi poecess at fidi ge krne use-2x3 Ymabux. > AT A kist process x Tiere & fa instead 4 Qxd mobix we »* Tsi CA apne ko oh (puny coordinole) Ap Th this System, we Con srepnesent al} the in a rnobdx youl} pUicahan qo: eR ue Ove Saal ey rransformolion equations - Taonslation + © | | a dear hy gary NY) ay7.i! 9 yj} fot 1 o 0 pho = T (ta dy): P @) Rotation » a= acaG- ysiaS % > xsi 3 y+ asin® rycol- : a]. [ood ~-sieO ] [* ; ee Fl ginS ew f LY ‘ se &) Seabing : a. Fi ity a ‘ ° [| Fe clit | hn yee Y&s 3p Th homogenous coordinate \ Sy C(O 0 q " oO 5) oC ce Reflection <> i arefleclion js a transformation Shak produces a mivror imoge vi an object. —> The miooot image qj dd aelleckion Js generated sdative to on axis 4) siehection by totaling the object 120° fo She sieflecKion axis . © Apout X= aus * aa = @ About % 00S + ee ‘Aa oa Th ad i. - @) Avout —Orrinin H+ . V8 Oost \ dbott the Sine, AO ond deforming the oresulbant coordi nodes. | | | bout: [ae A) a Cu) Y-oxt © 1 0 ee ce ec 7 oy c 64,8) 4 at a | io eo ‘ \ 4 © © - \RN Shearing » —> The - F = The sheaning dnanslovmation distovs the Shape 4 the object, a — There oie 2 type 4 ens bronsformolion: oORWIND . dg 0) ¥~ Shearing a eae a Ye shewsng * — presene the jj coovdinakes bul changes fhe a valiies. > Fos ony point ?Cuy) : 7 P (atehe: y 64), whee shu is the sheaning vector in K nb come While thee Js 6 change iin Y-shesing : —> The 4% coordinaye email in volue- ate Shh — For any point Guy) esr ® PCa, yrshy*) , vdnere Shy is the Sheortingy vecfr ta ¥ dixadion & Sheaning ‘ X= heating 5 x | swe 0 a Vv n | y 0 \ 0 y | 6 Oo SI | Y-shect a i x y |” ¥ | 1 ) XP Reflection : th) About X-aus % ~ ei] ft 6 2 a) “ ier Or tet ice y ' ie fe : xe | 0 0 4 1 3 Oe PE LE! 6° Os Ay (ny About Y ois oc oo a o CoC Q: Shear a polygon A(o,0) B(r0) Chi) d(o :) by shearing vec chat and determing the new caordinates « A@o) BQo) C0) p (0,1) A (0.9 80,0) c @, \) VQ 1) Shearing 8 applied on_ both the direction gimubloneous| then the mobdx Sst be + 1 Qyrd when b=9 7a Sheanving b f #2 ico ar 4 Shearing © Ay pola gon with verttices —A%(0,0), 00) (4) (0,1) . Parform the: Velloning Snansformations — and condade the. stesul of Shearing.” : g) %~ Shearing with == 2 qotlowed dy y che arting with b=3 ty Sinaltoneows a ond YY Seong with a22 and b=3, @ a a _f. 2.0 t = fo s “|o 1.0 y ° ' o o | 1 i AY (0,0) Bora a iO re 1 1 wie Hire ° ~ lo \ oo | baal 8 U0) ¥ rd Ce ae ret fla or lalla iles yf} fs i 8 al? |, om > —— —-co - oe a ow- Ow - C-e& @-n —-°eG -o@6 — Ts! —oe- — GS oes 4“___) "a “ ——— - wor —-— ee oi —1 —X ww 22 oS - w Ss = ee S @ a re " Now , ) Shecnting ws : 2-4 3s equtylent fo vieflection - delalive to yroxs followed by counter “clockwise stototion q ao". oO °° —> The mabux qn the elect on yee is I: Ba Q Snow they ateflection abouk the Wine yr Pea 5 alate —> We need fo puoove thot this ds equivalent fae j i 1" the AK tp abux obtain by sieleckisa about : XK Te Jt oO to od o | 0 ° ! o Oo | 0 ter< Ty eo oF]? & tw]. fe a oy ofjot o | fen © do | ° oO @l 6 o | to] fa q \ a-Jul. jr © 8,3 y 6 -7 6 Zils J3 A (9.3) | S$! oel \ | i 4 Belg -J\ © Ie ~y . 6 1 y! © ~). 8 al fF \ 8 (6,1) 0 eal ‘\nanelornalin — Th 3D. ve hove 3 ols WY a 10 0% {lt gy} =fot Om] a Z oo th llz 1 © 06 oO 4 \ G@) a-d Sealing + 4 & © © O\l4 yj = ]O bo Of\9 z 0 0 gs O|\4 1 6 o 61 1 jt! such ther Maen ore nov rol fe each other @ ad Rotations @) a-d Rehection : 3 Rotalion abou % ads? % Tn %Y plane Ea Mo oo e 10 107 O8( [a Rx =] 0 cob -sing © Ye] e fo { ost 0 Sind cad 0 z 6 oe a, C0 o2) t ‘ee oo OS) 4p Tn ¥ i “PF Rotation about y axe ° ain ee v a 6 OO 14 1 e 0 LE i. Se Miaeie” y o © o 6 \ oo o Vik “sink © coh 0 (oSpeeeas teeny oy asec FP In' Z-* plone v : =p Rotation abovwk =z axis + av rood te ee yf se |e o Of ly o 0.8 4 o Zz co - 0 z @ SinS 0 0 6:4 v 5 eo GD 8 6 © 0 R= |sin’ 8 6 0 ‘ » 0 4 a sotabion As’ about She yr mers ys’ chou a-onds nd determine the siesultany @ Fa the given mattix , {sdoued by yotation Q\ Tabring 2 o | 0 \ 38 0 0 ho tO 603 §& | —S Trae aie hwo — Totalions Ra 2 Ra. R= aus 0 Sinks’ OT Re 1 0 o 6 J Jo 1 6 0 * Lo cois’ ~sins" 6 -SinyS 6 Cols’ 0 O anus” cous’ Oo 0 0 yl © 0 0 \ Nowy, Composite tnonsformation, R= wh? | ye 8 Ye o -Yi © Ye 0 0 0 A es 0 vy Va O 0 \ 0 Off o Yea oo ov ya Oo Veo ya 6 0 O ) 0 Oo o | oo 6 | 0 0 0 The aresulvont — moti Wi be - & \ sectong whos porallelopiped hos its bai ad unit, 2vart & | uni om X,¥ 2 Zods aespectively, Performa wofa tion by 90" Clockwise ‘abou! X- oxhs « => Rotation about X-axis. « eaten : 3 * © c%) ~-sin¢a) 9 © ginGas) coGa) © CIPO terse tt | Sel Eto HOHte : © 1 0 HN 9 0 So 8 8 a& Trranstos mation matrix * > (2,9) a : dD G2. oj 0 : : 1 E> (0.20). 0 1 8 8 p> (6% 1) 7 o.} & = @2 WO oO ae J S 2 ° = a Viewing aoa graphics package thet odlews a user fo spedty which part qf a defined picture Js to be disployed ond where that pant is fo be displayed om dhe disploy device Using @ Conceph — known = chipping. — > World coordinate Susten ¢ This is the objech space the space in which apphicabion mode) ds degined - —> Screen coordinale system 3 The space in which She mage ds displayed js called od Soreen coor dinade guste. Window : The method selecting the portion q ite dawg ‘sealed orectanguledt aned Which te geleted is Called window, windowing Q the & Viewport: The sectangulax portion s the interjace usindow shat defines where the vnage which ackually appear is “called = viewfort. eee Yusindow i ¥ Viewing Pipeline » Yon oe uInbow Yamin BWinin AWmax, World Coordinares. A Mopting Oo pot Coor dinake is veered 4 YWinta XVinax 0 (0,0) _—> Device coordirsres a world coovdinake Scene to device” to as Viewing. “jonsFormation 2d viauing dransfowmation ie singly slonied’ to od! Fhe ©" Window _ fo viewport jnosstormation ot & Windour! 9 qulstane, xT TH Ta AG ANy™ Wenig EW nay 7 Menta Yo = Yamin ee Yooinax — vein Ral a “Relative position” war Bad lea} | Hs ~ (Han) savin > Pays Wi + (am Ho) 6 ea — Wenig ba, $y > Scahing factor W= Wain > |W = Wain + Cha Yoni) a Neny 7 Yen Clipping = gr Portion window or atez ata Ye a Cspped pat bolte o ar the process 4 displaying inside image 4 Yhe window) is called dipping. Types: —> Point Sipping, oe G) we ce ve —> Line dipping ce t ete Yala —> Falygon cliping “( lane) Jenne oe —> Gone Clipping _- AO) pe va Tals AE Foie Play) ill be diplayed st: Xudnin & aX XWorat Yumto S ye Yutmax Q) Line cipping : “ sr Window + aera ® ara yermene ar | oe ) Both end points inside a1 i visible.’ * diy NOT” Vigible# Both points oursde, ET ity Pontielly wishes 4 a aie 1 bobo Were a3" ae cg—ing eas nal “Cohen Guthenland | Line Spping Algorithm” ©) Polygon Cipping : — Suthentand Hedgeman Joo ith aM CN Before ee Af clipping | G@ Tet Ctpping : 6) Gave cheering | —£ oh] bo &) eS) Bb AR vo Before AFten —T\ Before Cohen Sutherland line cli pine Libportthm: wen AA X Determining the visibility ql The Mine s —> In Cohen Suthenland algosithn outcode or vegion code ane used fo determine the visibility gq the Mine , the whole sregion is divided into 4 Subse regions ond ae Sub- Xe Qvon hop a Code. : 2 Xenin Xa ee Ye Ymin €B) Y Ya, CD bape Pseudo Code : © Assign ihe region _ code fo tun end points 4 a given Sine. @) TE doth howe megian Coder _O000__.then Vine accepted comple’ ® else penform — logical AND operation | jo both vtegion ze @ if nesultl fo Mine ds wel 4 ; oe ® els Mine AGT - partially : v ek pont to ine GT jo -uindow a TET 2 | Sind the & intersection q dine With usindow. Replace end point unth fhe dnfersechon point 2 updole egion code. Repeat step @) until dine is daviviglly accepted ot ejected - G) Repeok above Steps for other Une ALGORITHM : & Assign Region code to both end pein’ (jer iF be (g 2 6) ne ace QR Gog == 0097 ( then completedyy accepted) > Wed lindo FRR | else it nS Bae Co 88 G FOCOD — Refer it else Cp WF Vine Crosses min OF Awa. then ye git» ON) ~~ : - x qt ade “| " ae) () Verify Amin < A/S You : me Ya ee £ (ve Yaa a i ay IF jt does: not sabishy then mp coe Q tet Aecy be te dectan gua window Lith (20,20) , B(90,20) 4 ¢(a6, 70) | and (20,70). Find segion codes fo She end foints ond ~ Use” Cohen- Sutherland algorithm fo dip dhe Line FB with P()o.a0) 2 (00,20): 1001 &,( 80,40) (40170). > Qe 0) > Yox 5 O00! | mm BO oy Yinty ©) Finding Region Code s 9,(10,30) > %»% R= 00 ee 9, (80,90) > Kh @ P= 1000, 000027 tine Aa porially aa visible. COlp GRY isko) @ Slope, m= YoY = Gs2 = & = 0-857 B-4, 8o-to 7 gee : : — For point 9% —> Fo point g intersection @ — an ; B= LL Cymae™ It : a Cy Yr) + a, ye Corn Xe) = Ls (0-30) +lo = 0:57 (20-, \o) +30 0-857 $57 +30 = (Se6r> 2 bre eet a —skormula ty Colenlate he bit code + xy Bir l= sig of (yy) ksign=1 he a BE D= Sy" 4 Cane ) # signz 0 =ve x Bit 3= Sig (> Xn) x Bit 4 Sign 4 (x72) Q. Use the chen gutherland o.gouithm fo deterring he visibidity a RP p(i0. 3) , P, Qoo. 19) agains windows usith lower lay hand cornell “ight hand cones ok (30,40). oy (Go, 10) and vppe Outesde for. Pit Guys) a Bit 1 = § (20-40) =-10 70 Bird = S(i0-29) =-\020 mis) ee Bits = 5 (70-80) <-lO7 (66,10) 0 = g(S0-79) = 710 20. Ovteode Yor Pas (00, to) Bit! = $ (to -4o) = $(-30) = 0 Bit2 = 6(10-10) = OF pirg = § (0-80) * |, Bity = § (50-\00) : $50) 20 4p. the oulcode qe both the end point is rot ©000 - visible (0000 AND O10 As. 0 aesut is 0000. 0 the both the end porn and need to be upped — The ourcode q P, as Gool. we can conclude had the ote Sine sg extending (000 1) let ey edge q the windovd. 0) 7 sling BR tome S *eat) (9,12) ¢ 4 — R Stine RR Tm Bey 7s &|y=05] Gs) Gy) (8:12) ‘ ss — Now, also Finding outeede of P C5, cate B = 45-10 40) ts the @ bitcode of Fis 0009. . Tt is inside the Sipping. window. Rre ome lo-aS - 5 2» fac. As, ‘ab dee nee a re Frding out outeode QT! (5:6, 10) pile VS ae an | = =S-loc =B6-10 = completely inside the. chip aye ae Nord, Ba WO=O , By =B6-10 =, By = 5-596 =0 & visible portion is (s, 4+ 5) & —_ determing, eo: 7 hts the intursechion point Bes al the We RL = 40-20 = 10 = 30 = Lao 30-10 the Visible portion 4 \ine io (80, 6 61) : with al coor dinores @ Rod out te coovdinates q the dipped Vine qo a Yne P,P2 where B (620) 2 Ps Ce0,30) ageinst 4 window — wrth (nin » Yain) =(5, 15) and CBnaes Your) = 25:25): Hor) — 9, (19.20) By 10-25 = 0 Tv greet 8 Gt). ee pyz 1025 > 0 Q Ye '5 B, > 18 21) —» P, (6020) * olel saat \o1o g,20-25 @! 1 = And (000 p, 21s-60=D B ; t? Jie Pox Wally visible, p30 8! Re = By = 15-30= 0 LC — FYo point e, m= BOr10 = 60-10 Bt ls 2 =| Pe) 3 0 a \ » a " Oo w 2 u = A 1 wn u ° ® rm G5.y) (ons, is), = PPS ; gets. of 2, tee Bz 6-25 “e\ g,2 15-16 =| ‘ _? As. te outcode. ~ 6.000. ——= vs The Mioe_it_compleley ibe gta vise portion is (5.8) & Gs, ia: ape Bat = jo zs 1S Sutherland 7 Hedgenas fly on Chipping Alaovithn > F dps She sregion q the polygon Sying oviside She window. —> Tk dips ageinst each edge of windos 2 ohtan nev set 4 vortices ZA I ro Rus for Aigging he plygon out Sin i i : : ~ x in — In ofp —> intensection : point Op > destinakion Point olp> intersection point . + destination point 7 ovr > ow o|p > NULL = — Vertex © oy PP ng against ‘ight edge : @ Oipping against bottom edge : nw Ate ® Clipping against vhe ep edge * A A ortho 3 ae @) Tepak jour chips & Ge eins Ges Xm » Ce Yemen 2 Cy = Yen corvesponding to dhe left, vigh, top, and bottom Uindow . boundoer. The polygon is specified poly ia. fern of TR ventex ust Vin = YM Mee Yad where phe vertices ane ‘named anticloceuise. @) else it both the vation ane, {ngide the ospper then © avd y to vow? @ else iF vi is ouside 2 YW inede oh the chipper then GO) ADD Ye intersection point-.of fhe dipper with the edge.Ory) ond vj to, Vour-~ 3 @) fe each clipper in She oder Cibo Cd, do Gi else @ Ser outpor vertex Mer Vou” NULL , f= 1, fel ® vepeat © Consider the vertex poly vi By, fo Min GS op is inside and vy outside Hen ADD the in tensechion point ol The Ckpper with the edge (vi, yj) te Vouk “ADD NULL to Vout Car = ® Until oll edge Lie consecutive Venttk pains) in Via ara checked. @ se Gv © End for A ow ED/ Steps q Sutherland Hodgeman Polygon Cipping Algaxithm + (e)Read the coordinates q) al vertices 4 She poly gen: @) Red Ire coordinokes 44 a the Vpping window, @) Cosider She Left edge She window. 7 © Compare the verte gy the edge g| the polygon, individually with She dipping plone. 6) Save he sesubhing * ntengechions and The vertticn According fo Ske rola ® Repeok Step ©.® for the sremoining edge gy the chipping urtindew. 7 uss - ee © fon Kine Mike neaulrant st q) verticw, to the nent edge Y 4 She dipping wiadoro: ' © stor

You might also like