I0/I60 omper Grphics Eminion April 6 0 4:00 7:00 This eminion consis of for qesions wih in ol 6 sqesion. Ech sqesion weighs eqll. In ll cses: EXPLAIN YOUR ANSWER. Use skeches where needed o clrif or nswer. Red firs ll qesions compleel. If n lgorihm is sked hen descripion in seps or psedo-code is epeced which is cler enogh o e esil rnsferred o rel code. Aim compcness nd clri. Use ddiionl fncions nd procedres if desired. Gie from ech fncion nd procedre shor descripion of inp nd op. The se of he ook copies of slides noes nd oher meril is no llowed. We consider some sic echniqes for comper grphics. Wh is iewpor in comper grphics erminolog? A iewpor is region of he screen h is sed for showing grphics op picll recnglr re. Gie crierion o disingish cone nd conce polgons. Some chrcerisics of cone polgon re h: - All inerior ngles re < 80 degrees; - All line segmens eween wo inerior poins re compleel inside he polgon; - Gien line hrogh n edge ll poins of he polgon re eiher on his line or on he sme side of he line; - rom ech inerior poin he complee ondr is isile. These do no hold for conce polgons nd cn hence e sed o disingish eween hem. c In he simples model for rnsprenc he color I srfce of he srfce nd he color I ck of he ckgrond re lended ino perceied color I. Gie forml for I ssming rnsprenc coefficien α in he rnge from 0 opqe o fll rnspren. In he simples model I srfce nd I ck nd re weighed wih α nd α nd dded p i.e. I α I srfce α I ck. I is es o mi p opci nd rnsprenc. To check ssie α 0 opqe which gies I I srfce hence we see he srfce which is correc. Also α fll rnspren gies I I ck hence we see he onl he ckgrond which is correc gin. inll if I srfce I ck we ge I α α hence if srfce nd ckgrond he he sme color rnsprenc does no mer nmore. d Wh is he difference in he compion of ligh inensiies eween Phong shding nd Gord shding? In Gord shding colors of erices re inerpoled oer polgons in Phong shding normls of erices re inerpoled followed shding clclion.
We consider pr of hperolic srfce descried wih. nd Gie prmeric descripion S nd n implici descripion 0 of his srfce. We ke nd nd ge. Hence. S or he implici eqion we rewrie he gien eqion o ge 0 hence. Derie forml for norml ecor for poin on his srfce eiher sing prmeric or n implici descripion. Using he prmeric descripion we ge:. 0 0 S S N Using he implici eqion we ge:. N c lcle ll inersecion poins of line P wih his srfce wih P P P P nd. A picl r-rcing sk. irs noe h P. Ne we clcle for which les of we find inersecions wih he infinie srfce. Ssiion of P ino he eqion gies. We rewrie his o ge qdric eqion in : 0. or nd Se c If D 4c < 0 hen here re no inersecions. If D > 0 we ge wo les for sing he wellknown c forml:. 4 c ± If D 0 nd 0 here is single inersecion for / proided h 0. The cse D0 nd 0 cn occr for insnce for 0 0 0 nd 0. Sch line lies compleel in he nonded srfce. If we find one or wo inersecion poins he finl sep is o check wheher he poins P i re loced wihin he gien poins i.e. he condiions nd i i ms e me.
d Gie procedre o drw his srfce ssming procedre DrwTringleA B is ille. or insnce: N 0; // nmer of seps per side d.0/n; // sepsie fncion Pni j: poin; // rerns poin on he srfce specified indices i nd j 0...N egin Pn. i*d; Pn. j*d; Pn. i*i j*j*d*d; procedre DrwSrfce; egin for i 0 o N do for j 0 o N do egin P00 Pni j; // lcle poins of qd P0 Pni j; P0 Pni j; P Pni j; DrwTringleP00 P0 P; // Drw he qd wih wo ringles DrwTringleP00 P P0; Mn lernies re possile for insnce soring nd resing poins. We wn o drw n rc s shown in he figre. The rc srs in poin A 0 psses hrogh poin B 0 nd ends in poin 0. A poin A nd he rc is perpendiclr o he -is poin B he rc is perpendiclr o he -is. We wn o define he cre prmericll s P wih [0 ]. We eplore differen opions o define his rc. Indice for ech opion if i is possile o define n rc h mees he reqiremens nd if no eplin wh no; if es eplin how his cn e done nd define P ecl. We consider: Use of n ellipse scled circle; This is possile: P cosπ sinπ. Use of cre sed on cic fncion 0 ; This is no possile. A poin A nd he ngen o he cre is ericl nd his implies h he derie of is infinie. c Use of single qdric Béier segmen P P0 P P ; nd Agin no possile. A cre h srs A nd ends cn e oined choosing P 0 0 nd P 0. To oin ericl ngens hese poins we ge P p nd P p. These cnno e sisfied simlneosl. Or eqilenl P ms e loced he crossing of he ngen lines A nd B nd if hese lines re prllel sch poin cnno e fond. d Use of single cic Béier segmen P P0 P P P.
This is possile. A cre h srs A nd ends cn e oined choosing P 0 0 nd P 0. To oin ericl ngens hese poins nd iming smmeric rc we se P p nd P p where p is consn o e deermined. Hlfw he rc shold cross he -is wih i.e. P /. Ssiion of he les picked for he conrol-poins gies P / P 0 /8 P /8 P /8 P /8 p/4. Hence if we choose p 4/ we oin cic Béier segmen h mees he reqiremens. B A 4 We im o drw he figre shown. In he cener is sqre S 0 cenered on he origin wih sie. The sqre S hs sie < is lower lef corner coincides wih he pper lef corner of S 0 nd S is roed oer α degrees. This pern is repeed he sie of sqre S i is imes he sie of sqre S i. On op of he oher edges sqres re posiioned similrl. We se homogenos rnsformion mri M sch h posiion A in glol coordines is reled o posiion B in locl coordines i AMB. I m e ssmed h T gies rnslion mri long he ecor ; h Rϕ gies roion mri of ϕ degrees rond he origin; nd h Ss gies niform scling mri wih scle fcor s. The roine DrwSqre drws sqre in he locl coordine frme h is implicil defined he mri M. In hese α S 0 locl coordines he sqre h is drwn hs sie nd is cenered on he origin. S Se M sch h cll o DrwSqre drws S ecl ccording o he specificion gien nd he figre. We cn rnsform S 0 o S sing he following seps sing glol rnsformions: T : Moe he sqre sch h he lower lef corner is in he origin; Rα: Roe he sqre rond he origin oer α degrees; S: Scle he sqre wih fcor ; 4 T : Moe he lower lef corner he origin o he pper lef corner of he originl sqre. Using locl rnsformions we ge: 4
T : Moe he cener of he sqre o he pper righ corner; S: Scle he sqre wih fcor ; Rα: Roe he sqre rond is origin oer α degrees; 4 T : Moe he sqre sch h is lower lef corner moed o is origin. Noe h onl he order is reersed he rnsformions re he sme. rhermore he roion nd scling cn e inerchnged. Bsed on hese rnsformions we ge M T S RαT. Sppose M hs een se sch h S i hs js een drwn wih cll DrwSqre. Upde M o drw S i wih e noher cll o DrwSqre. Ech ime new sqre is dded he sme rnsformion is pplied gin. This cn e seen if we consider S i nd check which rnsformions re needed in locl coordines o ge S i. Hence: M M T S RαT. B lso M T S RαT M. gies he desired resl. In generl he rnsformion M i for S i is gien M i T S RαT i c I is desired h sqre S n hs sie p nd is roed oer β degrees in ol. How o se nd α o ge his effec? The ol roion ms e eql o β he figre shows h his is eql o nα. Hence α β / n. The sie ms e eql o p repeed scling gies sie eql o n. Hence p/ /n. d Gie procedre o drw he complee figre inclding ll for rms where ech rm consiss of n sqres. or insnce: procedre Drwigren; egin M I; // se M o he ideni mri DrwSqre; // drw S 0 P T SRαT ; // lcle nd sore he sic rnsformion sep for i o n do // for ll leels egin M MP; // dp he rnsformion for he ne leel sqres for j o 4 do // for ll rms egin DrwSqre; // drw sqre M R90M; // ppl glol roion o shif o he ne rm // Noe: fer for roions oer 90 degrees M is ck o is sring posiion Alerniel he loops for leels nd rms cn e inerchnged for insnce: 5
procedre Drwigren; egin M I; // se M o he ideni mri DrwSqre; // drw S 0 P T SRαT ; // lcle nd sore he sic rnsformion sep for i 0 o do // for ll rms egin M Ri*90; // se M o roion of 0 90 80 70 degrees for j o n do // for ll leels egin M MP; // dp he rnsformion for he ne leel sqre DrwSqre; // drw sqre 6