Compue Gaphic wih Maices Mah 38A Pojec Suden: Wei-Liang Chen Suden #: 3292 Dae: Dec 3 d, 2 Pofesso: James King
Imagine ha ou ae dawing a picue b hand o compue. The picue we daw b compue ae called compue gaphic. Compue gaphic can divide ino 2 dimensional (2-D) and 3 dimensional (3-D). 2-D gaphic is usuall like anime, comic, o an kind of dawing ha is on a pape. The games we see nowadas ae usuall 3-D, jus like Diablo II o Baldu s Gae. The diffeence beween 2-D and 3-D ae 2-D is fla and 3-D is like solid, so as ou look ove hem b a camea. 2-D gaphic will jus be he same; if he gaphic is he fon of he peson, ou won able o see his back. Howeve, in a 3-D gaphic, ou can move he camea aound. You will be able o see he peson s back if ou move camea behind ha peson. You can even see fom he op o he boom of he peson. Fo hee, I am going o alk abou he mai elaes o he 3-D compue gaphic, bu i will also include some deail abou 2-D gaphic oo. As we daw o look a 3-D gaphic, he sucue includes fou basic hings: polgon, poine, vee and edge. The elaionship of hese fou is show as he able below: Polgon lis edges p: e e2 e3 p2: e3 e4 e5 Edge Lis Polgons veices e: p v v4 e2: p 2 e3: p p2 v2 v4 e4: p2 v2 v3 e5: p2 v3 v4 Vee lis coodinaes v: v2: 2 2 2 v3: 3 3 3 v4: 4 4 4 I migh ake some ime o undesand wha his able means is, bu wha i means hee is polgons ae he poines of he edge lis and poines ae held in clockwise ode fom he fon. Fo he conaining polgons and veices, edges ae hei poines. Each edge is also in he liss fo wo polgons. Fo vee, he can onl be keep once fo hei coodinaes. Wih all hese, i means we ae able o move he gaph
easil, which means we ae able o change veices, edge and polgons as we wan o. In a 3-D gaph, even we have he sucue of he hing we need o daw, we sill need o do somehing we called ansfomaions o make ou 3-D model ino he final desinaion. In ode o make he 3-D model ino ou final desinaion, hee ae hee pas o do. Fis is o scale he objec ino he coec sie, second is oae i o he coec oienaion, hen he las is o anslae o he final desinaion. This is whee 2-D o 3-D gaphic involves in mai. You migh hink ha 2-D gaph used 22 maices and 3-D gaph used 33 maices. If ou hink of his, hen ou ae oall wong. 2-D gaph acuall used 33 maices and 3-D gaph used 44 maices. The eason is we need he ea mai o epesen 2-D o 3-D anslaion, scaling and oaion. This soluion o heo ha is used in ansfomaion is called homogeneous coodinaes. Scaling in 3-D: Assume we have a mai fo scaling s in diecion. s / s s / s S s The invese iss. / s This is how we did scaling as long as he ss in he mai is no eo. When one of s in he mai is eo, his means he dimension of his objec is lowe. Roaion in 3-D: Remembe we have leaned he oaion in 2-D befoe in he class. Howeve, 3-D oaion is much hade because we have anohe ais. Le s ecall he oaion cosθ mai fo 2-D, which is. This mai woks well on 2-D bu also cosθ 3-D. Jus he oaion on 2-D is b poin and 3-D is b ais. The had hing when ou oae in 3-D is o deemine which side is posiive o negaive. Hee ae hee was o deemine he posiive o negaive on a 3-D objec:
Lef handed Righ handed I am no eall sue abou he fis wa. I have asked m fiend who woks on compue gaphic. He also has no idea abou i. Second one will a bi confused unless ou eall wih ou lef hand. The mos popula one ha is used b people was he igh handed ule. I is also eas ecogniable if ou look a a 3-D pefec squae oo. Hee is anohe lis of wha s he diecion of posiive when ou oae he ais ou need: Roaion ais Diecion of posiive oaion fom owads fom owads fom owads This able gives people a clea mind which wa is posiive and negaive. Wih his diecion able, we wee able o find he oaional mai fo each ais. The maices fo hese hee main aes ae: cosθ R cosθ R cosθ cosθ cosθ cosθ R. These hee maices ae used on he oaion when hee is a poin on he ais and he
angle i oaes. Hee is an eample of how hese maices wok. Eample: Le P (,, ) in a igh-handed ssem. Appl a oaion abou he -ais of +9 o. cos sin sin cos θ θ θ θ R M We go he mai, and hen we ae able o ge he homogenous fom: ( ) ( ) PM. So he poin P afe oaion will be (-,, ). Tanslaion in 3-D: Some of ou mus wonde wh he fouh ow is alwas eo ecep he las one is. This ow is used fo anslaion. If said we wan o anslae b (,, ), he mai we ae calculaing will be T. The poin will be ansfom as ( ) ( ) T + + + Now ou can acuall see he elaionship beween scaling, oaion and anslaion. We can combine hem and fom a new mai: 33 32 3 23 22 2 3 2.
The s in he mai ae used in scaling and oaion, and s ae used fo anslaion. Nomall, scale is se o one so he values will jus be pue oaion, no need o wo abou he scaling. As I menion befoe, he modeling pocess is scale, oae and hen anslae. I can also do in he backwad wa fo ohe siuaion. In he siuaion of viewing, he pocess is anslaed, oae hen scale. This siuaion onl woks on viewing because we ae acuall moving he viewe hee, so he viewe s diecion is acuall opposie he objec s diecion. Roaion abou Abia Aes: This is he las pocess afe ou done modeling he objec, wha happened if he objec ou model is no on he -ais ou wan o pu on? The las hing we do hee is oae he objec abou Abia aes. The sep fo oaing model in abia ae is acuall jus like ansfomaion, bu we don need scaling hee. All we need is anslaion and oaion. Fis, we anslae he model so i passes hough he oigin. Then we oae i so i will lie on he ais ou wan, assume -ais. This pocess can also be evese if ou wan o find he oiginal sae of he modeling. Below is a picue of a sho summa of oaion abou abia aes: All of hese ansfomaion, oaion, anslaion, scaling ae all how mai applies on compue gaphic. Abia aes someime can also give nas answe due o he pocess ou need o calculae can esul a mai ha looks nas. I is bee ou o avoid his kind of siuaion b no using his oaion much.
Hee is an eample which will make eveone clea up on wha I efe in his pojec. This eamples show he calculaion of ansfomaion and oaion of 2D. (This eample is aken ou fom he souce I used o wie up his pojec) Eample: Find he 33 mai ha coesponds o he composie ansfomaion of a scaling b 3, a oaion b 9 o, and finall a anslaion ha adds (-5, 2) o each poin of a figue. Soluion: If φ π/2, hen sinφ, and cosφ..3.3 Scale.3.3 Roae.3.3 2.5 Tanslae The mai fo he composie ansfomaion is 2.3.5.3.3.3 2.5.3.3 2.5 This is he calculaion, hopefull ou can ge i. If ou ae no familia wih 3-D calculaion, eample 7 fom e book Linea Algeba and Is Applicaions in secion 2.8 will be a good one o look a i, I hope he hing I eplain hee does make people undesand he elaionship beween mai and compue gaphic. And I hope his can also help ou undesand moe abou he mai we ae leaning in he class now. Bibliogaph:
# Souce: www.bah.ac.uk/~maspjw/ch3-suf-models.pdf, pages. #2 Souce: Linea Algeba And Is Applicaions, David C. La, Secion 2.8 (Applicaions o Compue Gaphics), epined wih coecion, Apil 2.