You are on page 1of 85
PAGE No] (oare] } racti eooeeore hone limencianal Tenasformation —~__Cyanslation and scaling) | Practical outcome Pos). Linre — gee for too cee x tans For mations: | i) Translation | it) Scaling . pipettes : i 4 ) Translation : cai JL: Start eee 2: Include header Files il 3.._Declave _voriable. 21, 41, 22, yan me, Ee 4_-_ Accept end points of _Ifne _and_ store ft in _ a aie eee Nh Rt 2s a ———______ 5. Draw a Hine using ioe cine” —line. Ge, Z Steger OUatl o.) 3 a b> ____|6. Accept the translation coordinate Prom usery and _6lore [t in x % y vespechively T_.__calculoke new values for 2x SRSA Oto | ——by addfng translation Coordinates : jee. eal Rl ice te ea ss i F For x drow line. after translation, ~ i (oare } Jo. ineC ae1,4., Ra Y2)i u- Stop mers rithm oP Scaling + TT | it 2» Include header Piles _ 7 ~ Declare. Variable 1, ys, 2 Sy Aaa -Accept end points of line fa Es fave es (seo Ome a | 1 Gi, *2,42, S-_DyowW _a_line using line _Punchion i-e. lineGet yl, 22, yo); le. Accept the Scaling Factoy-” —Prem __| USer and Gtore i+ _in__S 4+ 64 vespecHvely- | J Calculake new values Foxy 208.1 Toe 2 2 eee ae —____|_by multiply the previous value of sl ,y1,22, ye. | eee pee OC Scaling Factay i.e Ee Ri = Xl # Se 5 o Y= 4 ksy 5 E : x ok Sie i eee cee ee —____|?- Draw the line aftey tyanéslation - +e __use__new _values_oF 1, y1 22, yo. draw line after Scaling. |Elow chart _ (Translation) — a stark) Declave __ Variable_ _gd= DETECT,gm Ri, yy, K of a Ly. [rccept translation Coordinates Prom/ [user ond Stove ft in *&,y |__| Calculoke new values for 21 .y1, 22,42 eri adding translation Coordinates : pea ee OC a S Hea eet 4s eo Bt ot oe GS = eae C Start Declave Variable gd= DETECT, gm, acetates) 202 ‘ns Bx 18y 6 ae na Precept value For =I, ty pence [Draw line Geis4), 22,42) ....CeeFere Scaling)] ST ~Cé ee [Precept Scaling Facky From user and [Grove it in Se, Sy. eas — new values for 7 aad | ttply by Scaling factor . Reale ACT OCs J ieee are Yi Sy 5 i aa Sx 3 = 48 fs —aPtex Scaling *. ae (oare #* indude 4 include < conio-h> # Include < graphics. h a jl main Cc) | tnd ga DETECT, gms | int wl,yl, 22,42, Ys a —____||__inftgraph (2 9d. %9m_," Co NTC bgi”) 5 |__ Settextshyle (0.0 1128): z cut textxyCeoric,' rame-Bhininde Gitanjali_ Santosh’); Outtextay (2,22, "Roll _no- 1249"); | __print® C"\n\n_ Enter 2 line _end_points_:”)3 Ea Soceieeuns, 032, Ov) Scanf C" Ad nd Kd Aad", Fx1,F41,9%2 S42) PrinkEC"\n Line before translation :"); lineCotl, yt, 2,425 delay (809; _ ss Enter translation _co-ord:' 2e.yi" Sconf C“ td pd“ ,£2,% 4); Ry = we lteG 41 = Yi ty; Rea 2 ee a D Bias oF ys: 5 Seeemetoote Nn Nt xt AG NEE [ine of pevettronees eeeeeelah anes); : ™ oe Bee licves (snl eee 425 ah Tnelude Fs tdio- Nowe ees Ht faclucle + conio- h> a Ht include <_ a J ae Me mant(e a eet _ eal fot __gd= DETECT, gms _ Saal fot 21,41 R22, u2, 52, Sy 5 oo Egm, ae A\ TC AW Eg) Sek texts. et C80 sia," Hame: = Bhintade Gitanjali PrinteC’\a \n \n_ Enter 2 Line end points 2"); eerinkeG! =i yy loo, uo) 7 Scan 6" %d bd fd fol”, Fel, 8 y! 8x2, S42)3 print C"\a Line before Scaling $")5 line (ret Yt Re yo) EEE Ye ley (oct) ae _prinke C" \t \t tntey_Scaling Facloy_ Sz,5y "3 Senne Ci eds Px a fale e LIS RLF Sj Yi = 4) & Syi ALS Ro # Sx 42 = 4a #845 Prinke C" \o \t \t\t \t Vt line _aPtey line Cet, 41,22, 425 a a Jekch ae rE pee = e dlesegraph 02s Reet Sue * eet eet? a “Clranslation) Name - Bhintade Gitanjali_ Santosh — Roll no = 1249 Entey_2 line endpoints: coe 2 Y 200 800 320 Wine translabion coordinate x,y: 5o 2. line _aftey_translaHon_* leo (are } al_Related questions £ = Waite the th trangfermation_matnx “for_o0 Trans- Sol”: “ft! ep ae th i —— ° a 9.2] Jarite the —transfarmation matnx_ for 2 Sc io - ae es oa. x | [sx Bea __ ele © Sy] ae ee 93| What | does Scaling transtomation™ _do® @ son] __A_Scaling transformation changes. the_size | of an __object. This operation _ —€an_br® compress or expand the _diimensjon oF +the abject _ q-4| Whether size of object Femains same_ox ed in case of tyanslabian? Sol" Frans {ation does not alter the Shape or_ Size of _ the object I+ just moves the _enhre. aoe From one location to _o ° 0 along a Haight path. a [oare } cise — Translate the poly g on with coordinate s- A(2,5),| 2)_and_cC1e,2)_by 3_units_in_x_diveckon in _y dive chon. = eve translation uector, q=[ 43 Z et [Trans ation operation is _dePined a5, ene PS Tp ss eA =Te a “EE (23s s}56 | saat eo Bite as o | lo 14 | eee Z = jon_AC248), Blau mere 0,2) will Berne A'CS..9)_,8'Cle, 14), _c\3,624 1\_ Start _|La) Declare _vanables mL, yl, 22,42. Cel yts 22, 42)- 6) Enter the angle it into Ctheta) 2) Include heades_ftles ae 1, V1, R254 2. the 4) Accept end _pofnts. _of line and stove it ia || 5) Drow a (paeluctagiling function te. line | eat z “thera From_user_and Store || Variable 1s een 7). calculate new Values fox atl, yl, 222,42.) tt ne |S 21 COS. (theta) —41-& Gin Ctheradé yp = a sin (theta) + YI -h cos Ctheta) ; ee wore cos_Ctheta)—Y2 % Sin Ctheta)s__ = Bo ¥ Sin (theta) + 42 * cos Ctheka) : Eo tad Cr) eres 3) Draw line after we) [fneC et yr te 142 drawing line after translation. 3) We use new Values oF wl, 412%2,42 Fox D5 STP. jalue Fox > te 1 (omre } 4 _foclude ~< graphics .h3 [3 include ee ieee Marie rrarnchape Cine. tak toh) [ate e Void Rotation Cint)j i Void _ aver Ge ) ions. GE = ee eet ies te i dweseraenen fai mS eis gdriver = DETECT, made: _ he ee re Intel ,yl, 2x2, 42, theta; eee priate C'\a Enter the 2 Be AUE pI a ieee zee zu a . _Scank C* wd ro 4d on Bx), 2 yi, Pz2 3 ya); eee (4 gdziver, gmode "cc bg i”) pea Wine Ger Will eek, SM C" Enter Rotation angle_thata? Ds pulatF Scanf_C’ 4d" theta); ee ere (theta) - SU ween) n CtheFa) 5 Y= 21 * siaCtheta) + 41 x cos Ctheta); Ro = R2 # Cos (theta) —yo * Sin Ctheta)s }___42 = 2 # sin Ctheta)ty2 % cos Ctheta) ; Be onenet nu lrne acter aya enon Pecttbhe. (raceno: Practical No.5 one) '109ram For. _two dimensional “TYansformation CReFlection 4 Sheaning) Practical — outcome; : rs “bathe —a_pragraen fir. Refleckinn Eg ae 2 aneres ae a: Pegi: 2emin= jo -yming Le ©) max =40, ere —Yenax ='lo +. e Declare mide, midy ae | Step | ner iacoeaa rie, | diawalepe 0 paced 1_fePlechion( Step 5% dostde Void main () _ ft ta | i Jo create and 4 AXIS on “the _scxeens| Calculate —— as —_midac_= Ploox (germax iy) ae _midy = Floor Cgetmax 4.C)/2)3— Now drow these axis, jfneC mide, omide ,_ . = line Co eee eco ite drawshape () and draw aq __ rectangle. 5 ine qa oratin. tefl Hes ymin. mile t+ amox, ____midy= yminJs es ! mn - 0 7 - Mid 4 = ymax), = x i its mid y= yenax), idac + emia, midy = ymax ,mid x+txmin, Bees Servic) eee ee Sy) Step 7 2 Call Reflection ) - r for __yeFlecHan— “abnad ioe axis syed = — New 2#eqia = Xmin New Xmax = >A max ail new ymin =—Y min Neu) Y max = -4max aa Call _draashape () ee o 5 For tePlecHon about y < axis_is Ce =) 0) ape Ned Amin ==-xXmin = iat oe a Cte A max = = X max sy peer Ecos mig = mai (eee LPI Umax = max Col ee on nce) Se [Step Ree ST0P Now drow the _axts_i boar (9 ehmax2e 3 00 max mid eStore a Ene Cenia diaoShape C) xLo] mid y— io — nid e+ aC midy = 460 oe : —a AG Start Ne f y = | EniialiZe remin=10, Yemin=lo, Xmax =40 > Yman=Tesmidx, mid T Ay arene z Declave vofd functions dlrasoshapeC), RePlectionC/ T 1 re = ee |.mMidx = Floor Cgetmaxx (1/2) | ae aa = Floor (getmaxy ()/2) line (mide. 0, midz, gekmax4 ©. - line (o, midu, getmaxr.() > mid y) 4 line(midz temin, midly = ymin, emide + xmaz.snid y= 4migh i ny Grid. tAmax.. midy =ymax_, mide + xmia,midy— ymax) | ae ne -areseshone O ae emi ya --4Mia,midetxmax, Midly ymax) |, [line (mid. + xm midy= Ymin»midx + 0 ee po. E [cali RePlecHion() _f/ RePlecHion about Toni NewxeMin= —Xoin NEW MAA &=-K MaX new ymin = ymin} max sia “ Se t d pec) | | iCall dvaw shape (> | cost dyaw sha; STO void funch'oor droushapecd? Sheantng (|__| ie ¥Y ae eee —__| _midx=FloorC getmaxx¢)/2) 5 | _midy = PlnorCgetmoasy 0/2); | —_|Line(mide 0 ,mide, germaxy0d)s thine Co .midy . getmaxxC), midy )s ] ey ae = = Teall dyaaahape ou Line Cmide + # (61. midy-¥Col , midet xD. midy-qoedDs i ide +xO1, enidy-40 ,mide + x02], midy -4 (215 line Conide +eC2)_.midy—4C2) , mide +x(81, midy 43195 line Cmide tx fa] midy= idy — aa rai 2. = Se eee thas Declare hee Shy=1S fat newer Ty iat _xc4) = =Jo,50,50, 0}; = -#t include ad eee Sl h> lude_ | int C4) = § 0,0,50,50%5 ae : [ | int mide» mid 45 abe i Void Drawshape oe fl ink de a void shearing (); Void main (> - HF clyscy C) 5 __tot gdanver = DETECT genode > thela 5 initgra ph. (C$ qd Fm." c Wei BE1")s — print é C™ \o_Name 2 Bhintade Gftanjali sai _printeC"\0 Roll to. 1249"); | _ idee Floor. ‘Cgetmax A(>/2) 5 ja a __mid y = Floor Sa Q]2) 5 _ Es ~ line Cmid 2 0, mide 5 getmaxy oom line © O., midy ,getmoxxC), midydi ait Ree yarachare Ce yoo : Shearing CDi vee ce getchc? ta 2 a loSeQ7 eZ, lection aptead ne understand the concept of transtor=| ion Such a5 tanslation_, ReFlestion LDeveloped the program for Reflection and Sheasing | we @ eeemt ne on: formation “mati x fox 2D shear- : Sel": ewe shoe Pe - je) ae ese eS ea : a | aie ome |e OE Oe =a - ee BOM 0) I alee 93 Differentiate between __X-Sheaz_and_ shear. eal “ | Seah cao mec Yechear: | | di. tn x Sheav, the 1. In_y shear, the fnake remain coordinates remain L ea —y Co-ord the Same._but the — the same_ but they i ase X_ Co-ordinates changes. y= Co-ordinate. changes _| |\2.. The X%-Gheor proses 2.. The \-Sheay _preser- inates and the \ Coordinate _|_ves_the Coord and changes are. _| changes_the Coord inak ‘ | | made to X coordina=|_which causes the. tes, which causes tha horizontal ines _to_tran-| “| vertical lines_to tilt | Sfore foto _lines__ which Tight _or Tee toe Slopes__up ox _dason i : fe | Derine Reflection and Ghearing ee qg mirror image of an objects The mirtor | fenage can be efther about x-axis or Y-aA15: The object fs totated by 180". I isa trans formation which produce | 1 H S| Sheaning ooo At ix hans formafron which changes the Shape of object. The sliding oF layers | oF object occur: The shear can be in ene divechon or in two direchons io — a antes atl __ © Exercise_ | | QO A Point C4,3) is yotated counterclockwise by e an angle of 45° - Find the _‘ratation _matn'x e andthe _Yesultant point. Apply the Gheaming, transfoYmation to Squaye with ACo,), BC1,0), c(t) _and_pC ©71) _as_gfven below : S00: Cara) 24,3) fs totated by 45 "*Ccounterclachiaise)|| P= [ax 45° = Sin see) ish i A Sin 45° cos 45° ea (moeno] (pare } = [ine -/z {4 [- fe oe eS] a el : : z [gs] [a7 e Meer eee iinet ise Pesteand “shea Parameter is 0-5 >» 50 Shx= 0-5 ___ —2 The re reriaes matrix for Shearing, usith Yespeck to __reFerence_line___4aeF i afi she = Yet che | 2 ee fleet | owls oO tL Ihiros fa ea] | l Eee ear coer inate Spanier ii. Here, reference. line is ere: parametey {s_0-5_, so Sry =0-5. zi 0 } a 1 6 6 = _ JL Sarees Flos 1 os 6 mee! 6 tia] Practt 7 Progvam for three dimensiones transformation (Translation agai | Step 4°. Inside main funcHon , peclare | Step 5° | Step € 4 Beege rc biG) ee Step 7 : Define the translation 2a | step 8 rile translation ©), declare _ Outcome: Witite program for thee dlimensieoall_ Translation and uae cae are | Algo orithm : ‘is |i) Translation : ee step 1: Stor} Step 2. Include header File ory Step 6: Declare._tyanslation () _and_ .Declaze oriable maxx, max y.mide,midys | vowtoble gd= DETECT, 220 cal] translation () Nica Cn leses ees tae 70 ae eeae Calcitate maxx & maxy : _ Maxx = getmaxxC) ___maxy = getmaxyC)_ calculate mid 2 & miy —— mid (nom) (pare } Step lo : Accept translation coordinates from user. and store ft in 2x y.- a step Il: Draw object after translation : bovad (mide +2 +50 ,midy-Cytloe), midxtxteo,— midy—Cyt50), 20, 1)5 2 | Step ee End a ab it) Rete eS m e (SDR _ Stark fee T e ea Step 2°. Include header Fike. > + Step G_: Declare _Scali'ng_ funchon and peclave | _ __Variable maxx ,.mox 4» mide, midy 6tep 4 2 Inside main _funct’on_, Declare Soar a DETECT ,4gm- Soe a Es J ppepmomeemee calle. scaling C) id | = gekch £) p—1—- __DeFine._ Scaling ce Step @ _< Insfde scaling () , declare variable pee a yee Az = iin haw Sa a calculake maxx 4 maxy + max x= ey é | max 4 = _germax Ca | cq midz = max x/2 = 2 I a (eAre J + Dyaw object before scali'ng bay ad Cmide +50, midy= 100, midetloo , ——_Midy—5o, 20°, DG Step le: Accept scaling Fachy from __user, and stere i+” in sx ,5y,sz. ccnp hers } rey acaling * bar 8dCmid 2 +(Csx%¥ a Step 12 2 End : << a — | A eee nae | waid—sealjag cd a ou Declare See —_|Maxx = geFmax x Cli _— LE {maxy = gekmax yc); —_ See eda IX (2 a a | eet aan ea __| bar ad Cmide +50, midy-loo, maids eplonjeniAleen ree pees re eee hs + 20,1)_ Enter scaling Packer 4 etnxe ft tn se ,5ysz 2 MyaiesohwerEeGeter’ Scaling sa barad (mide t+ CSz #50),midy -Gy # loo), Programm Code 1 lon ¢ a Ftinclude tra) Void scaling (5 [aid moiac) = nd ad= D c gms fnitgraph (8 gd gms !\\TC\\ bai”) 19 3 ad (oare } 4) Explain Homogeneous coordinates? Sol ____ Homo li Poy: i but _q__dystem coordinates. in_prosective cortesian _coordinakeS are fe tal —___|| Fucliden _geo metry. They _have advantage that || —_____|| the coordinates: of pornt fincluding points at || ————a fnFint ty can be Yepre sented using Coo rdinakes | = —__Homagenous Coordinate have _a_vange | ee of application, fncludiag Computer _g7ap hics_ a and Sv __ computer’ gra phicr and__50 Computes. —_____|| Viston where they —_qlou>_tvans formation -__ . = _ a “oa = 2 a Bria con he represented LE] yy [ | 2 = fa 2p tans formation 1 i == i lan din 3) transformation | * oe IL a {5__tepresented a5 yjov|t el me E z z al ees So]? “bax 3d’ fuochons s@ale _ it a its e ram to _dro woo cube. bit aa Sica eee Cn ee i | Htinclude -< graphics eres om Ht e@ =e SEE Beas De — printf C" Right bottom value C22. yd: ye ot Krank C" Zid" £22, 2-2) i ee lepth = (x21) /4; sf a fcemecen (07 [cree es ae es fat gd= DET Ect. 9m; ___tot 21, 22, y!,y2,me, my, depths) ___loitgraph gd, #gm,"c:\\IC\\ Bat") 5 Void draw Ci Vord Scale C5 es __printe C" Transformation Scaling ” > “i Beep cee |S top value Cel 41 — Scank Ct" nd Ad” Fret, sys rie (ATM tafe) a a a fe draw (>) Sie ea eas = Program For three _dimensio- c @ A ore eas rasp {— stare fs 2 Jnclyde header files ch -|.3) Declare _vam'ables 21,4 1,22, yo, theta. __ || —4) Accept 2 end pafats and store it in x1, || é eee ere Yo Sa ass ee 5) Drow _a_shape using funcHons f-e | e Maxx = gekmax x (yj oe ——maxy= get moxy (); _ poe | iat cd eae TV ON 5 ae £ —__midy = maxy pi and drei object | bot adCmide t5°, mid 4-loo, mid +6o,midao, Meet CS Oe 6) Enter the —angle._thetcr prom ser || es _4nel store i+ inte Ctheta) variable. aes V calculate new valies For wt,ut,x2,y2. || fe. 1 ar cosC theta) — 44 * Sin Ctheta)j a ee 2 sin Cnet) ty * Cos Ctheta))j | | ee RD KK CE theta) 2 * @ 51 Ctheta); | ———— ares Aly), 22,42, thera / | _____/ Accep} value fa ue Or | _|__maax = getmaxxC);_maxy= getmaxy (9 : | Myde= maxx/ei onidy= cnaxy/2j Ty ee a midy-lo0, midet6o,midy85,); | ~-/ Recep Ratahion_angle From user eel / —| calculate mew values For 4422 ,y2 | Bie 2z\ * Cos(thera)—y! & SinC-fhetadi Yee 1 Sin(theta)-+yl * CosC thetas Ris 42K cos(thela) —42 4 Sin Ctheka) Daw Shape after rotation. barad Cenide +x 1, midy ~41, mide +x eee ese mihi 2) 51) 1 | bat ad Cmide tao midy ~ zl mide € 46 mdy 295) Les pro ae clyeers) sp T z L__Stpve _fntn_theta_- eZ =u 4 A ## include # Padude < cenio-h i in ude Y graphics -h>_ include eters hye ie “Start Sees 2. Rend 9 end points of line ax pLGeL. yd aod | eee PoG2e2, yo) a ee 8. Read 2 Corner points of the Alipoing ea Window as Cwxl, wy) and Cwr2, wy2) of ae 4 AsSign__the region codes for __2_end_ points eli d Po using following steps- code with dOo00 ieee eeesc ieee hit gant Pena ne oe we eee ost ira’ fP Oy Wy Step 6+ checls "vistbilty of Irene Pleas _ a) if eqion codes _for_bath end petals Py rE _Drao line and go to _step a - b) If _vegian__codes-_foY __both end. and P2_ ave not 0 and of them fs also not ero => ae | eh vide Partially visible It +__step for bot) Sub divided line _Segm 4ntil__you__g ek _compl amp lerely — invisible line Seqments- DATE: fT Flovochart 3 a Read end points of a line Pic: / an, 2 I [ Cie, wus) 4 CWxo, ply2) Lasssiga region code._fox Pi ¥ p2| iF False pS Te forges mat) au stip ang Be BI a _—| ae (Set Bit Si Se wy aa Mn a Gade Pye region > TE See za - 2 Gmnplelely vis ble — Partially visible llrne Completely visivie [Mine Partially visible Pivide line fate foo equol parts # Perform above steps for each divided tine DATE: Ht {nclude <6tdia-h> # fnelude pena be # Include < stdlib-hy @ ee epic b> ee ole a inf ey 5 es chax code [a]; void Boscia Poe PT PZ sae Sa fo+_visfbijity Cet P, , pT p2di : 4 @ PT, vesetendpt CPT pi >—-Pl_22)j3 eee voids middub CPT Pi, 1 Pad; ae Che Bae | ee 9 print C" ENTER END -PoLNT 1 Gey) #72) | | SeanF C" fel fod”, & Pix & ply di = If prin NTER NO- PolNT Ceiy): 9? imce a 2d" 3 fei eee | eardevice (Di x PAGE NO.! DATE: 1 1 i draw window C5 getch C)5 getch CDi Clear device C5 i an —mid sub CP!, p295 —— getch (5 . ani o | “dose graph 693 a eo ao 2 Fur no (o)j 4 a | Void _midsub (pT pl, PT p2) Eade, ES fot v5 a pl= Getrode Cpi)s erie papas 5 2 = ‘ade (p2di_ ra i" Ee Ve vistbih'ty Cpl, p2i a Switch Cv) . i ie ae case o eantelcoaas break; _ me casel : break; dl si Quito 8 mid ce = Piet (pr-p-pl.2)/23 mid- Y= Ply +Ce2 -4 —Pl.y)/2s MidsubCp midds ao mid-% = mid: 2 +1; brealx;_ Ff 3 z Setcalox CREDII line (150, |e 0, 450, foo); ° ine C450, loo, 450, 400); ine C450, 4o0, 150, Goods i" 50,400, 190, lao)) =e 4 iia us id _dvasli'ine CPT pl PT p2) ze ‘ aoe tine Cpl. .2 “ply sp2-m, p2-y)i aa ay ee s a PT Gekcade CPT p? Sh iacaead : ca a sebasal a iesh 2 td plemp. cade Col = ae _ptemp: Code(e] = ‘a’; nee y y= 4oo) ptemp. code CiJ= '1' 5 " else | Ptemp - wcode (1 = if Cpx > = 450) ptemp- code [2] = ‘I’ else ptemp. code(2] i¢ Cp.x ~= |50) ptemp: code [a] A ptemp +y = P-yy rae eer Int visibility CeT pl. PT p2) 3 é fnt i, Flag = 05 z Pox Ci=os f<4; ith) el {PCC pl- code CiJt =o’) IL _(@2-tode Ct Jl=‘o’ YD Flag _=15 = fe Flag = £0) os ane return Co); for tzo7 144i ity) Z om nse fe(C pi-codeCiJ= =p2-codefJ) §¥% a CPi-code CiJ=a'l?)) (ii fie celanieeD Yeturn 115 Yeurn @); PAGE NO. DATE: 1 SelOGeemaa ° eo Sol”. Po = (So, 10) R = 10 w2250, yy y= 20 Yy2=]0 res [ce tx py / eG fea m= Item 20 to) /2 . Go, 15) C- | Compare cohen Sutherland _$ rid point ____| |_ subdivistan Iine cli'pping _algaxithm ——________}— ) Cohen Sutherland: The _g divisions From) — | the twa dimensional space makes __eFFectvVe | | _detevmination of the areas of intevest. | _ | 2) midpoint Subdivision algorithm + An_altevation of cys beck algorithm that _useS the pnidpaint | of the lines to effectively folentify the areas | of I[nterest._ i : z Difference: t 1) The midpoint Subdivision_algonithon does pat Z |_ require any Floating point operation to determine || the point of jantersection. | 2) This reduces the complexity of the algonitha || _£ hence ftacreases the speed nf the algorithm. | |) The accuracy fx also highes in midpoint Subdi= | __uision algorithm when compared to cohen — utherland Algozithm. a an | Waite disadvantages oF midpoi clipping algorithm. | Pidpotat subdivision line clipping algoni | dis advantage dd andl take more time o_chip the line this_is the ‘DATE ree | Outtame + ans [He __Q__pragxann to clip line é je man__Poly goo clipping es) 4 5 ¥ he Co-ordinates of all _yertires_of- polygon -ordjnates of | clipping windows. —_ : 7 e Starting coordinates oF Tectang{elar|_ —_____|5- Compare the vertices of each edge of the polygon) —___|\__individually wi th clapping plane. eee. e |e. Save _the resulting __tnterSechon and vertices _in. the new list of vertices according to four _possibe | —Melation ships between the edge and the clipping, bo AGT: oo ee sy Repeat the Steps 4 and © for remaining dge of the clipping window: time the resultant jist oF yerhices is essively pasted 4o process the next stag of of clippiag uoindow. beth fnpuk vertices faside the polygon clipping window boundary then Second vertex to_output vertex fist. 2) SE fixst vertex iss inside the window) boundary on _a_2°d vertex fs outside then only fater— SecHon wl cola a 0 fo 4) Te 15t vertex is outside tho —poiok oF the poly qon edge = ist. cS ie ard vertex is fnside then both tntersection | a and_20d vertex are added to__output verter || © Pregram cade — ## include ¥6tdilo-h 22s mee # fndude graphics: h> 4 include < math - hy tt fnclude < conto. hz Void ddaC fab, iat, int, int, fat, fak, int): |Void dda Ciat 21, fat 4 5—lot_x2,fot yo. fat emia i tnt__yon'a, fat maa, tat ymax) Flak de, dyi float Steps, *=21, yey si fat j=oj { ele oer le) are PAGE NO.: DATE: J nig = ) Steps = abs Cdz)s eise Steps = abs Cdy)5 dvs de/ steps i dy = dy / steps: lohiie Citt? = sheps) 2 iECx >= x maxin $2 2 <=xmax 8% y 24min 42% y v= ymax) ine Ce, 4,22, 4y2)i = “erurn 0 ; & eS eee | 4s Ytdy; z | i 4 f ee : Mendeecnotoat ess es ee : a : i Int mgd gm, rei, 282, 4! al x ace eee ne la bs, b4 1, b, ymin, ymax ee Float mm _;_ citer Ghee (eepapaay Flag =o gd= DETECT; gma DETECT: Inttgvaph C$ gm,4gd,"c.\TC\ gi!) 5 pnlatf C" Enter the ane breadth of clipping window :\n")3 ES fec t ia PAGE NO.! DATE: 1 ation [2 240i] fo] Pai esiletari 1 prec, % Rect l, yRectb) Baril ated. aca CoLepeineias es xmin | “28 Ky <= | ee kmax 44 112 =%min- YW2=Nens) i<= Ymax) eee a Xe } FEC e2>=Xmcin 29 22 vs max + =Ymin & Y2<= Ymox? _ wets Flag +t: — gush i ee | vertex list . nw ji 7 i hi |then won'te hich point axe_addecl to eutput | 50l%7| Both the fatersechon _poiat of the polygon edge gp tcitta_slndoud _houndarn}_and_second_vertsA_aze | added +o output vertex lish ___2)|_ Waife the _prvedureto- al gt Salty Refer Algonithen Male i coi | SahP-y! Vertex | case | of P £2, a List at Z : Mi-V2_ | case 3 = ie ' V2 -Vg— | case2 | 11 - Va v4 |CaSe4 | Vg,T V4 -V5 | case2 | Ta t T IL Ms -Vt\ cases | TaV5 | - + “! APter clippting eS

You might also like