You are on page 1of 39

# DAR ES SALAAM INSTITUTE OF TECHNOLOGY

## DEPARTMENT OF COMPUTER STUDIES

COMPUTER GRAPHICS

BY KONDELA EMMANUEL

1. INTRODUCTION Computer graph !" " the u"e o# !omputer to \$e# %e& "tore& ma% pu'ate& %terrogate& a%\$ pre"e%t p !tor a' output( A'though !omputer graph !" " a )a"t # e'\$ that e%!ompa""e" a'mo"t a%* graph !a' a"pe!t& +e are ma %'* %tere"te\$ % the ge%erat o% o# mage" o# ,D-\$ me%" o%a' "!e%e"( Computer mager* ha" app' !at o%" #or # 'm "pe! a' e##e!t"& " mu'at o% a%\$ tra % %g& game"& me\$ !a' mager*& #'* %g 'ogo"& et!( Computer Graph !" re' e" o% a% %ter%a' mo\$e' o# the "!e%e& that "& a mathemat !a' repre"e%tat o% "u ta.'e #or graph !a' !omputat o%"( The mo\$e' \$e"!r .e" the ,D "hape"& 'a*out a%\$ mater a'" o# the "!e%e( Th " ,D repre"e%tat o% the% ha" to .e pro/e!te\$ to !ompute a 0D mage #rom a g )e% ) e+po %t& th " " the re%\$er %g "tep( Re%\$er %g %)o')e" pro/e!t %g the o./e!t" 1per"pe!t )e2& ha%\$' %g ) " . ' t* 1+h !h part" o# o./e!t" are h \$\$e%2 a%\$ !omput %g the r appeara%!e a%\$ ' ght %g %tera!t o%"( F %a''*& #or a% mate\$ "e3ue%!e& the mot o% o# o./e!t" ha" to .e "pe! # e\$( 4e + '' \$ "!u"" a% mat o% % th " \$o!ume%t( Applications: A% mat o%"

E%terta %me%t

Histor :

Intro!"ction to Op#nGL: Ope%GL " a "o#t+are %ter#a!e to graph !" har\$+are( Th " %ter#a!e !o%" "t" o# a.out 567 \$ "t %!t !omma%\$" that *ou u"e to "pe! #* the o./e!t" a%\$ operat o%" %ee\$e\$ to pro\$u!e %tera!t )e three\$ me%" o%a' app' !at o%"( Ope%GL " \$e" g%e\$ a" a "tream' %e\$& har\$+are- %\$epe%\$e%t %ter#a!e to .e mp'eme%te\$ o% ma%* \$ ##ere%t har\$+are p'at#orm"( To a!h e)e the"e 3ua' t e"& %o !omma%\$" #or per#orm %g + %\$o+ %g ta"8" or o.ta % %g u"er %put are %!'u\$e\$ % Ope%GL9 %"tea\$& *ou mu"t +or8 through +hate)er + %\$o+ %g "*"tem !o%tro'" the part !u'ar har\$+are *ou:re u" %g( S m 'ar'*& Ope%GL \$oe"%:t pro) \$e h gh-'e)e' !omma%\$" #or \$e"!r . %g mo\$e'" o# three-\$ me%" o%a' o./e!t"( Su!h !omma%\$" m ght a''o+ *ou to "pe! #* re'at )e'* !omp' !ate\$ "hape" "u!h a" automo. 'e"& part" o# the .o\$*& a rp'a%e"& or mo'e!u'e"( 4 th Ope%GL& *ou mu"t .u '\$ up *our \$e" re\$ mo\$e' #rom a "ma'' "et o# geometr ! pr m t )e" - po %t"& ' %e"& a%\$ po'*go%"( A S\$i!%#n o& Op#nGL Co!# Be!au"e *ou !a% \$o "o ma%* th %g" + th the Ope%GL graph !" "*"tem& a% Ope%GL program !a% .e !omp' !ate\$( Ho+e)er& the .a" ! "tru!ture o# a u"e#u' program !a% .e " mp'e; It" ta"8" are to % t a' <e !erta % "tate" that !o%tro' ho+ Ope%GL re%\$er" a%\$ to "pe! #* o./e!t" to .e re%\$ere\$( Be#ore *ou 'oo8 at "ome Ope%GL !o\$e& 'et:" go o)er a #e+ term"( Re%\$er %g& +h !h *ou:)e a'rea\$* "ee% u"e\$& " the pro!e"" .* +h !h a !omputer !reate" mage" #rom mo\$e'"( The"e mo\$e'"& or o./e!t"& are !o%"tru!te\$ #rom geometr ! pr m t )e" - po %t"& ' %e"& a%\$ po'*go%" - that are "pe! # e\$ .* the r )ert !e"( The # %a' re%\$ere\$ mage !o%" "t" o# p =e'" \$ra+% o% the "!ree%9 a p =e' " the "ma''e"t ) " .'e e'eme%t the \$ "p'a* har\$+are !a% put o% the "!ree%( I%#ormat o% a.out the p =e'" 1#or %"ta%!e& +hat !o'or the*:re "uppo"e\$ to .e2 " orga% <e\$ % memor* %to . tp'a%e"( A . tp'a%e " a% area o# memor* that ho'\$" o%e . t o# %#ormat o% #or e)er* p =e' o% the "!ree%9 the . t m ght %\$ !ate ho+ re\$ a part !u'ar p =e' " "uppo"e\$ to .e& #or e=amp'e( The . tp'a%e" are them"e')e" orga% <e\$ %to a #rame.u##er& +h !h ho'\$" a'' the %#ormat o% that the graph !" \$ "p'a* %ee\$" to !o%tro' the !o'or a%\$ %te%" t* o# a'' the p =e'" o% the "!ree%( No+ 'oo8 at +hat a% Ope%GL program m ght 'oo8 ' 8e( Re%\$er" a +h te re!ta%g'e o% a .'a!8 .a!8grou%\$& a" "ho+% .e'o+(

## Chu%8 o# Ope%GL Co\$e #include <whateverYouNeed.h>

main() { InitializeAWindowPlease() !l"lear"olor (#.#\$ #.#\$ #.#\$ #.#) !l"lear (%&'"(&()'*+,,-)'*I.) !l"olor/0 (1.#\$ 1.#\$ 1.#) !l(rtho(#.#\$ 1.#\$ #.#\$ 1.#\$ 21.#\$ 1.#) !l*e!in(%&'P(&Y%(N) !l3erte4/0 (#.56\$ #.56\$ #.#) !l3erte4/0 (#.76\$ #.56\$ #.#) !l3erte4/0 (#.76\$ #.76\$ #.#) !l3erte4/0 (#.56\$ #.76\$ #.#) !l-nd() !l,lush() +8date.heWindowAnd"hec9,or-vents() : The # r"t ' %e o# the ma %12 rout %e % t a' <e" a + %\$o+ o% the "!ree%; The I% t a' <eA4 %\$o+P'ea"e12 rout %e " mea%t a" a p'a!eho'\$er #or + %\$o+ "*"tem-"pe! # ! rout %e"& +h !h are ge%era''* %ot Ope%GL !a''"( The %e=t t+o ' %e" are Ope%GL !omma%\$" that !'ear the + %\$o+ to .'a!8; g'C'earCo'or12 e"ta.' "he" +hat !o'or the + %\$o+ + '' .e !'eare\$ to& a%\$ g'C'ear12 a!tua''* !'ear" the + %\$o+( O%!e the !'ear %g !o'or " "et& the + %\$o+ " !'eare\$ to that !o'or +he%e)er g'C'ear12 " !a''e\$( Th " !'ear %g !o'or !a% .e !ha%ge\$ + th a%other !a'' to g'C'earCo'or12( S m 'ar'*& the g'Co'or,#12 !omma%\$ e"ta.' "he" +hat !o'or to u"e #or \$ra+ %g o./e!t" - % th " !a"e& the !o'or " +h te( A'' o./e!t" \$ra+% a#ter th " po %t u"e th " !o'or& u%t ' t:" !ha%ge\$ + th a%other !a'' to "et the !o'or( The %e=t Ope%GL !omma%\$ u"e\$ % the program& g'Ortho12& "pe! # e" the !oor\$ %ate "*"tem Ope%GL a""ume" a" t \$ra+" the # %a' mage a%\$ ho+ the mage get" mappe\$ to the "!ree%( The %e=t !a''"& +h !h are .ra!8ete\$ .* g'Beg %12 a%\$ g'E%\$12& \$e# %e the o./e!t to .e \$ra+% - % th " e=amp'e& a po'*go% + th #our )ert !e"( The po'*go%:" >!or%er"> are \$e# %e\$ .* the g'?erte=,#12 !omma%\$"( A" *ou m ght .e a.'e to gue"" #rom the argume%t"& +h !h are 1=& *& <2 !oor\$ %ate"& the po'*go% " a re!ta%g'e o% the <@7 p'a%e( F %a''*& g'F'u"h12 e%"ure" that the \$ra+ %g !omma%\$" are a!tua''* e=e!ute\$ rather tha% "tore\$ % a .u##er a+a t %g a\$\$ t o%a' Ope%GL !omma%\$"( The Up\$ateThe4 %\$o+A%\$Che!8ForE)e%t"12 p'a!eho'\$er rout %e ma%age" the !o%te%t" o# the + %\$o+ a%\$ .eg %" e)e%t pro!e"" %g( A!tua''*& th " p e!e o# Ope%GL !o\$e "%:t +e'' "tru!ture\$( You ma* .e a"8 %g& >4hat happe%" # I tr* to mo)e or re" <e the + %\$o+A> Or& >Do I %ee\$ to re"et the !oor\$ %ate "*"tem ea!h t me I \$ra+ the re!ta%g'eA> Later % th " !hapter& *ou + '' "ee rep'a!eme%t" #or .oth I% t a' <eA4 %\$o+P'ea"e12 a%\$ Up\$ateThe4 %\$o+A%\$Che!8ForE)e%t"12 that a!tua''* +or8 .ut + '' re3u re re"tru!tur %g the !o\$e to ma8e t e## ! e%t( Op#nGL R#n!#rin% 'ip#lin#s Mo"t mp'eme%tat o%" o# Ope%GL ha)e a " m 'ar or\$er o# operat o%"& a "er e" o# pro!e"" %g "tage" !a''e\$ the Ope%GL re%\$er %g p pe' %e( Th " or\$er %g& a" "ho+% % .e'o+& " %ot a "tr !t ru'e o# ho+ Ope%GL " mp'eme%te\$ .ut pro) \$e" a re' a.'e gu \$e #or pre\$ !t %g +hat Ope%GL + '' \$o( I# *ou are %e+ to three-\$ me%" o%a' graph !"& the up!om %g \$e"!r pt o% ma* "eem ' 8e \$r %8 %g +ater out o# a # re ho"e( The #o''o+ %g \$ agram "ho+" the He%r* For\$ a""em.'* ' %e approa!h& +h !h Ope%GL ta8e" to

pro!e"" %g \$ata( Geometr ! \$ata 1)ert !e"& ' %e"& a%\$ po'*go%"2 #o''o+ the path through the ro+ o# .o=e" hat %!'u\$e" e)a'uator" a%\$ per-)erte= operat o%"& +h 'e p =e' \$ata 1p =e'"& mage"& a%\$ . tmap"2 are treate\$ \$ ##ere%t'* #or part o# the pro!e""( Both t*pe" o# \$ata u%\$ergo the "ame # %a' "tep" 1ra"ter <at o% a%\$ per-#ragme%t operat o%"2 .e#ore the # %a' p =e' \$ata " +r tte% %to the #rame.u##er(

No+ *ou:'' "ee more \$eta ' a.out the 8e* "tage" % the Ope%GL re%\$er %g p pe' %e( D "p'a* L "t" A'' \$ata& +hether t \$e"!r .e" geometr* or p =e'"& !a% .e "a)e\$ % a \$ "p'a* ' "t #or !urre%t or 'ater u"e( 1The a'ter%at )e to reta % %g \$ata % a \$ "p'a* ' "t " pro!e"" %g the \$ata mme\$ ate'* - a'"o 8%o+% a" mme\$ ate mo\$e(2 4he% a \$ "p'a* ' "t " e=e!ute\$& the reta %e\$ \$ata " "e%t #rom the \$ "p'a* ' "t /u"t a" # t +ere "e%t .* the app' !at o% % mme\$ ate mo\$e( 2 E)a'uator" A'' geometr ! pr m t )e" are e)e%tua''* \$e"!r .e\$ .* )ert !e"( Parametr ! !ur)e" a%\$ "ur#a!e" ma* .e % t a''* \$e"!r .e\$ .* !o%tro' po %t" a%\$ po'*%om a' #u%!t o%" !a''e\$ .a" " #u%!t o%"( E)a'uator" pro) \$e a metho\$ to \$er )e the )ert !e" u"e\$ to repre"e%t the "ur#a!e #rom the !o%tro' po %t"( The metho\$ " a po'*%om a' mapp %g& +h !h !a% pro\$u!e "ur#a!e %orma'& te=ture !oor\$ %ate"& !o'or"& a%\$ "pat a' !oor\$ %ate )a'ue" #rom the !o%tro' po %t"( 1See Chapter 50 to 'ear% more a.out e)a'uator"(2 Per-?erte= Operat o%" For )erte= \$ata& %e=t " the >per-)erte= operat o%"> "tage& +h !h !o%)ert" the )ert !e" %to pr m t )e"( Some )erte= \$ata 1#or e=amp'e& "pat a' !oor\$ %ate"2 are tra%"#orme\$ .* B = B #'oat %g-po %t matr !e"( Spat a' !oor\$ %ate" are pro/e!te\$ #rom a po" t o% % the ,D +or'\$ to a po" t o% o% *our "!ree%( I# a\$)a%!e\$ #eature" are e%a.'e\$& th " "tage " e)e% .u" er( I# te=tur %g " u"e\$& te=ture !oor\$ %ate" ma* .e ge%erate\$ a%\$ tra%"#orme\$ here( I# ' ght %g " e%a.'e\$& the ' ght %g !a'!u'at o%" are per#orme\$ u" %g the tra%"#orme\$ )erte=& "ur#a!e %orma'& ' ght "our!e po" t o%& mater a' propert e"& a%\$ other ' ght %g %#ormat o% to pro\$u!e a !o'or )a'ue( Pr m t )e A""em.'* C' pp %g& a ma/or part o# pr m t )e a""em.'*& " the e' m %at o% o# port o%" o# geometr* +h !h #a'' out" \$e a ha'#-"pa!e& \$e# %e\$ .* a p'a%e( Po %t !' pp %g " mp'* pa""e" or re/e!t" )ert !e"9 ' %e or po'*go% !' pp %g !a% a\$\$ a\$\$ t o%a' )ert !e" \$epe%\$ %g upo% ho+ the ' %e or po'*go% " !' ppe\$( I% "ome !a"e"& th " " #o''o+e\$ .* per"pe!t )e \$ ) " o%& +h !h ma8e" \$ "ta%t geometr ! o./e!t" appear "ma''er tha% !'o"er o./e!t"( The% ) e+port a%\$ \$epth 1< !oor\$ %ate2 operat o%" are app' e\$( I# !u'' %g "

e%a.'e\$ a%\$ the pr m t )e " a po'*go%& t the% ma* .e re/e!te\$ .* a !u'' %g te"t( Depe%\$ %g upo% the po'*go% mo\$e& a po'*go% ma* .e \$ra+% a" po %t" or ' %e"( 1See >Po'*go% Deta '"> % Chapter 0(2 The re"u't" o# th " "tage are !omp'ete geometr ! pr m t )e"& +h !h are the tra%"#orme\$ a%\$ !' ppe\$ )ert !e" + th re'ate\$ !o'or& \$epth& a%\$ "omet me" te=ture-!oor\$ %ate )a'ue" a%\$ gu \$e' %e" #or the ra"ter <at o% "tep( P =e' Operat o%" 4h 'e geometr ! \$ata ta8e" o%e path through the Ope%GL re%\$er %g p pe' %e& p =e' \$ata ta8e" a \$ ##ere%t route( P =e'" #rom a% arra* % "*"tem memor* are # r"t u%pa!8e\$ #rom o%e o# a )ar et* o# #ormat" %to the proper %um.er o# !ompo%e%t"( Ne=t the \$ata " "!a'e\$& . a"e\$& a%\$ pro!e""e\$ .* a p =e' map( The re"u't" are !'ampe\$ a%\$ the% e ther +r tte% %to te=ture memor* or "e%t to the ra"ter <at o% "tep( I# p =e' \$ata " rea\$ #rom the #rame .u##er& p =e'-tra%"#er operat o%" 1"!a'e& . a"& mapp %g& a%\$ !'amp %g2 are per#orme\$( The% the"e re"u't" are pa!8e\$ %to a% appropr ate #ormat a%\$ retur%e\$ to a% arra* % "*"tem memor*( There are "pe! a' p =e' !op* operat o%" to !op* \$ata % the #rame.u##er to other part" o# the #rame.u##er or to the te=ture memor*( A " %g'e pa"" " ma\$e through the p =e' tra%"#er operat o%" .e#ore the \$ata " +r tte% to the te=ture memor* or .a!8 to the #rame.u##er( Te=ture A""em.'* A% Ope%GL app' !at o% ma* + "h to app'* te=ture mage" o%to geometr ! o./e!t" to ma8e them 'oo8 more rea' "t !( I# "e)era' te=ture mage" are u"e\$& t:" + "e to put them %to te=ture o./e!t" "o that *ou !a% ea" '* "+ t!h amo%g them( Some Ope%GL mp'eme%tat o%" ma* ha)e "pe! a' re"our!e" to a!!e'erate te=ture per#orma%!e( There ma* .e "pe! a' <e\$& h gh-per#orma%!e te=ture memor*( I# th " memor* " a)a 'a.'e& the te=ture o./e!t" ma* .e pr or t <e\$ to !o%tro' the u"e o# th " ' m te\$ a%\$ )a'ua.'e re"our!e( Ra"ter <at o% Ra"ter <at o% " the !o%)er" o% o# .oth geometr ! a%\$ p =e' \$ata %to #ragme%t"( Ea!h #ragme%t "3uare !orre"po%\$" to a p =e' % the #rame.u##er( L %e a%\$ po'*go% "t pp'e"& ' %e + \$th& po %t " <e& "ha\$ %g mo\$e'& a%\$ !o)erage !a'!u'at o%" to "upport a%t a' a" %g are ta8e% %to !o%" \$erat o% a" )ert !e" are !o%%e!te\$ %to ' %e" or the %ter or p =e'" are !a'!u'ate\$ #or a # ''e\$ po'*go%( Co'or a%\$ \$epth )a'ue" are a"" g%e\$ #or ea!h #ragme%t "3uare( Fragme%t Operat o%" Be#ore )a'ue" are a!tua''* "tore\$ %to the #rame.u##er& a "er e" o# operat o%" are per#orme\$ that ma* a'ter or e)e% thro+ out #ragme%t"( A'' the"e operat o%" !a% .e e%a.'e\$ or \$ "a.'e\$( The # r"t operat o% +h !h ma* .e e%!ou%tere\$ " te=tur %g& +here a te=e' 1te=ture e'eme%t2 " ge%erate\$ #rom te=ture memor* #or ea!h #ragme%t a%\$ app' e\$ to the #ragme%t( The% #og !a'!u'at o%" ma* .e app' e\$& #o''o+e\$ .* the "! ""or te"t& the a'pha te"t& the "te%! ' te"t& a%\$ the \$epth-.u##er te"t 1the \$epth .u##er " #or h \$\$e%-"ur#a!e remo)a'2( Fa ' %g a% e%a.'e\$ te"t ma* e%\$ the !o%t %ue\$ pro!e"" %g o# a #ragme%t:" "3uare( The%& .'e%\$ %g& \$ ther %g& 'og !a' operat o%& a%\$ ma"8 %g .* a . tma"8 ma* .e per#orme\$( F %a''*& the thorough'* pro!e""e\$ #ragme%t " \$ra+% %to the appropr ate .u##er& +here t ha" # %a''* a\$)a%!e\$ to .e a p =e' a%\$ a!h e)e\$ t" # %a' re"t %g p'a!e(

(. IMAGE FORMATIONS Image Format o% I% !omputer graph !"& +e #orm mage" +h !h are ge%era''* t+o \$ me%" o%a' u" %g a pro!e"" a%a'ogou" to ho+ mage" are #orme\$ .* ph*" !a' mag %g "*"tem" Camera" M !ro"!ope" Te'e"!ope" Huma% ) "ua' "*"tem

There are three e'eme%t" o# Format o%9 o./e!t"& ) e+er a%\$ ' ght "our!e( Attr .ute" that go)er% ho+ ' ght %tera!t" + th the mater a'" % the "!e%e( Note the %\$epe%\$e%!e o# the o./e!t"& the ) e+er& a%\$ the ' ght "our!e1"2( ). LIGHT AND COLOR L ght Co'or L ght !o'or " a "u./e!t )e e=per e%!e o# ' ght( Ph*" !a''*& ' ght " !ompo"e\$ o# photo%" - t %* part !'e" o# ' ght& ea!h tra)e' %g a'o%g t" o+% path& a%\$ ea!h ) .rat %g at t" o+% #re3ue%!* 1or +a)e'e%gth& or e%erg* - a%* o%e o# #re3ue%!*& +a)e'e%gth& or e%erg* \$eterm %e" the other"2( A photo% " !omp'ete'* !hara!ter <e\$ .* t" po" t o%& \$ re!t o%& a%\$ #re3ue%!*C+a)e'e%gthCe%erg*( Photo%" + th +a)e'e%gth" ra%g %g #rom a.out ,D7 %a%ometer" 1%m2 1) o'et2 a%\$ E07 %m 1re\$2 !o)er the !o'or" o# the ) " .'e "pe!trum& #orm %g the !o'or" o# a ra %.o+ 1) o'et& %\$ go& .'ue& gree%& *e''o+& ora%ge& re\$2( Ho+e)er& *our e*e" per!e )e 'ot" o# !o'or" that are%:t % the ra %.o+ - +h te& .'a!8& .ro+%& a%\$ p %8& #or e=amp'e( Ho+ \$oe" th " happe%A L ght " the part o# the e'e!tromag%et ! "pe!trum that !au"e" a rea!t o% % our ) "ua' "*"tem"( Ge%era''* the"e are +a)e'e%gth" % the ra%ge o# a.out ,67-E67 %m 1%a%ometer"2( Lo%g +a)e'e%gth" appear a" re\$" a%\$ "hort +a)e'e%gth" a" .'ue"

O%e +a* to #orm a% mage " to #o''o+ ra*" o# ' ght #rom a po %t "our!e # %\$ %g +h !h ra*" e%ter the 'e%" o# the !amera( Ho+e)er& ea!h ra* o# ' ght ma* ha)e mu't p'e %tera!t o%" + th o./e!t" .e#ore .e %g a."or.e\$ or go %g to %# % t*(

Co'or mo\$e'" The huma% e*e !a% "ee ' ght "tart %g + th a +a)e'e%gth o# a.out ,77-B77 %m 1) o'et2 up to rough'* E77-F77 %m 1re\$2( From the theoret !a' po %t o# ) e+& a !o'our " \$e# %e\$ .* the \$ "tr .ut o% o# the %te%" t e" o)er the ) " .'e "pe!trum o# the ' ght( For !o'our per!ept o%& the huma% e*e ha" three \$ ##ere%t t*pe" o# re!eptor"( Ea!h re!eptor t*pe " more "e%" t )e to a !erta % "ma''er ra%ge o# the "pe!trum( The* are !a''e\$ re\$-& gree%- a%\$ .'ue-re!eptor"( The .'ue-re!eptor" are % ge%era' 'e"" "e%" t )e tha% the other t+o( The ma % !hara!ter "t !" o# a !o'our #or huma% per!ept o% are the #o''o+ %g o%e"( hue !orre"po%\$ %g to the \$om %a%t +a)e'e%gth % the "pe!trum o# the !o'our& "aturat o% or pur t* +h !h " h gh +he% the "pe!trum !o%" "t" o# a %arro+ pea8 at the \$om %a%t +a)e'e%gth& a%\$ +h !h " 'o+ #or a #'atter "pe!trum& %te%" t* or ' ght%e"" \$epe%\$ %g o% the e%erg* o# the "pe!trum( The h gher the e%erg* o# the " %g'e #re3ue%! e"& the h gher " the %te%" t*( Per!ept o% o# !o'our" " .a"e\$ o% three !ompo%e%t" or re!eptor" % the huma% e*e& a%\$ a'"o the %tu t )e u%\$er"ta%\$ %g o# !o'our" " .a"e\$ o% three !ompo%e%t"& hue& "aturat o% a%\$ ' ght%e""( There#ore& mo"t

!o'our mo\$e'" % !omputer graph !" a'"o u"e three !ompo%e%t" to repre"e%t !o'our" 'ea\$ %g to a three\$ me%" o%a' !o'our "pa!e( There are a\$\$ t )e a%\$ "u.tra!t )e !o'our mo\$e'"( I% a\$\$ t )e !o'our mo\$e'" the !o'our " \$eterm %e\$ .* a "uperpo" t o% o# ' ght o# \$ ##ere%t !o'our"( Co'our" are aggregate\$ % a% a\$\$ t )e #a"h o%& +he% the .a!8grou%\$ t"e'# " .'a!8 or \$ar8( A !omputer mo% tor " a t*p !a' e=amp'e +here a\$\$ t )e !o'our mo\$e'" are u"e\$( The a\$\$ t o% o# a'' !o'our" * e'\$" +h te( The " tuat o% " \$ ##ere%t #or pr %ter"( Co'our" are app' e\$ to a +h te .a!8grou%\$ 1paper2( M = %g a'' !o'our" + '' * e'\$ .'a!8 % th " !a"e( The mo"t !ommo% !o'our mo\$e' % !omputer graph !" " the RGB mo\$e'( Mo"t o# the mo% tor" a'"o +or8 + th the RGB mo\$e'( The RGB mo\$e' " a% a\$\$ t )e mo\$e' a%\$ ea!h !o'our " !ompo"e\$ o# the three pr mar* !o'our" re\$& gree% a%\$ .'ue( There#ore& three )a'ue" R& G& B G7& 5H are "u## ! e%t to "pe! #* a !o'our( The m % mum %te%" t* " <ero& o%e " the ma= mum %te%" t* #or ea!h o# the pr mar* !o'our"( 17& 7& 72 !orre"po%\$" to .'a!8& 15& 5& 52 " +h te& 1=& =& =2 \$e# %e" a ' ghter or \$ar8er gre*& \$epe%\$ %g o% the !ho !e o# =& 15& 7& 72 e%!o\$e" re\$& 17& 5& 72 gree% a%\$ 17& 7& 52 .'ue( U"ua''*& #or the !o\$ %g o# the %te%" t* o# a !o'our& o%e .*te " u"e\$& "o that ea!h o# the pr mar* !o'our" ha" 06I \$ ##ere%t 'e)e'" o# %te%" t*( I%"tea\$ o# three #'oat %g po %t )a'ue" .et+ee% <ero a%\$ o%e& t " there#ore a'"o )er* !ommo% to "pe! #* three %teger )a'ue" .et+ee% 7 a%\$ 066 #or the %te%" t e" % or\$er to \$e# %e a !o'our( Not e)er* !o'our !a% .e repre"e%te\$ e=a!t'* a" a% a\$\$ t )e !om. %at o% o# the three pr mar* !o'our" re\$& gree% a%\$ .'ue( For th " rea"o%& the Comm "" o% I%ter%at o%a'e \$e ':E!'a rage 1CIE2 %tro\$u!e\$ a mo\$e' + th three art # ! a' !o'our" J& Y a%\$ K +h !h !a% repre"e%t a%* other !o'our( Ho+e)er& # %\$ %g "u ta.'e !om. %at o%" o# the three art # ! a' !o'our" to mo\$e' a \$e" re\$ !o'our " %ot )er* %tu t )e& "o that the CIEJYK mo\$e' " "e'\$om u"e\$( The "u.tra!t )e CMY mo\$e' " the \$ua' to the RGB mo\$e' a%\$ " u"e\$ #or pr %ter" a%\$ p'otter"( The pr mar* !o'our" are !*a%& mage%ta a%\$ *e''o+( The tra%"#ormat o% #rom a% RGB !o'our to t" CMY repre"e%tat o% " g )e% .* the e3uat o% CMY @ 5 - RGB

F gure a.o)e "ho+" the !o'our !u.e( Ea!h )erte= repre"e%t" a "pe! # ! !o'our( For the RGB mo\$e'& the or g % o# the !oor\$ %ate "*"tem " the 'o+er 'e#t rear )erte= at the !o'our .'a!8( The or g % o# the !oor\$ %ate "*"tem #or the CMY mo\$e' " % the upper r ght #ro%t )erte= at the !o'our +h te( The \$ ago%a' .et+ee% the"e )ert !e" !o%ta %" a'' gre*to%e"( To\$a*& mo"t pr %ter" \$o %ot u"e the CMY mo\$e'( The* are .a"e\$ o% #our-!o'our pr %t %g + th the CMYK mo\$e' +here the #ourth a\$\$ t o%a' !o'our K " .'a!8(6 I% th " \$ re!t +a*& .'a!8 " .etter repre"e%te\$ tha% .* m = %g the three other !o'our"( The tra%"#ormat o% #rom the CMY mo\$e' to the CMYK mo\$e' " g )e% .* the #o''o+ %g e3uat o%"( K ;@ m %LC& M& Y M& C ;@ C N K& M ;@ M N K&

Y ;@ Y N K( 4 th the"e e3uat o%"& at 'ea"t o%e o# the #our )a'ue" C& Y& M& K + '' a'+a*" .e e3ua' to <ero( The YIO mo\$e' " %ot .a"e\$ o% three pr mar* !o'our" a" % the RGB a%\$ the CMY mo\$e'& .ut t u"e" the three !ompo%e%t" 'um %a%!e Y a%\$ t+o )a'ue" I a%\$ O !hara!ter " %g the !hromat ! t*& the t*pe o# !o'our( Th " !o'our mo\$e' " a'"o u"e\$ % the Amer !a% NTSC te'e) " o% %orm( 4he% a !o'oure\$ repre"e%tat o% ha" to .e tra%"#orme\$ %to a gre*-"!a'e repre"e%tat o%& #or %"ta%!e #or .'a!8-a%\$-+h te T?& the Y -!ompo%e%t a'o%e \$e# %e" the !orre"po%\$ %g gre*-"!a'e %te%" t*( The tra%"#ormat o% #rom the RGB mo\$e' to the YIO mo\$e' " g )e% .* the #o''o+ %g matr =( YIO @ 12P1RGB2 The propert* that the )a'ue Y \$eterm %e" the 'um %a%!e or %te%" t* \$ re!t'* " a'"o he'p#u' +he% !omputer mo% tor" + th \$ ##ere%t .r ght%e"" "hou'\$ .e a\$/u"te\$& "o that the !o'our" the* "ho+ are more or 'e"" the "ame #or \$e%t !a' RGB )a'ue"( It " mu!h ea" er to a\$/u"t o%'* the Y -)a'ue o# the YIO mo\$e' tha% to a\$/u"t the three )a'ue" R& G a%\$ B at the "ame t me( L 8e the YIO mo\$e'& the HS? mo\$e' " %ot .a"e\$ o% three e'eme%tar* !o'our"& .ut o% the three parameter" hue& "aturat o% a%\$ )a'ue 1 %te%" t*2( The HS? mo\$e' repre"e%t" the !o'our "pa!e a" a p*ram \$ "ta%\$ %g o% t" t p( The t p !orre"po%\$" to the !o'our .'a!8( The hue H " g )e% .* a% a%g'e arou%\$ the )ert !a' a= "( Pr %! pa' !o'our" are repre"e%te\$ .* a%g'e"& "tart %g + th re\$ at 7Q & ha) %g *e''o+ at I7Q & gree% at 507Q & .'ue at 0B7Q a%\$ purp'e at ,77Q ( The "aturat o% S o# a !o'our ra%ge" #rom <ero a'o%g the ? -a= " to o%e at the " \$e"( The )a'ue ? e%!o\$e" ' ght%e""( The h gher ? "& the ' ghter the !o'our( F gure .e'o+ ''u"trate" the HS? mo\$e'( The HLS mo\$e' " .a"e\$ o% " m 'ar \$ea" a" the HS? mo\$e'( The hue " \$e# %e\$ % the "ame +a* a" % the HS? mo\$e'( The ' ght%e"" " \$e# %e\$ .* a

)a'ue .et+ee% <ero a%\$ o%e( The "aturat o% \$epe%\$" o% the \$ "ta%!e to the m \$\$'e a= " repre"e%t %g the gre*-)a'ue"( The "aturat o% " a'"o .et+ee% <ero a%\$ o%e( F gure .e'o+ "ho+" t+o )er" o%" o# the HLS mo\$e'( Somet me"& the HLS mo\$e' " %terprete\$ a" a !*' %\$er a" % the 'e#t-ha%\$ " \$e o# the # gure( But "omet me" the \$ou.'e !o%e o% the r ght " pre#erre\$ #or the HLS mo\$e'( The \$ou.'e !o%e re#'e!t" the #a!t that t \$oe" %ot ma8e "e%"e to "pea8 o# "aturat o% #or the !o'our" .'a!8 a%\$ +h te& +he% gre*)a'ue" are a'rea\$* !hara!ter "e\$ .* the 'um %a%!e )a'ue( D agram o# HLS mo\$e'

A'gor thm" to tra%"#orm !o'our" #rom the HS? a%\$ the HLS mo\$e' to the RGB mo\$e' a%\$ .a!8 !a% .e #ou%\$ % G5FH( The HS? a%\$ the HLS mo\$e' !ou%t a" per!ept o%-or e%te\$ !o'our mo\$e'" " %!e the* re#'e!t the %tu t )e per!ept o% o# !o'our" .etter( Spe! #* %g the parameter" o# a \$e" re\$ !o'our " ea" er + th per!ept o%-or e%te\$ mo\$e'" tha% + th mo\$e'" ' 8e RGB or CMY( For the 'atter mo\$e'"& graph ! program" )er* o#te% "upport the "pe! # !at o% o# !o'our" .* pro) \$ %g a !o'our pa'ette( L 8e the HS? a%\$ the HLS mo\$e'& the CNS mo\$e' " a%other per!ept o%-or e%te\$ !o'our mo\$e' .a"e\$ o% the "pe! # !at o% o# the t*pe o# the !o'our& t" "aturat o% a%\$ t" ' ght%e""( The CNS mo\$e' \$oe" %ot u"e %um.er" #or the"e parameter" .ut +or\$"( For the t*pe o# the !o'our& )a'ue" ' 8e purp'e& re\$& ora%ge& .ro+%& *e''o+& gree%& .'ue are a)a 'a.'e %!'u\$ %g m =ture" ' 8e *e''o+ "h gree%& gree%-*e''o+ or gree% "h *e''o+( The ' ght%e"" !a% .e \$e# %e\$ a" o%e o# the )a'ue" )er* \$ar8& \$ar8& me\$ um& ' ght a%\$ )er* ' ght( The "aturat o% !a% .e gre* "h& mo\$erate& "tro%g or ) ) \$( The %um.er o# po"" .'e !om. %at o%" o# the"e e=pre"" o%" " mu!h "ma''er tha% the %um.er o# !o'our" e=pre"" .'e + th the RGB mo\$e'( But the \$e"!r pt o% o# the !o'our " mu!h more %tu t )e( Ope%GL !o'or %g app' !at o% Ope%GL ma %ta %" a !urre%t !o'or 1 % RGBA mo\$e2 a%\$ a !urre%t !o'or %\$e= 1 % !o'or- %\$e= mo\$e2( U%'e"" *ou:re u" %g a more !omp' !ate\$ !o'or %g mo\$e' "u!h a" ' ght %g or te=ture mapp %g& ea!h o./e!t " \$ra+% u" %g the !urre%t !o'or 1or !o'or %\$e=2( Loo8 at the #o''o+ %g p"eu\$o!o\$e "e3ue%!e; "etR!o'or1RED29 \$ra+R tem1A29 \$ra+R tem1B29 "etR!o'or1GREEN29 "etR!o'or1BLUE29 \$ra+R tem1C29 Item" A a%\$ B are \$ra+% % re\$& a%\$ tem C " \$ra+% % .'ue( The #ourth ' %e& +h !h "et" the !urre%t !o'or to gree%& ha" %o e##e!t 1e=!ept to +a"te a . t o# t me2( 4 th %o ' ght %g or te=tur %g& +he% the !urre%t !o'or " "et& a'' tem" \$ra+% a#ter+ar\$ are \$ra+% % that !o'or u%t ' the !urre%t !o'or " !ha%ge\$ to "ometh %g e'"e( Spe! #* %g a Co'or % RGBA Mo\$e I% RGBA mo\$e& u"e the g'Co'orP12 !omma%\$ to "e'e!t a !urre%t !o'or( void !l"olor/{; s i 0 d u; us ui: (.YP-r\$ .YP-!\$ .YP-;) void !l"olor<{; s i 0 d u; us ui: (.YP-r\$ .YP-!\$ .YP-;\$ .YP-a) void !l"olor/{; s i 0 d u; us ui:v (const .YP-=v) void !l"olor<{; s i 0 d u; us ui:v (const .YP-=v) >ets the current red\$ !reen\$ ;lue\$ and al8ha values. .his command can have u8 to three su00i4es\$ which di00erentiate variations o0 the 8arameters acce8ted. .he 0irst su00i4 is either / or <\$ to indicate whether ?ou su88l? an al8ha value in addition to the red\$ !reen\$ and ;lue values. I0 ?ou don@t su88l? an al8ha value\$ it@s automaticall? set to 1.#. .he second su00i4 indicates the data t?8e 0or 8arametersA ;?te\$ short\$ inte!er\$ 0loat\$ dou;le\$ unsi!ned ;?te\$ unsi!ned short\$ or unsi!ned inte!er. .he third su00i4 is an o8tional v\$ which indicates that the ar!ument is a 8ointer to an arra? o0 values o0 the !iven data t?8e.

For the )er" o%" o# g'Co'orP12 that a!!ept #'oat %g-po %t \$ata t*pe"& the )a'ue" "hou'\$ t*p !a''* ra%ge .et+ee% 7(7 a%\$ 5(7& the m % mum a%\$ ma= mum )a'ue" that !a% .e "tore\$ % the #rame.u##er( U%" g%e\$- %teger !o'or !ompo%e%t"& +he% "pe! # e\$& are ' %ear'* mappe\$ to #'oat %g-po %t )a'ue" "u!h that the 'arge"t repre"e%ta.'e )a'ue map" to 5(7 1#u'' %te%" t*2& a%\$ <ero map" to 7(7 1<ero %te%" t*2( S g%e\$- %teger !o'or !ompo%e%t"& +he% "pe! # e\$& are ' %ear'* mappe\$ to #'oat %g-po %t )a'ue" "u!h that the mo"t po" t )e repre"e%ta.'e )a'ue map" to 5(7& a%\$ the mo"t %egat )e repre"e%ta.'e )a'ue map" to -5(7 1"ee Ta.'e B-52( Ne ther #'oat %g-po %t %or " g%e\$- %teger )a'ue" are !'ampe\$ to the ra%ge G7&5H .e#ore up\$at %g the !urre%t !o'or or !urre%t ' ght %g mater a' parameter"( A#ter ' ght %g !a'!u'at o%"& re"u't %g !o'or )a'ue" out" \$e the ra%ge G7&5H are !'ampe\$ to the ra%ge G7&5H .e#ore the* are %terpo'ate\$ or +r tte% %to a !o'or .u##er( E)e% # ' ght %g " \$ "a.'e\$& the !o'or !ompo%e%t" are !'ampe\$ .e#ore ra"ter <at o%( Spe! #* %g a Co'or % Co'or-I%\$e= Mo\$e I% !o'or- %\$e= mo\$e& u"e the g'I%\$e=P12 !omma%\$ to "e'e!t a " %g'e-)a'ue\$ !o'or %\$e= a" the !urre%t !o'or %\$e=( void !lInde4{si0d u;:(.YP- c) void !lInde4{si0d u;:v(const .YP- =c) >ets the current color inde4 to c. .he 0irst su00i4 0or this command indicates the data t?8e 0or 8arametersA short\$ inte!er\$ 0loat\$ dou;le\$ or unsi!ned ;?te. .he second\$ o8tional su00i4 is v\$ which indicates that the ar!ument is an arra? o0 values o0 the !iven data t?8e (the arra? contains onl? one value). I% >C'ear %g the 4 %\$o+> % Chapter 0& *ou "a+ the "pe! # !at o% o# g'C'earCo'or12( For !o'or- %\$e= mo\$e& there " a !orre"po%\$ %g g'C'earI%\$e=12( void !l"learInde4(%&0loat cinde4) >ets the current clearin! color in color2inde4 mode. In a color2inde4 mode window\$ a call to !l"lear(%&'"(&()'*+,,-)'*I.) will use cinde4 to clear the ;u00er. .he de0ault clearin! inde4 is #.#. Note; Ope%GL \$oe" %ot ha)e a%* rout %e" to 'oa\$ )a'ue" %to the !o'or-'oo8up ta.'e( 4 %\$o+ "*"tem" t*p !a''* a'rea\$* ha)e "u!h operat o%"( GLUT ha" the rout %e g'utSetCo'or12 to !a'' the + %\$o+-"*"tem "pe! # ! !omma%\$"( Spe! #* %g a Sha\$ %g Mo\$e' A ' %e or a # ''e\$ po'*go% pr m t )e !a% .e \$ra+% + th a " %g'e !o'or 1#'at "ha\$ %g2 or + th ma%*

\$ ##ere%t !o'or" 1"mooth "ha\$ %g& a'"o !a''e\$ Gourau\$ "ha\$ %g2( You "pe! #* the \$e" re\$ "ha\$ %g te!h% 3ue + th g'Sha\$eMo\$e'12( void !l>hadeBodel (%&enum mode) >ets the shadin! model. .he mode 8arameter can ;e either %&'>B((.C (the de0ault) or %&',&A.. 4 th #'at "ha\$ %g& the !o'or o# o%e part !u'ar )erte= o# a% %\$epe%\$e%t pr m t )e " \$up' !ate\$ a!ro"" a'' the pr m t )e:" )ert !e" to re%\$er that pr m t )e( 4 th "mooth "ha\$ %g& the !o'or at ea!h )erte= " treate\$ %\$ ) \$ua''*( For a ' %e pr m t )e& the !o'or" a'o%g the ' %e "egme%t are %terpo'ate\$ .et+ee% the )erte= !o'or"( For a po'*go% pr m t )e& the !o'or" #or the %ter or o# the po'*go% are %terpo'ate\$ .et+ee% the )erte= !o'or"( E=amp'e Dra+ %g a Smooth-Sha\$e\$ Tr a%g'e; #include <%&D!l.h> #include <%&D!lut.h> void init(void) { !l"lear"olor (#.#\$ #.#\$ #.#\$ #.#) !l>hadeBodel (%&'>B((.C) : void trian!le(void) { !l*e!in (%&'.)IAN%&->) !l"olor/0 (1.#\$ #.#\$ #.#) !l3erte450 (6.#\$ 6.#) !l"olor/0 (#.#\$ 1.#\$ #.#) !l3erte450 (56.#\$ 6.#) !l"olor/0 (#.#\$ #.#\$ 1.#) !l3erte450 (6.#\$ 56.#) !l-nd() : void dis8la?(void) { !l"lear (%&'"(&()'*+,,-)'*I.) trian!le () !l,lush () : void resha8e (int w\$ int h) { !l3iew8ort (#\$ #\$ (%&sizei) w\$ (%&sizei) h)

!lBatri4Bode (%&'P)(E-".I(N) !l&oadIdentit? () i0 (w <F h) !lu(rtho5G (#.#\$ /#.#\$ #.#\$ /#.#=(%&0loat) hD(%&0loat) w) else !lu(rtho5G (#.#\$ /#.#=(%&0loat) wD(%&0loat) h\$ #.#\$ /#.#) !lBatri4Bode(%&'B(G-&3I-W) : int main(int ar!c\$ char== ar!v) { !lutInit(Har!c\$ ar!v) !lutInitGis8la?Bode (%&+.'>IN%&- I %&+.')%*) !lutInitWindow>ize (6##\$ 6##) !lutInitWindowPosition (1##\$ 1##) !lut"reateWindow (ar!vJ#K) init () !lutGis8la?,unc(dis8la?) !lut)esha8e,unc(resha8e) !lutBain&oo8() return # : 4 th "mooth "ha\$ %g& %e gh.or %g p =e'" ha)e "' ght'* \$ ##ere%t !o'or )a'ue"( I% RGBA mo\$e& a\$/a!e%t p =e'" + th "' ght'* \$ ##ere%t )a'ue" 'oo8 " m 'ar& "o the !o'or !ha%ge" a!ro"" a po'*go% appear gra\$ua'( I% !o'or- %\$e= mo\$e& a\$/a!e%t p =e'" ma* re#ere%!e \$ ##ere%t 'o!at o%" % the !o'or- %\$e= ta.'e& +h !h ma* %ot ha)e " m 'ar !o'or" at a''( A\$/a!e%t !o'or- %\$e= e%tr e" ma* !o%ta % + '\$'* \$ ##ere%t !o'or"& "o a "mooth-"ha\$e\$ po'*go% % !o'or- %\$e= mo\$e !a% 'oo8 p"*!he\$e' !( To a)o \$ th " pro.'em& *ou ha)e to !reate a !o'or ramp o# "mooth'* !ha%g %g !o'or" amo%g a !o%t guou" "et o# %\$ !e" % the !o'or map( Remem.er that 'oa\$ %g !o'or" %to a !o'or map " per#orme\$ through *our + %\$o+ "*"tem rather tha% Ope%GL( I# *ou u"e GLUT& *ou !a% u"e g'utSetCo'or12 to 'oa\$ a " %g'e %\$e= % the !o'or map + th "pe! # e\$ re\$& gree%& a%\$ .'ue )a'ue"( The # r"t argume%t #or g'utSetCo'or12 " the %\$e=& a%\$ the other" are the re\$& gree%& a%\$ .'ue )a'ue"( To 'oa\$ th rt*-t+o !o%t guou" !o'or %\$ !e" 1#rom !o'or %\$e= 5I to BE2 + th "' ght'* \$ ##er %g "ha\$e" o# *e''o+& *ou m ght !a'' 0or (i F # i < /5 iLL) { !lut>et"olor (1MLi\$ 1.#=(iD/5.#)\$ 1.#=(iD/5.#)\$ #.#) : No+& # *ou re%\$er "mooth-"ha\$e\$ po'*go%" that u"e o%'* the !o'or" #rom %\$e= 5I to BE& tho"e po'*go%" ha)e gra\$ua''* \$ ##er %g "ha\$e" o# *e''o+( 4 th #'at "ha\$ %g& the !o'or o# a " %g'e )erte= \$e# %e" the !o'or o# a% e%t re pr m t )e( For a ' %e "egme%t& the !o'or o# the ' %e " the !urre%t !o'or +he% the "e!o%\$ 1e%\$ %g2 )erte= " "pe! # e\$( For a po'*go%& the !o'or u"e\$ " the o%e that:" % e##e!t +he% a part !u'ar )erte= " "pe! # e\$( Ope%GL #o''o+" the"e ru'e" !o%" "te%t'*& .ut the .e"t +a* to

a)o \$ u%!erta %t* a.out ho+ a #'at-"ha\$e\$ pr m t )e + '' .e \$ra+% " to "pe! #* o%'* o%e !o'or #or the pr m t )e( *. IMAGE 'ROCESSING A !omputer mage " u"ua''* repre"e%te\$ a" a \$ "!rete gr \$ o# p !ture e'eme%t" 8%o+% a" p =e'" 1p !ture e'eme%t"2( It " "ma''e"t u% t o# p !ture that !a% .e pre"e%te\$ or !o%tro''e\$( Ea!h p =e' ha" t" a\$\$re""( The a\$\$re"" o# a p =e' !orre"po%\$" to t" !oor\$ %ate"( P =e'" are %orma''* arra%ge\$ % a% arra* o# 'o!at o%" 10-\$ me%" o%a' gr \$2& a%\$ are repre"e%te\$ u" %g \$ot" or "3uare"( Ea!h p =e' " a "amp'e o# the or g %a' mage& more "amp'e" pro) \$e more a!!urate repre"e%tat o%" o# the or g %a' mage( The %um.er o# p =e'" \$eterm %e" the re"o'ut o% o# the mage& though ha" a more "pe! # ! \$e# % t o%( P =e' !ou%t" !a% .e e=pre""e\$ a" a " %g'e %um.er& a" % a Sthree-megap =e'S \$ g ta' !amera& +h !h ha" a %om %a' three m '' o% p =e'"& or a" a pa r o# %um.er"& a" % a SIB7 .* BF7 \$ "p'a*S& +h !h ha" IB7 p =e'" #rom " \$e to " \$e a%\$ BF7 #rom top to .ottom 1a" % a ?GA \$ "p'a*2& a%\$ there#ore ha" a tota' %um.er o# IB7 BF7 @ ,7E&077 p =e'" or 7(, mega p =e'"( T*p !a' re"o'ut o%" ra%ge #rom ,07P077 to 0777P5677( There#ore& +e "a* a p =e' " the mo"t .a" ! !ompo%e%t o# a%* !omputer graph !( P =e' "ta%\$" #or p !ture e'eme%t( It !orre"po%\$" to the "ma''e"t th %g that !a% .e \$ra+% o% a !omputer "!ree%( E)er* !omputer graph ! " ma\$e up o# a gr \$ o# p =e'"( 4he% the"e p =e'" are pa %te\$ o%to the "!ree%& the* #orm a% mage( Th " gr \$ o# p =e'" " !a''e\$ a . tmap(

I% .'a!8 T +h te& ea!h p =e' !a% .e repre"e%te\$ .* 5 . t& a 5 # the p =e' " .'a!8& or a 7 # the p =e' " +h te( The !omputer ope%" a .'a!8 T +h te . t mappe\$ mage( the% t "tart" 'oo8 %g #or %um.er" that \$e"!r .e mage %#ormat o%( E)er* t me t !ome" to a 7 t \$ra+" a +h te p =e'( 4he% t !ome" to a 5 t \$ra+" a .'a!8 p =e'( The p =e'"& or !o'or "amp'e"& that #orm a \$ g t <e\$ mage 1"u!h a" a UPEG # 'e u"e\$ o% a +e. page2 ma* or ma* %ot .e % o%e-to-o%e !orre"po%\$e%!e + th "!ree% p =e'"& \$epe%\$ %g o% ho+ a !omputer \$ "p'a*" a% mage( I% !omput %g& a% mage !ompo"e\$ o# p =e'" " 8%o+% a" a . tmappe\$ mage or a ra"ter mage( The +or\$ ra"ter or g %ate" #rom te'e) " o% "!a%% %g patter%"& a%\$ ha" .ee% + \$e'* u"e\$ to \$e"!r .e " m 'ar ha'#to%e pr %t %g a%\$ "torage te!h% 3ue"( Computer" !a% u"e p =e'" to \$ "p'a* a% mage& o#te% a% a."tra!t mage that repre"e%t" a GUI( The re"o'ut o% o# th " mage " !a''e\$ the \$ "p'a* re"o'ut o% a%\$ " \$eterm %e\$ .* the ) \$eo !ar\$ o# the !omputer( LCD mo% tor" a'"o u"e p =e'" to \$ "p'a* a% mage& a%\$ ha)e a %at )e re"o'ut o%( Ea!h p =e' " ma\$e up o# tr a\$"& + th the %um.er o# the"e tr a\$" \$eterm % %g the %at )e re"o'ut o%( O% "ome CRT mo% tor"& the .eam "+eep rate ma* .e # =e\$& re"u't %g % a # =e\$ %at )e re"o'ut o%( Mo"t CRT mo% tor" \$o %ot ha)e a # =e\$ .eam "+eep

rate& mea% %g the* \$o %ot ha)e a %at )e re"o'ut o% at a''& %"tea\$ the* ha)e a "et o# re"o'ut o%" that are e3ua''* +e'' "upporte\$( To pro\$u!e the "harpe"t mage" po"" .'e o% a% LCD& the u"er mu"t e%"ure the \$ "p'a* re"o'ut o% o# the !omputer mat!he" the %at )e re"o'ut o% o# the mo% tor( A" "tate\$ a.o)e& # the tota' %um.er o# p =e'" hor <o%ta' a%\$ )ert !a' %!rea"e th " mea%" the re"o'ut o% o# r.g !o'or mage %!rea"e a%\$ the re\$u!t o% o# tota' %um.er o# p =e'" mea%" poor re"o'ut o%( The %te%" t* o# p =e' " a )ar a.'e& #or a .'a!8 a%\$ +h te mage& a %um.er \$e"!r .e" the %te%" t* o# ea!h p =e'( It !a% .e e=pre""e\$ .et+ee% 7(7 1.'a!82 a%\$ 5(7 1+h te2( Ho+e)er& #or %ter%a' . %ar* repre"e%tat o% rea"o%"& t " u"ua''* "tore\$ a" a% %teger .et+ee% 7 1.'a!82 a%\$ 066 1+h te2( The %um.er o# \$ "t %!t !o'or" that !a% .e repre"e%te\$ .* a p =e' \$epe%\$" o% the %um.er o# . t" per p =e' 1.pp2( A 5 .pp mage u"e" 5-. t #or ea!h p =e'& "o ea!h p =e' !a% .e e ther o% or o##( Ea!h a\$\$ t o%a' . t \$ou.'e" the %um.er o# !o'or" a)a 'a.'e& "o a 0 .pp mage !a% ha)e B !o'or"& a%\$ a , .pp mage !a% ha)e F !o'or";

I% !o'or mage "*"tem"& a !o'or " t*p !a''* repre"e%te\$ .* three or #our !ompo%e%t %te%" t e" "u!h a" re\$& gree%& a%\$ .'ue& 1RGB !o'or "pa!e2 or !*a%& mage%ta& *e''o+& a%\$ .'a!8 1CMYK !o'or "pa!e2( For RBG !o'or "pa!e mage& the %te%" t* o# ea!h p =e' " a% a)erage )a'ue o# re\$& gree% a%\$ .'ue %te%" t e"( th " " to "a*& RBG !o'or !ompo%e%t" ha)e 06I gra*"!a'e 'e)e'" ea!h& 17 - 0662 #or re\$ !ha%%e'& 17 - 0662 #or gree% !ha%%e' a%\$ 17 - 0662 #or .'ue !ha%%e'( Thu" + th a% F-. t" #or re\$& F-. t" #or gree% a%\$ F-. t" #or .'ue a p =e' !o%" "t" o# a tota' %um.er o# 0B-. t" per e)er* p =e'( A 0B-. t \$epth a''o+" F . t" per !ompo%e%t( O% "ome "*"tem"& ,0-. t \$epth " a)a 'a.'e; th " mea%" that ea!h 0B-. t p =e' ha" a% e=tra F . t" to \$e"!r .e t" opa! t* 1#or purpo"e" o# !om. % %g + th a%other mage2( For a !o'or mage& ea!h p =e' " \$e"!r .e\$ .* a tr p'e o# %um.er" repre"e%t %g the %te%" t* o# re\$& gree% a%\$ .'ue( For e=amp'e& pure re\$ " 1066& 7& 72 a%\$ purp'e " 1066& 7& 0662( For !o'or \$epth" o# 56 or more . t" per p =e'& the \$epth " %orma''* the "um o# the . t" a''o!ate\$ to ea!h o# the re\$& gree%& a%\$ .'ue

!ompo%e%t"( H gh!o'or& u"ua''* mea% %g 5I .pp& %orma''* ha" # )e . t" #or re\$ a%\$ .'ue& a%\$ " = . t" #or gree%& a" the huma% e*e " more "e%" t )e to error" % gree% tha% % the other t+o pr mar* !o'or"( For app' !at o%" %)o') %g tra%"pare%!*& the 5I . t" ma* .e \$ ) \$e\$ %to # )e . t" ea!h o# re\$& gree%& a%\$ .'ue& + th o%e . t 'e#t #or tra%"pare%!*(

Be!au"e the mage " repre"e%te\$ .* a \$ "!rete arra* o# p =e'"& a' a" %g pro.'em" ma* o!!ur( The mo"t !'a"" !a' #orm o# a' a" %g " the /agg* a"pe!t o# ' %e"( A%t a' a" %g te!h% 3ue" are thu" re3u re\$( I% the !a"e o# the ' %e& t !o%" "t" % u" %g %terme\$ ate gra* 'e)e'" to "mooth the appeara%!e o# the ' %e( A%other #orm o# a' a" %g !a% .e o."er)e\$ o% te'e) " o% +he% peop'e +ear "h rt" + th a # %e "tr ppe\$ te=ture( A #' !8er %g patter% " o."er)e\$ .e!au"e the " <e o# the patter% " o% the "ame or\$er o# mag% tu\$e a" the p =e' " <e( +. ,ECTOR GRA'HICS Be#ore a% o./e!t !a% .e "ho+% o% a !omputer mo% tor or a pr %ter& a mo\$e' \$e"!r . %g the o./e!t:" geometr* " re3u re\$& u%'e"" the o./e!t " a% mage t"e'#( Mo\$e'' %g o# geometr !a' o./e!t" " u"ua''* \$o%e % the #rame+or8 o# )e!tor-or e%te\$ or )e!tor graph !"( A more !omp'e= o./e!t " mo\$e''e\$ a" a !om. %at o% o# e'eme%tar* o./e!t" ' 8e ' %e"& re!ta%g'e"& ! r!'e"& e'' p"e" or ar!"( Ea!h o# the"e e'eme%tar* o./e!t" !a% .e \$e# %e\$ .* a #e+ !oor\$ %ate"& \$e"!r . %g the 'o!at o% o# the o./e!t& a%\$ "ome parameter" ' 8e the ra\$ u" #or a ! r!'e( A )er* " mp'e \$e"!r pt o% o# the hou"e % term" o# )e!tor graph !" " "ho+% % # gure .e'o+( The hou"e !a% .e \$e# %e\$ a" a "e3ue%!e o# po %t" or )e!tor"( It mu"t a'"o .e "pe! # e\$ + th % the "e3ue%!e o# po %t" +hether t+o %e gh.our %g po %t" "hou'\$ .e !o%%e!te\$ .* a ' %e or %ot( Dotte\$ ' %e" % # gure F gure 0(5 Or g %a' mage& )e!tor a%\$ p =e' graph !" a.o)e re#er to po %t" % the "e3ue%!e that "hou'\$ %ot .e !o%%e!te\$ .* a ' %e( The )e!tor graph !"or e%te\$ \$e"!r pt o% o# o./e!t" " %ot \$ re!t'* "u ta.'e #or the repre"e%tat o% o% a pure'* p =e'-or e%te\$ \$e) !e ' 8e a% LCD mo% tor or pr %ter( From a theoret !a' po %t o# ) e+& t +ou'\$ .e po"" .'e to \$ "p'a* )e!tor graph !" \$ re!t'* o% a CRT5 mo% tor .* ru%% %g the !atho\$e ra*Vor& % !a"e o# !o'our \$ "p'a*& the three !atho\$e ra*"Va'o%g the ' %e" \$e# %e\$ .* the "e3ue%!e o# po %t" a%\$ "+ t!h the ra* o% or o##& \$epe%\$ %g o% +hether the !orre"po%\$ %g !o%%e!t %g ' %e "hou'\$ .e \$ra+%( I% th " !a"e& the mo% tor m ght %ot .e #' !8er #ree a%*more " %!e the !atho\$e ra* m ght ta8e too 'o%g to re#re"h the "!ree% #or a more !omp'e= mage % )e!tor graph !"& "o that #'uore"!e%t "pot" o% the "!ree% m ght #a\$e out& .e#ore the !atho\$e ra* retur%"( F' !8er-#ree mo% tor" "hou'\$ ha)e a re#re"h rate o# I7 H<( I# a !atho\$e ra* +ere to ru% a'o%g the !o%tour ' %e" o# o./e!t" repre"e%te\$ % )e!tor graph !"& the re#re"h rate +ou'\$ \$epe%\$ o% ho+ ma%* ' %e" the o./e!t" !o%ta %& "o that a "u## ! e%t'* #a"t re#re"h rate !ou'\$ %ot .e guara%tee\$ %

th " operat o%a' mo\$e( There#ore& the !atho\$e ra* "!a%" the "!ree% ' %e .* ' %e 'ea\$ %g to a guara%tee\$ a%\$ !o%"ta%t re#re"h rate& %\$epe%\$e%t o# the mage to .e \$ra+%( Computer mo% tor"& pr %ter" a%\$ a'"o )ar ou" #ormat" #or "tor %g mage" ' 8e . tmap" or UPEG are .a"e\$ o% ra"ter or ra"ter-or e%te\$ graph !"& a'"o !a''e\$ p =e' or p =e'-or e%te\$ graph !"( Ra"ter graph !" u"e" a p =e' matr = o# # =e\$ " <e( A !o'our !a% .e a"" g%e\$ to ea!h p =e' o# the ra"ter( I% the " mp'e"t !a"e o# a .'a!8-a%\$-+h te mage a p =e' ta8e" o%e o# the t+o )a'ue" .'a!8 or +h te( I% or\$er to \$ "p'a* )e!tor-or e%te\$ graph !" % the #orm o# ra"ter graph !"& a'' geometr !a' "hape" mu"t .e !o%)erte\$ %to p =e'"( Th " pro!e\$ure " !a''e\$ "!a% !o%)er" o%( O% the o%e ha%\$& th " !a% 'ea\$ to h gh !omputat o%a' e##ort"( A "ta%\$ar\$ mo% tor ha" more tha% o%e m '' o% p =e'"( For ea!h o# them& t mu"t .e \$e! \$e\$ +h !h !o'our to a"" g% to t #or ea!h mage( O% the other ha%\$& u%\$e" re\$ a' a" %g e##e!t" o!!ur % the #orm o# /agge\$ e\$ge"& 8%o+% a" /agg e" or "ta r!a" %g( The term a' a" %g e##e!t or g %ate" #rom the # e'\$ o# " g%a' pro!e"" %g a%\$ re#er" to art #a!t"& (e(& "uper# ! a' u%\$e" re\$ e##e!t" that !a% o!!ur& +he% a \$ "!rete "amp' %g rate " u"e\$ to mea"ure a !o%t %uou" " g%a'(A gre*-"!a'e mage !a% .e ) e+e\$ a" a t+o-\$ me%" o%a' " g%a'( I% th " "e%"e& a !o'oure\$ mage .a"e\$ o% the three !o'our" re\$& gree% a%\$ .'ue& " %oth %g e'"e tha% three t+o\$ me%" o%a' " g%a'"& o%e #or ea!h !o'our( E)e% # a% mage + '' .e \$ "p'a*e\$ % term" o# ra"ter-or e%te\$ graph !"& t "t '' ha" a\$)a%tage" to mo\$e' a%\$ "tore t % a )e!tor-or e%te\$ #ormat( Ra"ter graph !" " .ou%\$ to a "pe! # ! re"o'ut o%( O%!e the re"o'ut o% " # =e\$& the #u'' %#ormat o% !o%ta %e\$ % the )e!toror e%te\$ mage !a%%ot .e re!o)ere\$ a%*more& 'ea\$ %g to "er ou" \$ "a\$)a%tage"& +he% the mage " \$ "p'a*e\$ o% a \$e) !e + th a \$ ##ere%t re"o'ut o% or +he% the mage %ee\$" to .e e%'arge\$ or "!a'e\$ \$o+%( F gure 0(0 "ho+" the t p o# a% arro+ a%\$ t" repre"e%tat o% % the #orm o# ra"ter graph !" #or t+o \$ ##ere%t re"o'ut o%"( I# o%'* the more !oar"e p =e' mage % the m \$\$'e " "tore\$& t " mpo"" .'e to re!o%"tru!t the re# %e\$ p =e' mage o% the r ght-ha%\$ " \$e + thout a\$\$ t o%a' %#ormat o%( O%e !ou'\$ o%'* pro\$u!e a% mage appear %g % the "ame #orm a" the o%e % the m \$\$'e .* " mp'* \$e%t #* %g #our p =e'" o# the re# %e\$ mage + th o%e p =e' % the !oar"er mage( I# the 3uot e%t o# the p =e' re"o'ut o% " %ot a% %teger %um.er& the tra%"#ormat o% #rom a ra"ter graph !" + th o%e re"o'ut o% to a ra"ter graph !" + th a%other re"o'ut o% .e!ome" e)e% more !omp' !ate\$ a%\$ + '' 'ea\$ to %e+ a' a" %g e##e!t"& e)e% # the %e+ re"o'ut o% " h gher tha% the or g %a' o%e( F gure 0(0 The t p o# a% arro+ \$ra+% a" ra"ter graph !" % t+o \$ ##ere%t re"o'ut o%" I% mo"t !a"e"& +he% a p =e' matr = " !o%" \$ere\$ % th " .oo8& ea!h p =e' " repre"e%te\$ .* a "3uare .et+ee% the ' %e" o# a gr \$ a" "ho+% % # gure a.o)e( Ho+e)er& "omet me" a%other repre"e%tat o% " more !o%)e% e%t +here p =e'" are ''u"trate\$ a" ! r!'e" o% the po %t" +here the ' %e" o# the gr \$ !ro""( F gure .e'o+ "ho+" the p =e' + th the gr \$ !oor\$ %ate" 16&,2( F gure 0(, A% a'ter%at )e repre"e%tat o% #or p =e'"

Dra-in% al%orit.\$s There are three \$ra+ %g a'gor thm" "u!h a" ra"ter <at o%& p =e' <at o% a%\$ "!a% !o%)er" o%( R#st#ri/ation Ra"ter "at o% 1or ra"ter <at o%2 " the ta"8 o# ta8 %g a% mage \$e"!r .e\$ % a )e!tor graph !" #ormat 1"hape"2 a%\$ !o%)ert %g t %to a ra"ter mage 1p =e'" or \$ot"2 #or output o% a ) \$eo \$ "p'a* or pr %ter& or #or "torage % a . tmap # 'e #ormat( I% %orma' u"age& the term re#er" to the popu'ar re%\$er %g a'gor thm #or \$ "p'a* %g three-\$ me%" o%a'

"hape" o% a !omputer( Ra"ter <at o% " !urre%t'* the mo"t popu'ar te!h% 3ue #or pro\$u! %g rea'-t me ,D !omputer graph !"( Rea'-t me app' !at o%" %ee\$ to re"po%\$ mme\$ ate'* to u"er %put& a%\$ ge%era''* %ee\$ to pro\$u!e #rame rate" o# at 'ea"t 0B #rame" per "e!o%\$ to a!h e)e "mooth a% mat o%( Compare\$ + th other re%\$er %g te!h% 3ue" "u!h a" ra* tra! %g& ra"ter <at o% " e=treme'* #a"t( Ho+e)er& ra"ter <at o% " " mp'* the pro!e"" o# !omput %g the mapp %g #rom "!e%e geometr* to p =e'" a%\$ \$oe" %ot pre"!r .e a part !u'ar +a* to !ompute the !o'or o# tho"e p =e'"( Sha\$ %g& %!'u\$ %g programma.'e "ha\$ %g& ma* .e .a"e\$ o% ph*" !a' ' ght tra%"port& or art "t ! %te%t( The pro!e"" o# ra"ter " %g ,D mo\$e'" o%to a 0D p'a%e #or \$ "p'a* o% a !omputer "!ree% " o#te% !arr e\$ out .* # =e\$ #u%!t o% har\$+are + th % the graph !" p pe' %e( Th " " .e!au"e there " %o mot )at o% #or mo\$ #* %g the te!h% 3ue" #or ra"ter "at o% u"e\$ at re%\$er t me a%\$ a "pe! a'-purpo"e "*"tem a''o+" #or h gh e## ! e%!*(

I% !omputer graph !"& a ra"ter graph !" mage& or . tmap& " a \$ata "tru!ture repre"e%t %g a ge%era''* re!ta%gu'ar gr \$ o# p =e'"& or po %t" o# !o'or& ) e+a.'e ) a a mo% tor& paper& or other \$ "p'a* me\$ um( Ra"ter mage" are "tore\$ % mage # 'e" + th )ar* %g #ormat"( The !o%)e%t o% % th " !our"e + '' #o''o+ that o# Ope%GL& p'a! %g the or g % % the 'o+er 'e#t !or%er& + th that p =e' .e %g at 'o!at o% 17& 72( Be a+are that p'a! %g the or g % % the upper 'e#t " a%other !ommo% !o%)e%t o%( O%e o# 0N %te%" t e" or !o'or" are a""o! ate\$ + th ea!h p =e'& +here N " the %um.er o# . t" per p =e'( Gre*"!a'e t*p !a''* ha" o%e .*te per p =e'& #or 0F @ 06I %te%" t e"( Co'or o#te% re3u re" o%e .*te per !ha%%e'& + th three !o'or !ha%%e'" per p =e'; re\$& gree%& a%\$ .'ue( Co'or \$ata " "tore\$ % a #rame .u##er( Th " " "omet me" !a''e\$ a% mage map or . tmap( A . tmap !orre"po%\$" . t-#or-. t + th a% mage \$ "p'a*e\$ o% a "!ree%& ge%era''* % the "ame #ormat u"e\$ #or "torage % the \$ "p'a*:" ) \$eo memor*& or ma*.e a" a \$e) !e- %\$epe%\$e%t . tmap( A . tmap " te!h% !a''* !hara!ter <e\$ .* the + \$th a%\$ he ght o# the mage % p =e'" a%\$ .* the %um.er o# . t" per p =e' 1a !o'or \$epth& +h !h \$eterm %e" the %um.er o# !o'or" t !a% repre"e%t2( 'i0#li/ation P =e' <at o% " a ) \$eo a%\$ mage e\$ t %g te!h% 3ue % +h !h a% mage " .'urre\$ .* \$ "p'a* %g part or a'' o# t at a mar8e\$'* 'o+er re"o'ut o%( It " pr mar '* u"e\$ #or !e%"or"h p( The e##e!t " a "ta%\$ar\$ graph !" # 'ter& a)a 'a.'e % a'' .ut the mo"t .a" ! . tmap graph !" e\$ tor"( A #am ' ar e=amp'e o# p =e' <at o% !a% .e #ou%\$ % te'e) " o% %e+" a%\$ \$o!ume%tar* pro\$u!t o%"& % +h !h )eh !'e ' !e%"e p'ate" a%\$ #a!e" o# "u"pe!t" at !r me "!e%e" are rout %e'* o."!ure\$ to ma %ta % the pre"umpt o% o# %%o!e%!e& a" % the te'e) " o% "er e" COPS( B*"ta%\$er" a%\$ other" +ho \$o %ot " g% re'ea"e #orm" are a'"o !u"tomar '* p =e' <e\$( Footage o# %u\$ t* 1 %!'u\$ %g ge% ta' a& .utto!8"& or .rea"t"2 " ' 8e+ "e

o."!ure\$ % "ome me\$ a; .e#ore the +ater"he\$ % ma%* !ou%tr e"& % %e+"paper" or ge%era' maga< %e"& or % p'a!e" % +h !h the pu.' ! !a%%ot a)o \$ "ee %g the mage 1"u!h a" o% . ''.oar\$"2( Drug re#ere%!e"& a" +e'' a" ge"ture" !o%" \$ere\$ o."!e%e 1"u!h a" the # %ger2 ma* a'"o .e !e%"ore\$ % th " ma%%er( P =e' <at o% " %ot u"ua''* u"e\$ #or th " purpo"e % # 'm"& D?D"& "u."!r pt o% te'e) " o% "er) !e"& por%ograph* 1e=!ept #or !ou%tr e" % +h !h the 'a+ re3u re" t2( 4he% o."!e%e 'a%guage " !e%"ore\$ .* a% au\$ .'e .'eep& the mouth o# the "pea8er ma* .e p =e' <e\$ to pre)e%t ' p rea\$ %g& o#te% a" % COPS graph ! %/ur e" a%\$ e=!e"" .'oo\$ + '' .e p =e' <e\$( P =e' <at o% ma* a'"o .e u"e\$ to a)o \$ u% %te%t o%a' pro\$u!t p'a!eme%t& or to h \$e e'eme%t" that +ou'\$ \$ate a .roa\$!a"t& "u!h a" \$ate a%\$ t me "tamp" o% home ) \$eo "u.m "" o%"( Ce%"or"h p #or "u!h purpo"e" " mo"t !ommo% o% rea' t* te'e) " o% "er e"( Scan con1#rsion S!a% !o%)er" o% " the pro!e"" o# !o%)ert %g .a" !& 'o+ 'e)e' o./e!t" %to the r !orre"po%\$ %g p =e' map repre"e%tat o%"( Th " " o#te% a% appro= mat o% to the o./e!t& " %!e the #rame .u##er " a \$ "!rete gr \$( The # r"t pro.'em to !o%" \$er " +hether or %ot to \$ra+ a p =e' at a''( For a p =e' to .e re%\$ere\$& t mu"t .e + th % a tr a%g'e& a%\$ t mu"t %ot .e o!!'u\$e\$& or .'o!8e\$ .* a%other p =e'( There are a %um.er o# a'gor thm" to # '' % p =e'" %" \$e a tr a%g'e& the mo"t popu'ar o# +h !h " the "!a%' %e a'gor thm( S %!e t " \$ ## !u't to 8%o+ that the ra"ter <at o% e%g %e + '' \$ra+ a'' p =e'" #rom #ro%t to .a!8& there mu"t .e "ome +a* o# e%"ur %g that p =e'" !'o"e to the ) e+er are %ot o)er+r tte% .* p =e'" #ar a+a*( A < .u##er " the mo"t !ommo% "o'ut o%( The < .u##er " a 0\$ arra* !orre"po%\$ %g to the mage p'a%e +h !h "tore" a \$epth )a'ue #or ea!h p =e'( 4he%e)er a p =e' " \$ra+%& t up\$ate" the < .u##er + th t" \$epth )a'ue( A%* %e+ p =e' mu"t !he!8 t" \$epth )a'ue aga %"t the < .u##er )a'ue .e#ore t " \$ra+%( C'o"er p =e'" are \$ra+% a%\$ #arther p =e'" are \$ "regar\$e\$( To # %\$ out a p =e':" !o'or& te=ture" a%\$ "ha\$ %g !a'!u'at o%" mu"t .e app' e\$( A te=ture map " a . tmap that " app' e\$ to a tr a%g'e to \$e# %e t" 'oo8( Ea!h tr a%g'e )erte= " a'"o a""o! ate\$ + th a te=ture a%\$ a te=ture !oor\$ %ate 1u&)2 #or %orma' 0-\$ te=ture" % a\$\$ t o% to t" po" t o% !oor\$ %ate( E)er* t me a p =e' o% a tr a%g'e " re%\$ere\$& the !orre"po%\$ %g te=e' 1or te=ture e'eme%t2 % the te=ture mu"t .e #ou%\$( Th " " \$o%e .* %terpo'at %g .et+ee% the tr a%g'e" )ert !e" a""o! ate\$ te=ture !oor\$ %ate" .* the p =e'" o%-"!ree% \$ "ta%!e #rom the )ert !e"( I% per"pe!t )e pro/e!t o%"& %terpo'at o% " per#orme\$ o% the te=ture !oor\$ %ate" \$ ) \$e\$ .* the \$epth o# the )erte= to a)o \$ a pro.'em 8%o+% a" per"pe!t )e #ore"horte% %g 1a pro!e"" 8%o+% a" per"pe!t )e te=tur %g2( Be#ore the # %a' !o'or o# the p =e' !a% .e \$e! \$e\$& a ' ght %g !a'!u'at o% mu"t .e per#orme\$ to "ha\$e the p =e'" .a"e\$ o% a%* ' ght" +h !h ma* .e pre"e%t % the "!e%e( There are ge%era''* three ' ght t*pe" !ommo%'* u"e\$ % "!e%e"( D re!t o%a' ' ght" are ' ght" +h !h !ome #rom a " %g'e \$ re!t o% a%\$ ha)e the "ame %te%" t* throughout the e%t re "!e%e( I% rea' ' #e& "u%' ght !ome" !'o"e to .e %g a \$ re!t o%a' ' ght& a" the "u% " "o #ar a+a* that ra*" #rom the "u% appear para''e' to Earth o."er)er" a%\$ the #a''o## " %eg' g .'e( Po %t ' ght" are ' ght" + th a \$e# % te po" t o% % "pa!e a%\$ ra\$ ate ' ght e)e%'* % a'' \$ re!t o%"( Po %t ' ght" are u"ua''* "u./e!t to "ome #orm o# atte%uat o%& or #a'' o## % the %te%" t* o# ' ght %! \$e%t o% o./e!t" #arther a+a*( Rea' ' #e ' ght "our!e" e=per e%!e 3ua\$rat ! #a''o##( F %a''*& "pot' ght" are ' 8e rea'-' #e "pot' ght"& + th a \$e# % te po %t % "pa!e& a \$ re!t o%& a%\$ a% a%g'e \$e# % %g the !o%e o# the "pot' ght( There " a'"o o#te% a% am. e%t ' ght )a'ue that " a\$\$e\$ to a'' # %a' ' ght %g !a'!u'at o%" to ar. trar '* !ompe%"ate #or g'o.a' ''um %at o% e##e!t" +h !h ra"ter <at o% !a% %ot !a'!u'ate !orre!t'*( There are a %um.er o# "ha\$ %g a'gor thm" #or ra"ter <er"( A'' "ha\$ %g a'gor thm" %ee\$ to a!!ou%t #or \$ "ta%!e #rom ' ght a%\$ the %orma' )e!tor o# the "ha\$e\$ o./e!t + th re"pe!t to the %! \$e%t \$ re!t o% o# ' ght( The #a"te"t a'gor thm" " mp'* "ha\$e a'' p =e'" o% a%* g )e% tr a%g'e + th a " %g'e ' ght %g )a'ue& a'"o 8%o+% a" #'at "ha\$ %g( There " %o +a* to !reate the ''u" o% o# "mooth "ur#a!e" th " +a*& e=!ept .* "u.\$ ) \$ %g %to ma%* "ma'' tr a%g'e"( A'gor thm" !a% a'"o "eparate'* "ha\$e )ert !e"& a%\$ %terpo'ate the ' ght %g )a'ue o# the )ert !e" +he% \$ra+ %g p =e'"( Th " " 8%o+% a" Gourau\$ "ha\$ %g( The "'o+e"t

a%\$ mo"t rea' "t ! approa!h " to !a'!u'ate ' ght %g "eparate'* #or ea!h p =e'& a'"o 8%o+% a" Pho%g "ha\$ %g( Th " per#orm" . ' %ear %terpo'at o% o# the %orma' )e!tor" a%\$ u"e" the re"u't to \$o 'o!a' ' ght %g !a'!u'at o%( G#o\$#tric o23#cts The .a" ! geometr ! o./e!t" % !omputer graph !" are u"ua''* !a''e\$ pr m t )e" or graph !" output pr m t )e"( The* %!'u\$e geometr ! e%t t e" ' 8e po %t"& "tra ght a%\$ !ur)e\$ ' %e" a%\$ area" a" +e'' a" !hara!ter "tr %g"( A'' geometr ! pr m t )e" are e)e%tua''* \$e"!r .e\$ % term" o# the r vertices - !oor\$ %ate" that \$e# %e the po %t" them"e')e"& the e%\$po %t" o# ' %e "egme%t"& or the !or%er" o# po'*go%"( The %e=t "e!t o% \$ "!u""e" ho+ the"e pr m t )e" are \$ "p'a*e\$ a%\$ +hat !o%tro' *ou ha)e o)er the r \$ "p'a*( You pro.a.'* ha)e a #a r'* goo\$ \$ea o# +hat a mathemat ! a% mea%" .* the term" po %t& ' %e& a%\$ po'*go%( The Ope%GL mea% %g" are%Wt 3u te the "ame& ho+e)er& a%\$ tW" mporta%t to u%\$er"ta%\$ the \$ ##ere%!e"( The \$ ##ere%!e" ar "e .e!au"e mathemat ! a%" !a% th %8 % a geometr !a''* per#e!t +or'\$& +herea" the re"t o# u" ha)e to \$ea' + th rea'-+or'\$ ' m tat o%"( For e=amp'e& o%e \$ ##ere%!e !ome" #rom the ' m tat o%" o# !omputer-.a"e\$ !a'!u'at o%"( I% a%* Ope%GL mp'eme%tat o%& #'oat %g-po %t !a'!u'at o%" are o# # % te pre! " o%& a%\$ the* ha)e rou%\$-o## error"( Co%"e3ue%t'*& the !oor\$ %ate" o# Ope%GL po %t"& ' %e"& a%\$ po'*go%" "u##er #rom the "ame pro.'em"( A%other \$ ##ere%!e ar "e" #rom the ' m tat o%" o# a . tmappe\$ graph !" \$ "p'a*( O% "u!h a \$ "p'a*& the "ma''e"t \$ "p'a*a.'e u% t " a p =e'& a%\$ a'though p =e'" m ght .e 'e"" tha% 5C577th o# a% %!h + \$e& the* are "t '' mu!h 'arger tha% the mathemat ! a%W" %# % te'* "ma'' 1#or po %t"2 or %# % te'* th % 1#or ' %e"2( 4he% Ope%GL per#orm" !a'!u'at o%"& t a""ume" po %t" are repre"e%te\$ a" )e!tor" o# #'oat %g-po %t %um.er"( Ho+e)er& a po %t " t*p !a''* 1.ut %ot a'+a*"2 \$ra+% a" a " %g'e p =e'& a%\$ ma%* \$ ##ere%t po %t" + th "' ght'* \$ ##ere%t !oor\$ %ate" !ou'\$ .e \$ra+% .* Ope%GL o% the "ame p =e'( The .a" ! pr m t )e" are the #o''o+ %g o%e"( 'oint !ra-in% al%orit.\$s Po %t" that are u% 3ue'* \$e# %e\$ .* the r =- a%\$ *-!oor\$ %ate( Po %t" are u"ua''* %ot \$ra+% them"e')e"( The r ma % #u%!t o% " the \$e"!r pt o% o# other o./e!t" ' 8e ' %e" that !a% .e \$e# %e\$ .* the r t+o e%\$po %t"( A po %t " repre"e%te\$ .* a "et o# #'oat %g-po %t %um.er" !a''e\$ a )erte=( A'' %ter%a' !a'!u'at o%" are \$o%e a" # )ert !e" are three-\$ me%" o%a'( ?ert !e" "pe! # e\$ .* the u"er a" t+o-\$ me%" o%a' 1that "& + th o%'* 4 a%\$ ? !oor\$ %ate"2 are a"" g%e\$ a z !oor\$ %ate e3ua' to <ero .* Ope%GL( To !o%tro' the " <e o# a re%\$ere\$ po %t& u"e g'Po %tS <e12 a%\$ "upp'* the \$e" re\$ " <e % p =e'" a" the argume%t( void !lPoint>ize(%&0loat size) >ets the width in 8i4els 0or rendered 8oints size must ;e !reater than #.# and ;? de0ault is 1.#. The a!tua' !o''e!t o% o# p =e'" o% the "!ree% +h !h are \$ra+% #or )ar ou" po %t + \$th" \$epe%\$" o% +hether a%t a' a" %g " e%a.'e\$( A%t a' a" %g " a te!h% 3ue #or "mooth %g po %t" a%\$ ' %e" a" the*:re re%\$ere\$( I# a%t a' a" %g " \$ "a.'e\$ 1the \$e#au't2&

#ra!t o%a' + \$th" are rou%\$e\$ to %teger + \$th"& a%\$ a "!ree%-a' g%e\$ "3uare reg o% o# p =e'" " \$ra+%( Thu"& # the + \$th " 5(7& the "3uare " 5 p =e' .* 5 p =e'9 # the + \$th " 0(7& the "3uare " 0 p =e'" .* 0 p =e'"& a%\$ "o o%( 4 th a%t a' a" %g e%a.'e\$& a ! r!u'ar group o# p =e'" " \$ra+%& a%\$ the p =e'" o% the .ou%\$ar e" are t*p !a''* \$ra+% at 'e"" tha% #u'' %te%" t* to g )e the e\$ge a "moother appeara%!e( I% th " mo\$e& %o%- %teger + \$th" are%:t rou%\$e\$( Mo"t Ope%GL mp'eme%tat o%" "upport )er* 'arge po %t " <e"( The ma= mum " <e #or a%t a' a"e\$ po %t" " 3uer*a.'e& .ut the "ame %#ormat o% " %ot a)a 'a.'e #or "ta%\$ar\$& a' a"e\$ po %t"( A part !u'ar mp'eme%tat o%& ho+e)er& m ght ' m t the " <e o# "ta%\$ar\$& a' a"e\$ po %t" to %ot 'e"" tha% t" ma= mum a%t a' a"e\$ po %t " <e& rou%\$e\$ to the %eare"t %teger )a'ue( You !a% o.ta % th " #'oat %g-po %t )a'ue .* u" %g GLRPOINTRSIKERRANGE + th g'GetF'oat)12( Lin# !ra-in% al%orit.\$s L %e"& po'*' %e" or !ur)e" !a% .e \$e# %e\$ .* t+o or more po %t"( 4herea" #or a ' %e t+o po %t" are %ee\$e\$& !ur)e" re3u re a\$\$ t o%a' !o%tro' po %t"( Po'*' %e" are !o%%e!te\$ "e3ue%!e" o# ' %e"( I% Ope%GL& line mea%" line se!ment& %ot the mathemat ! a%W" )er" o% that e=te%\$" to %# % t* % .oth \$ re!t o%"( There are ea"* +a*" to "pe! #* a !o%%e!te\$ "er e" o# ' %e "egme%t"& or e)e% a !'o"e\$& !o%%e!te\$ "er e" o# "egme%t"( I% a'' !a"e"& though& the ' %e" !ompr " %g the !o%%e!te\$ "er e" are "pe! # e\$ % term" o# the )ert !e" at the r e%\$po %t"(

'ol %on Po'*go%" are the area" e%!'o"e\$ .* " %g'e !'o"e\$ 'oop" o# ' %e "egme%t"& +here the ' %e "egme%t" are "pe! # e\$ .* the )ert !e" at the r e%\$po %t"( Po'*go%" are t*p !a''* \$ra+% + th the p =e'" % the %ter or # ''e\$ %& .ut *ou !a% a'"o \$ra+ them a" out' %e" or a "et o# po %t"& a" \$e"!r .e\$ % >Po'*go% Deta '"(> I% ge%era'& po'*go%" !a% .e !omp' !ate\$& "o Ope%GL ma8e" "ome "tro%g re"tr !t o%" o% +hat !o%"t tute" a pr m t )e po'*go%( F r"t& the e\$ge" o# Ope%GL po'*go%" !a%Wt %ter"e!t 1a mathemat ! a% +ou'\$ !a'' th " a sim8le 8ol?!on2( Se!o%\$& Ope%GL po'*go%" mu"t .e !o%)e=& mea% %g that the* !a%%ot ha)e %\$e%tat o%"( State\$ pre! "e'*& a reg o% " !o%)e= #& g )e% a%* t+o po %t" % the %ter or& the ' %e "egme%t /o % %g them " a'"o % the %ter or( See F gure 0-0 #or "ome e=amp'e" o# )a' \$ a%\$ %)a' \$ po'*go%"( Ope%GL& ho+e)er& \$oe"%Wt re"tr !t the %um.er o# ' %e "egme%t" ma8 %g up the .ou%\$ar* o# a !o%)e= po'*go%( Note that po'*go%" + th ho'e" !a%Wt .e \$e"!r .e\$( The* are %o%!o%)e=& a%\$ the* !a%Wt .e \$ra+% + th a .ou%\$ar* ma\$e up o# a " %g'e !'o"e\$ 'oop( Be a+are that # *ou pre"e%t Ope%GL + th a %o%!o%)e= # ''e\$ po'*go%& t m ght %ot \$ra+ t a" *ou e=pe!t( For %"ta%!e& o% mo"t "*"tem" %o more tha% the !o%)e= hu'' o# the po'*go% +ou'\$ .e # ''e\$& .ut o% "ome "*"tem"& 'e"" tha% the !o%)e= hu'' m ght .e # ''e\$(

For ma%* app' !at o%"& *ou %ee\$ %o%" mp'e po'*go%"& %o%!o%)e= po'*go%"& or po'*go%" + th ho'e"( S %!e a'' "u!h po'*go%" !a% .e #orme\$ #rom u% o%" o# " mp'e !o%)e= po'*go%"& "ome rout %e" to \$e"!r .e more !omp'e= o./e!t" are pro) \$e\$ % the GLU( The"e rout %e" ta8e !omp'e= \$e"!r pt o%" a%\$ tessellate them& or .rea8 them \$o+% %to group" o# the " mp'er Ope%GL po'*go%" that !a% the% .e re%\$ere\$( 1See Appe%\$ = C #or more %#ormat o% a.out the te""e''at o% rout %e"(2 The rea"o% #or Ope%GLW" re"tr !t o%" o% )a' \$ po'*go% t*pe" " that tW" " mp'er to pro) \$e #a"t po'*go%-re%\$er %g har\$+are #or that re"tr !te\$ !'a"" o# po'*go%"( S %!e Ope%GL )ert !e" are a'+a*" three-\$ me%" o%a'& the po %t" #orm %g the .ou%\$ar* o# a part !u'ar po'*go% \$o%Wt %e!e""ar '* ' e o% the "ame p'a%e % "pa!e( 1O# !our"e& the* \$o % ma%* !a"e" - # a'' the z !oor\$ %ate" are <ero& #or e=amp'e& or # the po'*go% " a tr a%g'e(2 I# a po'*go%W" )ert !e" \$o%Wt ' e % the "ame p'a%e& the% a#ter )ar ou" rotat o%" % "pa!e& !ha%ge" % the ) e+po %t& a%\$ pro/e!t o% o%to the \$ "p'a* "!ree%& the po %t" m ght %o 'o%ger #orm a " mp'e !o%)e= po'*go%( For e=amp'e& mag %e a #ourpo %t 3ua\$r 'atera' +here the po %t" are "' ght'* out o# p'a%e& a%\$ 'oo8 at t a'mo"t e\$ge-o%( You !a% get a %o%" mp'e po'*go% that re"em.'e" a .o+ t e& a" "ho+% % F gure 0-, & +h !h "%Wt guara%tee\$ to re%\$er !orre!t'*( Th " " tuat o% "%Wt a'' that u%u"ua' # *ou appro= mate "ur#a!e" .* 3ua\$r 'atera'" ma\$e o# po %t" '* %g o% the true "ur#a!e( You !a% a'+a*" a)o \$ the pro.'em .* u" %g tr a%g'e"& " %!e a%* three po %t" a'+a*" ' e o% a p'a%e(

R#ctan%l# S %!e re!ta%g'e" are "o !ommo% % graph !" app' !at o%"& Ope%GL pro) \$e" a # ''e\$-re!ta%g'e \$ra+ %g pr m t )e& g'Re!tP12( You !a% \$ra+ a re!ta%g'e a" a po'*go%& a" \$e"!r .e\$ % >Ope%GL Geometr ! Dra+ %g Pr m t )e"&> .ut *our part !u'ar mp'eme%tat o% o# Ope%GL m ght ha)e opt m <e\$ g'Re!tP12 #or re!ta%g'e"( void !l)ect{si0d:(.YP-41\$ .YP-?1\$ .YP-45\$ .YP-?5) void !l)ect{si0d:v(.YP-=v1\$ .YP-=v5) Dra+" the re!ta%g'e \$e# %e\$ .* the !or%er po %t" 141\$ ?12 a%\$ 145\$ ?52( The re!ta%g'e ' e" % the p'a%e z@7 a%\$ ha" " \$e" para''e' to the 4- a%\$ ?-a=e"( I# the )e!tor #orm o# the #u%!t o% " u"e\$& the !or%er" are g )e% .* t+o po %ter" to arra*"& ea!h o# +h !h !o%ta %" a% 1 4\$ ?2 pa r( Note that a'though the re!ta%g'e .eg %" + th a part !u'ar or e%tat o% % three-\$ me%" o%a' "pa!e 1 % the =-* p'a%e a%\$ para''e' to the a=e"2& *ou !a% !ha%ge th " .* app'* %g rotat o%" or other tra%"#ormat o%"( C"r1#s A%* "mooth'* !ur)e\$ ' %e or "ur#a!e !a% .e appro= mate\$ - to a%* ar. trar* \$egree o# a!!ura!* - .* "hort ' %e "egme%t" or "ma'' po'*go%a' reg o%"( Thu"& "u.\$ ) \$ %g !ur)e\$ ' %e" a%\$ "ur#a!e" "u## ! e%t'* a%\$ the% appro= mat %g them + th "tra ght ' %e "egme%t" or #'at po'*go%" ma8e" them appear !ur)e\$ 1"ee F gure 0-B 2( I# *ouWre "8ept !a' that th " rea''* +or8"& mag %e "u.\$ ) \$ %g u%t ' ea!h ' %e "egme%t or po'*go% " "o t %* that tW" "ma''er tha% a p =e' o% the "!ree%(

Ope%GL \$oe" %ot \$ re!t'* "upport re%\$er %g a%* !ur)e" other that ' %e" a%\$ po'*' %e"( Ho+e)er& *ou !a% "amp'e a !ur)e a%\$ \$ra+ t a" a ' %e "tr p& e(g(&; 0loat 4\$ ? !l*e!in(%&'&IN-'>.)IP) 0or (int tF# t <F 1 t LF .#1) { com8ute"urve( t\$ H4\$ H?) !l3erte450(4\$ ?) : !l-nd() You !a% a\$/u"t the "tep-" <e to \$eterm %e ho+ ma%* ' %e "egme%t" to \$ra+( A\$\$ %g ' %e "egme%t" + '' %!rea"e the a!!ura!* o# the !ur)e& .ut "'o+ \$o+% the re%\$er %g( The GLU \$oe" ha)e "ome "pe! a' <e\$ ' .rar e" to a"" "t + th ge%erat %g a%\$ re%\$er %g !ur)e"( For e=amp'e& the #o''o+ %g !o\$e re%\$er" a \$ "8 + th a ho'e % t" !e%ter& !e%tere\$ a.out the <-a= "( %&+Nuadric N F !luNewOuadric() !luGis9(N\$ inner)adius\$ outer)adius\$ slice"ount\$ 1) !luGeleteOuadric(N) Op#nGL G#o\$#tric Dra-in% 'ri\$iti1#s No+ that *ou:)e "ee% ho+ to "pe! #* )ert !e"& *ou "t '' %ee\$ to 8%o+ ho+ to te'' Ope%GL to !reate a "et o# po %t"& a ' %e& or a po'*go% #rom tho"e )ert !e"( To \$o th "& *ou .ra!8et ea!h "et o# )ert !e" .et+ee% a !a'' to g'Beg %12 a%\$ a !a'' to g'E%\$12( The argume%t pa""e\$ to g'Beg %12 \$eterm %e" +hat "ort o# geometr ! pr m t )e " !o%"tru!te\$ #rom the )ert !e"( For e=amp'e& E=amp'e 0-, "pe! # e" the )ert !e" #or the po'*go% "ho+% % F gure .e'o+( A% e=amp'e o# # ''e\$ po'*go%( !l*e!in(%&'P(&Y%(N) !l3erte450(#.#\$ #.#) !l3erte450(#.#\$ /.#) !l3erte450(<.#\$ /.#) !l3erte450(M.#\$ 1.6)

## !l3erte450(<.#\$ #.#) !l-nd()

I# *ou ha\$ u"e\$ GLRPOINTS %"tea\$ o# GLRPOLYGON& the pr m t )e +ou'\$ ha)e .ee% " mp'* the # )e po %t" "ho+% % F gure 0-I( Ta.'e 0-0 % the #o''o+ %g #u%!t o% "ummar* #or g'Beg %12 ' "t" the te% po"" .'e argume%t" a%\$ the !orre"po%\$ %g t*pe o# pr m t )e( void !l*e!in(%&enum mode) Bar9s the ;e!innin! o0 a verte42data list that descri;es a !eometric 8rimitive. .he t?8e o0 8rimitive is indicated ;? mode\$ which can ;e an? o0 the values shown in .a;le ;elow.

## 1al"# GLRPOINTS GLRLINES GLRLINERSTRIP GLRLINERLOOP GLRTRIANGLES

\$#anin% I%\$ ) \$ua' po %t" pa r" o# )ert !e" %terprete\$ a" %\$ ) \$ua' ' %e "egme%t" "er e" o# !o%%e!te\$ ' %e "egme%t" "ame a" a.o)e& + th a "egme%t a\$\$e\$ .et+ee% 'a"t a%\$ # r"t )ert !e" tr p'e" o# )ert !e" %terprete\$ a" tr a%g'e"

GLRTRIANGLERSTRIP ' %8e\$ "tr p o# tr a%g'e" GLRTRIANGLERFAN GLROUARDS GLROUARDRSTRIP GLRPOLYGON ' %8e\$ #a% o# tr a%g'e" 3ua\$rup'e" o# )ert !e" %terprete\$ a" #our-" \$e\$ po'*go%" ' %8e\$ "tr p o# 3ua\$r 'atera'" .ou%\$ar* o# a " mp'e& !o%)e= po'*go%

void !l-nd(void)

## Bar9s the end o0 a verte42data list.

No other Ope%GL !omma%\$" are )a' \$ .et+ee% a g'Beg %12 a%\$ g'E%\$12 pa r& a%\$ ma8 %g mo"t other Ope%GL !a''" ge%erate" a% error( Some )erte= arra* !omma%\$"& "u!h a" g'E%a.'eC' e%tState12 a%\$ g'?erte=Po %ter12& +he% !a''e\$ .et+ee% g'Beg %12 a%\$ g'E%\$12& ha)e u%\$e# %e\$ .eha) or .ut \$o %ot %e!e""ar '* ge%erate a% error( 1A'"o& rout %e" re'ate\$ to Ope%GL& "u!h a" g'JP12 rout %e" ha)e u%\$e# %e\$ .eha) or .et+ee% g'Beg %12 a%\$ g'E%\$12(2 The"e !a"e" "hou'\$ .e a)o \$e\$& a%\$ \$e.ugg %g them ma* .e more \$ ## !u't( Note& ho+e)er& that o%'* Ope%GL !omma%\$" are re"tr !te\$9 *ou !a% !erta %'* %!'u\$e other programm %g-'a%guage !o%"tru!t" 1e=!ept #or !a''"& "u!h a" the a#oreme%t o%e\$ g'JP12 rout %e"2( For e=amp'e& .e'o+\$ra+" a% out' %e\$ ! r!'e( #de0ine PI /.1<16P5M6/6QPQ %&int circle'8oints F 1## !l*e!in(%&'&IN-'&((P) 0or (i F # i < circle'8oints iLL) { an!le F 5=PI=iDcircle'8oints !l3erte450(cos(an!le)\$ sin(an!le)) : !l-nd() Note; Th " e=amp'e "%:t the mo"t e## ! e%t +a* to \$ra+ a ! r!'e& e"pe! a''* # *ou %te%\$ to \$o t repeate\$'*( The graph !" !omma%\$" u"e\$ are t*p !a''* )er* #a"t& .ut th " !o\$e !a'!u'ate" a% a%g'e a%\$

!a''" the " %12 a%\$ !o"12 rout %e" #or ea!h )erte=9 % a\$\$ t o%& there:" the 'oop o)erhea\$( 1A%other +a* to !a'!u'ate the )ert !e" o# a ! r!'e " to u"e a GLU rout %e9 "ee >Oua\$r !"; Re%\$er %g Sphere"& C*' %\$er"& a%\$ D "8">( I# *ou %ee\$ to \$ra+ 'ot" o# ! r!'e"& !a'!u'ate the !oor\$ %ate" o# the )ert !e" o%!e a%\$ "a)e them % a% arra* a%\$ !reate a \$ "p'a* ' "t& or u"e )erte= arra*" to re%\$er them(U%'e"" the* are .e %g !omp 'e\$ %to a \$ "p'a* ' "t& a'' g'?erte=P12 !omma%\$" "hou'\$ appear .et+ee% "ome g'Beg %12 a%\$ g'E%\$12 !om. %at o%( 1I# the* appear e'"e+here& the* \$o%:t a!!omp' "h a%*th %g(2 I# the* appear % a \$ "p'a* ' "t& the* are e=e!ute\$ o%'* # the* appear .et+ee% a g'Beg %12 a%\$ a g'E%\$12( A'though ma%* !omma%\$" are a''o+e\$ .et+ee% g'Beg %12 a%\$ g'E%\$12& )ert !e" are ge%erate\$ o%'* +he% a g'?erte=P12 !omma%\$ " ""ue\$( At the mome%t g'?erte=P12 " !a''e\$& Ope%GL a"" g%" the re"u't %g )erte= the !urre%t !o'or& te=ture !oor\$ %ate"& %orma' )e!tor %#ormat o%& a%\$ "o o%( To "ee th "& 'oo8 at the #o''o+ %g !o\$e "e3ue%!e( The # r"t po %t " \$ra+% % re\$& a%\$ the "e!o%\$ a%\$ th r\$ o%e" % .'ue& \$e"p te the e=tra !o'or !omma%\$"( !l*e!in(%&'P(IN.>) !l"olor/0(#.#\$ 1.#\$#.#) !l"olor/0(1.#\$ #.#\$#.#) !l3erte4(...) !l"olor/0(1.#\$ 1.#\$#.#) !l"olor/0(#.#\$ #.#\$1.#) !l3erte4(...) !l3erte4(...) !l-nd() D= !reen =D D= red =D D= ?ellow =D D= ;lue =D

You !a% u"e a%* !om. %at o% o# the 0B )er" o%" o# the g'?erte=P12 !omma%\$ .et+ee% g'Beg %12 a% \$g'E%\$12& a'though % rea' app' !at o%" a'' the !a''" % a%* part !u'ar %"ta%!e te%\$ to .e o# the "ame #orm( I# *our )erte=-\$ata "pe! # !at o% " !o%" "te%t a%\$ repet t )e 1#or e=amp'e& g'Co'orP& g'?erte=P& g'Co'orP& g'?erte=P&(((2& *ou ma* e%ha%!e *our program:" per#orma%!e .* u" %g )erte= arra*"( 1See >?erte= Arra*"(>2 4. CLI''ING

5. GEOMETRIC TRANSFORMATION I% a\$\$ t o% to geometr ! o./e!t"& geometr ! tra%"#ormat o%" p'a* a !ru! a' ro'e % !omputer graph !"( Geometr ! tra%"#ormat o%" !a% .e u"e\$ to po" t o% o./e!t"& (e(& to "h #t them to a%other po" t o% or to rotate them& to !ha%ge the "hape o# o./e!t"& #or %"ta%!e to "tret!h or "hr %8 them % o%e \$ re!t o%& or to mo)e o./e!t" or !ha%ge the "hape o# o./e!t" "tep .* "tep % a% mate\$ "!e%e"( Be#ore \$ "!u"" %g geometr ! tra%"#ormat o%" % more \$eta '& t " %e!e""ar* to e=p'a % "ome ge%era' !o%)e%t o%"( I% !omputer graph !"& po %t" a" +e'' a" )e!tor" are u"e\$( From a pure'* mathemat !a' po %t o# ) e+& .oth !a% .e repre"e%te\$ a" e'eme%t" o# the "pa!e R% & (e(& a" a tup'e o# rea' %um.er"( E"pe! a''* % ph*" !"& t " )er* mporta%t to \$ "t %gu "h !'ear'* .et+ee% the"e t+o !o%!ept" o# po %t" a%\$ )e!tor"( I% the #rame+or8 o# th " .oo8 a%\$ #rom the ) e+po %t o# !omputer graph !"& t " )er* !ommo% to "+ t!h .et+ee% the %terpretat o%" o# a tup'e o# rea' %um.er" a" a po %t a%\$ a" a )e!tor& g ) %g more #'e= . ' t* % ha%\$' %g !erta % matter"( A tup'e 1=5 & ( ( ( & =% 2 R% m ght o!!ur % o%e e3uat o% a" a po %t a%\$ % the %e=t e3uat o% t m ght .e %terprete\$ a" a )e!tor( Hope#u''*& ph*" ! "t" + '' to'erate the a.u"e o# %otat o% % the !o%te=t o# th " .oo8( For e3uat o%" + th % th " .oo8& !o'um% )e!tor" + '' .e u"e\$ !o%" "te%t'*( 4 th % the te=t& po %t" are "omet me" +r tte% a" ro+ )e!tor" % or\$er

to a)o \$ "tret!h %g o# te=t ' %e"( I% tho"e !a"e" +here a po %t " e=p' ! t'* u%\$er"too\$ a" a !o'um% )e!tor& the "*m.o' #or tra%"po" %g )e!tor" + '' .e u"e\$& (e(& the po %t + '' .e +r tte% a" 1=& *2 R0 a%\$ 1=& *& <2 R, & re"pe!t )e'*( The \$ot pro\$u!t o# t+o )e!tor" u a%\$ ) + '' .e \$e%ote\$ % the #o''o+ %g +a*& +h !h " a'"o )er* !ommo% % "tat "t !"; The mo"t mporta%t geometr ! tra%"#ormat o%" are "!a' %g& rotat o%& "hear %g a%\$ tra%"'at o%( A "!a' %g 'ea\$" to "tret!h %g or "hr %8 %g o# o./e!t" % the \$ re!t o% o# the =- a%\$ the *-a= "( A "!a' %g S1"= & "* 2 map" the po %t 1=& *2 to the po %t 1= & * 2 g )e% .* e3uat o% #or "!a' %g #a!tor " the "!a' %g #a!tor % the \$ re!t o% o# the =-a= "( I# X"= X Y 5 ho'\$"& the% a "tret!h %g % the \$ re!t o% o# the =-a= " " !arr e\$ out( For X"= X Z 5 "hr %8 %g ta8e" p'a!e( I# "= " %egat )e& % a\$\$ t o% to "tret!h %g or "hr %8 %g % the =-\$ re!t o%& a re#'e!t o% + th re"pe!t to the *-a= " " app' e\$( I% the "ame +a*& "* 'ea\$" to "tret!h %g or "hr %8 %g % the \$ re!t o% o# the *-a= " a%\$ a %egat )e )a'ue o# "* %!orporate" a% a\$\$ t o%a' re#'e!t o% + th re"pe!t to the =-a= "(

F gure 0(5, S!a' %g app' e\$ to a re!ta%g'e App'* %g a "!a' %g to a% o./e!t mea%" that the "!a' %g " !arr e\$ out po %t-+ "e( The "ame ho'\$" #or a'' other geometr ! tra%"#ormat o%"( The* !arr* out po %t+ "e tra%"#ormat o%" o# o./e!t"( A" a% e=amp'e& the tra%"'at o% + th the "!a' %g #a!tor" "= @ 0 a%\$ "* @ 7(6 " !o%" \$ere\$& "tret!h %g a'o%g the =-a= " .* the #a!tor 0 a%\$ "hr %8 %g % the \$ re!t o% o# the *-a= " .* the #a!tor 7(6( The app' !at o% o# th " "!a' %g to the re!ta%g'e +ho"e 'o+er 'e#t !or%er " 'o!ate\$ at the po %t 1F7&5072 a%\$ +ho"e upper r ght !or%er " at 15F7&5F72 * e'\$" a re!ta%g'e +ho"e + \$th ha" \$ou.'e\$ + th ha'# the or g %a' he ght( But % a\$\$ t o%& the !e%tre o# the re!ta%g'e " a'"o tra%"#orme\$ "o that the tra%"#orme\$ re!ta%g'e " "h #te\$ to the 'o+er r ght !ompare\$ to the or g %a' re!ta%g'e( A "!a' %g " a'+a*" !arr e\$ out + th re"pe!t to the or g % o# the !oor\$ %ate "*"tem( App'* %g a "!a' %g to a% o./e!t that " %ot !e%tre\$ arou%\$ the or g % o# the !oor\$ %ate "*"tem + '' 'ea\$ to a tra%"'at o% o# the 1!e%tre o# the2 o./e!t % a\$\$ t o% to the "!a' %g( A%other mporta%t group o# geometr ! tra%"#ormat o%" are rotat o%" that are \$eterm %e\$ .* a " %g'e parameter& the rotat o% a%g'e( The rotat o% " !arr e\$ out a%t !'o!8+ "e arou%\$ the or g % o# the !oor\$ %ate "*"tem % !a"e o# a po" t )e a%g'e( A %egat )e a%g'e mea%" that the rotat o% " !arr e\$ out % a !'o!8+ "e ma%%er( The rotat o% R1[2 .* the a%g'e [ map" the po %t 1=& *2 to the po %t 1= & * 2 g )e% .* A rotat o% " a'+a*" !arr e\$ out arou%\$ the or g % o# the !oor\$ %ate "*"tem( There#ore& a " m 'ar "h #t %g e##e!t a" % the !a"e o# "!a' %g" happe%"& +he% a% o./e!t " %ot !e%tre\$ arou%\$ the or g %( I% # gure 0(5B a rotat o% .* a% a%g'e o# B6Q +a" !arr e\$ out& mapp %g the or g %a' re!ta%g'e to the re!ta%g'e \$ra+% + th \$a"he\$ ' %e"( The "hear tra%"#ormat o% " a%other e'eme%tar* geometr ! tra%"#ormat o% that !au"e" a !erta %

\$e#ormat o% o# o./e!t"( S m 'ar to "!a' %g"& the "hear tra%"#ormat o% re3u re" t+o parameter"& ho+e)er& %ot o% the ma % \$ ago%a' o# the tra%"#ormat o% matr =& .ut o% the other t+o po" t o%"( App'* %g a "hear tra%"#ormat o% Sh1"= & "* 2 to a po %t 1=& *2 * e'\$" the po %t 1= & * 2 + th the %e+ !oor\$ %ate" A" % the !a"e o# "!a' %g" a%\$ rotat o%"& "hear tra%"#ormat o%" are !arr e\$ out + th re"pe!t to the or g % o# the !oor\$ %ate "*"tem& "o that a% o./e!t that " %ot !e%tre\$ arou%\$ the or g % + '' %ot o%'* .e \$e#orme\$ .* a "hear tra%"#ormat o%& .ut a'"o "h #te\$( The \$a"he\$ re!ta%g'e " o.ta %e\$ #rom the or g %a' re!ta%g'e % # gure .e'o+ .* app'* %g a "hear tra%"#ormat o% + th the parameter" "= @ 5 a%\$ "* @ 7(

## F gure 0(5B A rotat o% app' e\$ to a re!ta%g'e

F gure 0(56 A "hear tra%"#ormat o% app' e\$ to a re!ta%g'e S %!e "* @ 7 +a" !ho"e% #or th " "hear tra%"#ormat o%& the "hear %g ta8e" p'a!e % the \$ re!t o% o# the *a= "( 4he% the "hear %g "hou'\$ .e !arr e\$ out % the \$ re!t o% o# the =-a= "& "= @ 7 mu"t ho'\$( The 'a"t e'eme%tar* or pr m t )e geometr ! tra%"#ormat o% to .e !o%" \$ere\$ here " )er* " mp'e& .ut \$ ##er" #rom the other three t*pe" o# e'eme%tar* tra%"#ormat o%" that +ere %tro\$u!e\$ "o #ar % a% mporta%t a"pe!t( A tra%"'at o% T 1\$= & \$* 2 !au"e" a "h #t .* the )e!tor \$ @ 1\$= & \$* 2 ( Th " mea%" the tra%"'at o% map" the po %t 1=& *2 to the po %t( I% # gure .e'o+ a tra%"'at o% \$e# %e\$ .* the )e!tor \$ @ 15B7& F72 to a re!ta%g'e& mapp %g t to the \$a"he\$ re!ta%g'e(

F gure 0(5I Tra%"'at o% o# a re!ta%g'e I% !o%tra"t to the other tra%"#ormat o%" %tro\$u!e\$ "o #ar& tra%"'at o%" are %ot ' %ear& "o that the* !a%%ot .e repre"e%te\$ % term" o# matr = mu't p' !at o%( A matr = mu't p' !at o% + '' a'+a*" 'ea)e the <ero )e!tor u%!ha%ge\$& +herea" a tra%"'at o% + '' "h #t a'' po %t" %!'u\$ %g the or g % o# the !oor\$ %ate "*"tem !orre"po%\$ %g to the <ero )e!tor( Tra%"'at o%" are a## %e& .ut %ot ' %ear mapp %g"( 4 th % !omputer graph !"& more !omp'e= tra%"#ormat o%" are u"ua''* \$e"!r .e\$ or ge%erate\$ a" !ompo" t o%" o# e'eme%tar* geometr ! tra%"#ormat o%"( A tra%"#ormat o% !ompo"e\$ o# "!a' %g"& rotat o%" a%\$ "hear tra%"#ormat o%" !a% .e "pe! # e\$ .* a " %g'e matr =& o.ta %e\$ a" the pro\$u!t o# the matr !e" e%!o\$ %g the !orre"po%\$ %g e'eme%tar* tra%"#ormat o%"( 4he% a'"o tra%"'at o%" are %)o')e\$& the !ompo" t o% o# tra%"#ormat o% !a% %o 'o%ger .e !ompute\$ .* " mp'e matr = mu't p' !at o% a%\$ repre"e%te\$ .* a " %g'e matr =( I# a'' th " +a" po"" .'e + th % matr = !a'!u'u"& th " +ou'\$ .e a great a\$)a%tage % term" o# memor* /u"t a " %g'e matr = " re3u re\$ to repre"e%t a !omp'e= tra%"#ormat o%" a%\$ % term" o# !omputat o%a' e## ! e%!* " %!e a'' that +ou'\$ .e %ee\$e\$ #or #a"t !omputat o%" are e## ! e%t mp'eme%tat o%" o# matr = operat o%"( I% or\$er to repre"e%t a'"o tra%"'at o%" % matr = #orm& a%other repre"e%tat o% o# the !oor\$ %ate" o# po %t" " %tro\$u!e\$( The %e=t "e!t o% + '' \$ "!u"" th " a'ter%at )e repre"e%tat o% !a''e\$ homoge%eou" !oor\$ %ate" % more \$eta '( Ho\$o%#n#o"s coor!inat#s Th " "e!t o% %tro\$u!e" the repre"e%tat o% o# po %t" % the t+o-\$ me%" o%a' p'a%e % homoge%eou" !oor\$ %ate"( The "ame !o%!ept + '' a'"o .e app' e\$ 'ater o% to po %t" % the three-\$ me%" o%a' "pa!e #or the "ame rea"o%& to a''o+ the repre"e%tat o% o# ,D tra%"'at o%" % matr = #orm( Homoge%eou" !oor\$ %ate" u"e a% a\$\$ t o%a' \$ me%" o% #or the repre"e%tat o% o# po %t"( The po %t 1=& *& <2 % homoge%eou" !oor\$ %ate" " \$e%t # e\$ + th the po %t % Carte" a% !oor\$ %ate"( The <-!ompo%e%t o# a po %t % homoge%eou" !oor\$ %ate" mu"t %ot .e <ero( 4he% the po %t 1=7 & *7 2 % Carte" a% !oor\$ %ate" ha" to .e tra%"#orme\$ %to homoge%eou" !oor\$ %ate"& the repre"e%tat o% 1=7 & *7 & 52 !a% .e u"e\$( Th " "& ho+e)er& %ot the o%'* +a* to repre"e%t the po %t 1=7 & *7 2 % homoge%eou" !oor\$ %ate"( A%* repre"e%tat o% o# the #orm 1< \=7 & < \*7 & <2 +here < @ 7 e%!o\$e" a'"o the "ame po %t( The po %t" L1=& *& <2 R, X 1=& *& <2 @ 1< \ =7 & < \ *7 & <2M ' e o% a ' %e % the "pa!e R, pa"" %g through the or g % o# the !oor\$ %ate "*"tem( The ' %e " g )e% .* the "*"tem o# e3uat o%" = N =7 \ < @ 7& * N *7 \ < @ 7( A%* po %t o% th " ' %e& e=!ept the or g % o# the !oor\$ %ate "*"tem& " a repre"e%tat )e % homoge%eou" !oor\$ %ate" o# the po %t 1=7 & *7 2 % Carte" a% !oor\$ %ate"( F = %g a )a'ue #or < #or the repre"e%tat o% % homoge%eou" !oor\$ %ate"& #or %"ta%!e < @ 5& the Carte" a% =C*-p'a%e " repre"e%te\$ .* a para''e' p'a%e + th the !orre"po%\$ %g !o%"ta%t <-)a'ue( F gure 0(5E ''u"trate" the"e re'at o%"( A'' po %t" o% the ' %e "ho+% % # gure 0(5E repre"e%t the "ame po %t % the t+o-\$ me%" o%a' Carte" a% p'a%e R0 ( Choo" %g a !o%"ta%t )a'ue #or <& #or %"ta%!e o%e o# the p'a%e" "ho+% % # gure 0(5E& the !orre"po%\$ %g p'a%e " a homoge%eou" repre"e%tat )e o# the Carte" a% p'a%e R0 ( The or g % o# the Carte" a% !oor\$ %ate "*"tem !orre"po%\$" to a%* po %t o# the #orm 17& 7& <2 1< @ 72 % homoge%eou" !oor\$ %ate"( Th " po %t " %o 'o%ger a %e!e""ar* # =e\$ po %t o# a ' %ear mapp %g % term" o# homoge%eou" !oor\$ %ate"& (e(& a ' %ear mapp %g #rom R, to R, ( The ' %ear mapp %g !a% map th " po %t to a%other po %t % homoge%eou" !oor\$ %ate"(

I% homoge%eou" !oor\$ %ate" a tra%"'at o% !a% %o+ .e +r tte% a" matr = mu't p' !at o%; The other e'eme%tar* tra%"#ormat o% !a% .e e=te%\$e\$ to homoge%eou" !oor\$ %ate" % a "tra ght#or+ar\$ ma%%er& 'ea\$ %g to the #o''o+ %g "et o# tra%"#ormat o% matr !e"; Rotat o%" a%\$ tra%"'at o%" pre"er)e 'e%gth" a%\$ a%g'e"( S!a' %g" a%\$ "hear tra%"#ormat o%" \$o %ot pre"er)e 'e%gth" a%\$ a%g'e" % ge%era'& .ut at 'ea"t para''e' ' %e" + '' .e mappe\$ to para''e' ' %e" aga %( 4 th th " matr = repre"e%tat o% % homoge%eou" !oor\$ %ate"& the !ompo" t o% o# geometr ! tra%"#ormat o%" !a% .e !ompute\$ .* matr = mu't p' !at o%( A'' matr !e"& %tro\$u!e\$ #or the e'eme%tar* geometr ! tra%"#ormat o%" are o# the #orm( It " ea"* to )er #* that the pro\$u!t o# t+o "u!h matr !e" re"u't" aga % % a matr = o# the "ame #orm( There#ore& geometr ! tra%"#ormat o%" are u"ua''* repre"e%te\$ a%\$ "tore\$ % th " +a* % !omputer graph !"( Th " \$oe" %ot o%'* app'* to tra%"#ormat o%" that operate o% the t+o-\$ me%" o%a' p'a%e& .ut a'"o to tra%"#ormat o%" % the three-\$ me%" o%a' "pa!e( It " %o+ o.) ou" that a graph !" !ar\$ o# a !omputer mu"t amo%g other th %g" .e a.'e to !arr* out matr = operat o%" a" #a"t a" po"" .'e(

Or g %a'

Tra%"'at o%

Tra%"'at o%-Rotat o%

Rotat o%

Rotat o%-Tra%"'at o%

Us#s an! A2"s#s o& Ho\$o%#n#o"s Coor!inat#s Homoge%eou" !oor\$ %ate" pro) \$e a \$ ##ere%t repre"e%tat o% #or Carte" a% !oor\$ %ate"& a%\$ !a%%ot .e treate\$ % 3u te the "ame +a*( For e=amp'e& !o%" \$er the m \$po %t .et+ee% t+o po %t" p5 @ 15& 52 a%\$ p0 @ 16& 62( The m \$po %t " 1 5 ] p0 2C0 @ 1,& ,2( 4e !a% repre"e%t the"e po %t" % homoge%eou" !oor\$ %ate" a" p5 @ 15& 5& 52 a%\$ p0 @ 16& 6& 52( D re!t'* app'* %g the "ame !omputat o% a" a.o)e g )e" the "ame re"u't %g po %t; 1,& ,& 52( Ho+e)er& +e !a% a'"o repre"e%t the"e po %t" a" p^5 @ 10& 0& 02 a%\$ p^0 @ 16& 6& 52( 4e the% ha)e 1_^5 ] p^0 2C0 @ 1EC0& EC0& ,C02& +h !h !oore"po%\$" to the Carte" a% po %t 1EC,& EC,2( Th " " a \$ ##ere%t po %t& a%\$ ''u"trate" that +e !a%%ot .' %\$'* app'* geometr ! operat o%" to homoge%eou" !oor\$ %ate"( The " mp'e"t "o'ut o% " to a'+a*" !o%)ert homoge%eou" !oor\$ %ate" to Carte" a% !oor\$ %ate"( That "a \$& there are "e)era' mporta%t operat o%" that !a% .e per#orme\$ !orre!t'*

% term" o# homoge%eou" !oor\$ %ate"& a" #o''o+"( Trans&or\$ation in Op#nGL Ope%GL ma%age" t+o B ` B tra%"#ormat o% matr !e"; the mo\$e') e+ matr =& a%\$ the pro/e!t o% matr =( 4he%e)er *ou "pe! #* geometr* 1u" %g g'?erte=2& the )ert !e" are tra%"#orme\$ .* the !urre%t mo\$e' ) e+ matr = a%\$ the% the !urre%t pro/e!t o% matr =( He%!e& *ou \$o%:t ha)e to per#orm the"e tra%"#ormat o%" *our"e'#( You !a% mo\$ #* the e%tr e" o# the"e matr !e" at a%* t me( Ope%GL pro) \$e" "e)era' ut ' t e" #or mo\$ #* %g the"e matr !e"( The mo\$e') e+ matr = " %orma''* u"e\$ to repre"e%t geometr ! tra%"#ormat o%" o# o./e!t"9 the pro/e!t o% matr = " %orma''* u"e\$ to "tore the !amera tra%"#ormat o%( For %o+& +e:'' #o!u" /u"t o% the mo\$e') e+ matr =& a%\$ \$ "!u"" the !amera tra%"#ormat o% 'ater( To mo\$ #* the !urre%t matr =& # r"t "pe! #* +h !h matr = " go %g to .e ma% pu'ate\$; u"e g'Matr =Mo\$e1GL MODE to mo\$ #* the mo\$e') e+ matr =( The mo\$e') e+ matr = !a% the% .e % t a' <e\$ to the \$e%t t* + th g'Loa\$I\$e%t t*12( The matr = !a% .e ma% pu'ate\$ .* \$ re!t'* # '' %g t" )a'ue"& mu't p'* %g t .* a% ar. trar* matr =& or u" %g the #u%!t o%" Ope%GL pro) \$e" to mu't p'* the matr = .* "pe! # ! tra%"#ormat o% matr !e" 1g'Rotate& g'Tra%"'ate& a%\$ g'S!a'e2( Note that the"e tra%"#ormat o%" r ght-mu't p'* the !urre%t matr =9 th " !a% .e !o%#u" %g " %!e t mea%" that *ou "pe! #* tra%"#ormat o%" % the re)er"e o# the o.) ou" or\$er( E=er! "e; +h* \$oe" Ope%GL r ght-mu't p'* the !urre%t matr =A Ope%GL pro) \$e" a "ta!8" to a"" "t + th h erar!h !a' tra%"#ormat o%"( There " o%e "ta!8 #or the mo\$e' ) e+ matr = a%\$ o%e #or the pro/e!t o% matr =( Ope%GL pro) \$e" rout %e" #or pu"h %g a%\$ popp %g matr !e" o% the "ta!8( The #o''o+ %g e=amp'e \$ra+" a% upper arm a%\$ #orearm + th "hou'\$er a%\$ e'.o+ /o %t"( The !urre%t mo\$e') e+ matr = " pu"he\$ o%to the "ta!8 a%\$ poppe\$ at the e%\$ o# the re%\$er %g& "o& #or e=amp'e& a%other arm !ou'\$ .e re%\$ere\$ + thout the tra%"#ormat o%" #rom re%\$er %g th " arm a##e!t %g t" mo\$e') e+ matr =( S %!e ea!h Ope%GL tra%"#ormat o% " app' e\$ .* mu't p'* %g a matr = o% the r ghtha%\$ " \$e o# the mo\$e') e+ matr =& the tra%"#ormat o%" o!!ur % re)er"e or\$er( Here& the upper arm " tra%"'ate\$ "o that t" "hou'\$er po" t o% " at the or g %& the% t " rotate\$& a%\$ # %a''* t " tra%"'ate\$ "o that the "hou'\$er " % t" appropr ate +or'\$-"pa!e po" t o%( S m 'ar'*& the #orearm " tra%"'ate\$ to rotate a.out t" e'.o+ po" t o%& the% t " tra%"'ate\$ "o that the e'.o+ mat!he" t" po" t o% % upper arm !oor\$ %ate"( !lPushBatri4() !l.ranslate0(world>houlderR\$ world>houlderY\$ #.#0) draw>houlderEoint() !l)otate0(shoulder)otation\$ #.#0\$ #.#0\$ 1.#0) !l.ranslate0(2u88erArm>houlderR\$ 2u88erArm>houlderY\$ #.#0) draw+88erArm>ha8e() !l.ranslate0(u88erArm-l;owR\$ u88erArm-l;owY\$ #.#0) draw-l;owEoint() !l)otate0(el;ow)otation\$ #.#0\$ #.#0\$ 1.#0) !l.ranslate0(20orearm-l;owR\$ 20orearm-l;owY\$ #.#0) draw,orearm>ha8e() !lPo8Batri4() 6. CUR,ES The " mp'e"t !ur)e " a ' %e "egme%t or " mp'* a ' %e( A "e3ue%!e o# ' %e +here the #o''o+ %g ' %e "tart" +here the pre) ou" o%e e%\$" " !a''e\$ a po'*' %e( I# the 'a"t ' %e "egme%t o# a po'*' %e e%\$" +here the

# r"t ' %e "egme%t "tarte\$& the po'*' %e " !a''e\$ a po'*go%( For )ar ou" app' !at o%"V#or %"ta%!e #or mo\$e'' %g "ur#a!e"Va\$\$ t o%a' propert e" o# po'*go%" are re3u re\$( O%e o# "u!h propert e" " that the po'*go% "hou'\$ %ot o)er'ap + th t"e'#( Co%)e= t* " a%other mporta%t propert* that " o#te% %ee\$e\$( A po'*go% or& more ge%era''*& a% area or a reg o% " !o%)e= # +he%e)er t+o po %t" are + th % the reg o% the !o%%e!t %g ' %e .et+ee% the"e t+o po %t" ' e" !omp'ete'* %" \$e the reg o% a" +e''( F gure .e'o+" a "e'#-o)er'app %g po'*go%& a %o%!o%)e= po'*go% a%\$ a !o%)e= po'*go%( For the %o%!o%)e= po'*go% t+o po %t" %" \$e the po'*go% are !ho"e% a%\$ !o%%e!te\$ .* a \$otte\$ ' %e that ' e" %ot !omp'ete'* %" \$e the po'*go%( F gure 0(I "ho+" "e'#-o)er'app %g po'*go% I% a\$\$ t o% to ' %e" a%\$ p e!e+ "e ' %ear po'*' %e"& !ur)e" are a'"o !ommo% % !omputer graph !"( I% mo"t !a"e"& !ur)e" are \$e# %e\$ a" parametr ! po'*%om a'" that !a% a'"o .e atta!he\$ to ea!h other ' 8e ' %e" % a po'*' %e( Here t " "u## ! e%t to u%\$er"ta%\$ the pr %! p'e o# ho+ the parameter" o# a !ur)e %#'ue%!e t" "hape( I% a\$\$ t o% to the e%\$po %t" o# the !ur)e& o%e or more !o%tro' po %t" ha)e to .e "pe! # e\$( U"ua''*& t+o !o%tro' po %t" are u"e\$ 'ea\$ %g to a !u. ! !ur)e or o%'* o%e !o%tro' po %t " u"e\$ % or\$er to \$e# %e a 3ua\$rat ! !ur)e( The !ur)e .eg %" a%\$ e%\$" % the t+o "pe! # e\$ e%\$po %t"( I% ge%era'& t + '' %ot pa"" through !o%tro' po %t"( The !o%tro' po %t" \$e# %e the \$ re!t o% o# the !ur)e % the t+o e%\$po %t"( I% the !a"e o# a 3ua\$rat ! !ur)e + th o%e !o%tro' po %t o%e !a% mag %e the ' %e" !o%%e!t %g the !o%tro' po %t + th the t+o e%\$po %t"( The !o%%e!t %g ' %e" are the ta%ge%t" o# the 3ua\$rat ! !ur)e % the t+o e%\$po %t"( F gure .e'o+ ''u"trate" the \$e# % t o% o# a 3ua\$rat ! !ur)e o% the 'e#t-ha%\$ " \$e( The 3ua\$rat ! !ur)e " g )e% .* t+o e%\$po %t" a%\$ o%e !o%tro' po %t through +h !h the !ur)e \$oe" %ot pa""( The ta%ge%t" % the e%\$po %t" are a'"o "ho+% here a" \$otte\$ ' %e"( For a !u. ! !ur)e a" "ho+% o% the r ght ha%\$ " \$e o# the # gure& the ta%ge%t" % the t+o e%\$po %t" !a% .e \$e# %e\$ %\$epe%\$e%t'* .* the t+o !o%tro' po %t"( F gure 0(E De# % t o% o# 3ua\$rat ! a%\$ !u. ! !ur)e" 4he% # tt %g 3ua\$rat ! or !u. ! !ur)e" together % or\$er to #orm a 'o%ger& more !omp' !ate\$ !ur)e& t " %ot "u## ! e%t to " mp'* u"e the e%\$po %t o# the pre) ou" !ur)e a" a "tart %g po %t #or the %e=t !ur)e( The re"u't %g /o %t !ur)e +ou'\$ .e !o%t %uou"& .ut %ot "mooth& (e(& "harp .e%\$" m ght o!!ur( I% or\$er to a)o \$ "harp .e%\$"& the ta%ge%t o# the e%\$po %t o# the pre) ou" !ur)e a%\$ the #o''o+ %g !ur)e mu"t po %t %to the "ame \$ re!t o%( Th " mea%" the e%\$po %t& +h !h " e3ua' to the "tart %g po %t o# the %e=t !ur)e& a%\$ the t+o !o%tro' po %t" \$e# % %g the t+o ta%ge%t" mu"t .e !o'' %ear( Th " mea%" the* mu"t ' e o% the "ame ' %e( There#ore& the # r"t !o%tro' po %t o# a "u!!ee\$ %g !ur)e mu"t .e o% the ' %e \$e# %e\$ .* the 'a"t !o%tro' a%\$ e%\$po %t o# the pre) ou" !ur)e( I% the "ame +a* a !ur)e !a% .e # tte\$ to a ' %e + thout !au" %g a "harp .e%\$ .* 'o!at %g the # r"t !o%tro' po %t o% the pro'o%gat o% o# the ' %e( F gure ''u"trate" th " pr %! p'e( F gure 0(F F tt %g a !u. ! !ur)e to a ' %e + thout "harp .e%\$" Other mporta%t !ur)e" % !omputer graph !" are ! r!'e"& e'' p"e" a%\$ ! r!u'ar a%\$ e'' pt ! ar!"( I% the "ame "e%"e a" po'*go%"& ! r!'e" a%\$ e'' p"e" \$e# %e area"( Area" are .ou%\$e\$ .* a !'o"e\$ !ur)e( 4he% o%'* the "he'' or marg % o# the area "hou'\$ .e \$ra+%& there " %o \$ ##ere%!e to \$ra+ %g ar. trar* !ur)e"( I% !o%tra"t to ' %e" a%\$ " mp'e !ur)e"& area" !a% .e # ''e\$ .* !o'our" a%\$ te=ture"( From the a'gor thm !

po %t o# ) e+& # '' %g o# a% area " )er* \$ ##ere%t #rom \$ra+ %g !ur)e"( A=e"-para''e' re!ta%g'e"& +ho"e " \$e" are para''e' to the !oor\$ %ate a=e"& p'a* a% mporta%t ro'e % !omputer graph !"( A'though the* !a% .e u%\$er"too\$ a" "pe! a' !a"e" o# po'*go%"& the* are " mp'er to ha%\$'e " %!e t " a'rea\$* "u## ! e%t to "pe! #* t+o oppo" %g )ert !e"( I%"tea\$ o# "pe! #* %g a po'*go% or the .ou%\$ar* \$ re!t'* % or\$er to \$e# %e a% area& t " "omet me" more !o%)e% e%t to !o%"tru!t a more !omp' !ate\$ area .* !om. % %g pre) ou"'* \$e# %e\$ area" u" %g "et-theoret ! operat o%"( The mo"t mporta%t operat o%" are u% o%& %ter"e!t o%& \$ ##ere%!e a%\$ "*mmetr ! \$ ##ere%!e( The u% o% /o %" t+o area" to a 'arger area +herea" the r %ter"e!t o% !o%" "t" o# the part .e'o%g %g to .oth area"( The \$ ##ere%!e o# a% area + th a%other remo)e" a'' part" #rom the # r"t area that a'"o .e'o%g to the "e!o%\$ area( The "*mmetr ! \$ ##ere%!e !orre"po%\$" to a po %t+ "e e=!'u" )e OR-operat o% app' e\$ to the t+o area"( The "*mmetr ! \$ ##ere%!e " the u% o% o# the t+o area" + thout the r %ter"e!t o%( F gure 0(D "ho+" the re"u't" o# app'* %g the"e operat o%" to t+o area" % the #orm o# a ! r!'e a%\$ a re!ta%g'e(

F gure 0(D U% o%& %ter"e!t o%& \$ ##ere%!e a%\$ "*mmetr ! \$ ##ere%!e o# a ! r!'e a%\$ a re!ta%g'e Geometr ! tra%"#ormat o%" ' 8e "!a' %g"( The* pro) \$e a%other +a* o# !o%"tru!t %g %e+ area" #rom a'rea\$* e= "t %g o%e"( 7. FRACTALS 18. COM'UTER ANIMATION Computer a% mat o% " the u"e o# !omputer" to !reate a% mat o%"( There are a #e+ \$ ##ere%t +a*" to ma8e !omputer a% mat o%"( O%e " ,D a% mat o%( O%e +a* to !reate !omputer a% mat o%" " to !reate o./e!t" a%\$ the% re%\$er them( Th " metho\$ pro\$u!e" per#e!t a%\$ three \$ me%" o%a' 'oo8 %g a% mat o%"( A%other +a* to !reate !omputer a% mat o% " to u"e "ta%\$ar\$ !omputer pa %t %g too'" a%\$ to pa %t " %g'e #rame" a%\$ !ompo" te them( The"e !a% 'ater .e e ther "a)e\$ a" a mo) e # 'e or output to ) \$eo( O%e 'a"t metho\$ o# ma8 %g !omputer a% mat o%" " to u"e tra%" t o%" a%\$ other "pe! a' e##e!t" ' 8e morph %g to mo\$ #* e= "t %g mage" a%\$ ) \$eo( Computer graph !" are a%* t*pe" o# mage" !reate\$ u" %g a%* 8 %\$ o# !omputer( There " a )a"t amou%t o# t*pe" o# mage" a !omputer !a% !reate( A'"o& there are /u"t a" ma%* +a*" o# !reat %g tho"e mage"( Image" !reate\$ .* !omputer" !a% .e )er* " mp'e& "u!h a" ' %e" a%\$ ! r!'e"& or e=treme'* !omp'e= "u!h a" #ra!ta'" a%\$ !omp' !ate\$ re%\$ere\$ a% mat o%"( I# *ou +a%t to !reate *our o+% !omputer graph !"& %o matter ho+ " mp'e or !omp'e=& *ou ha)e to 8%o+ a #e+ th %g" a.out !omputer"& !omputer graph !"& a%\$ ho+ the* +or8( O%e o# the mo"t e=! t %g th %g" *ou !a% \$o o% a graph !" !omputer " \$ra+ p !ture" that mo)e( 4hether

*ou:re a% e%g %eer tr* %g to "ee a'' " \$e" o# a me!ha% !a' part *ou:re \$e" g% %g& a p 'ot 'ear% %g to #'* a% a rp'a%e u" %g a " mu'at o%& or mere'* a !omputer-game a# ! o%a\$o& t:" !'ear that a% mat o% " a% mporta%t part o# !omputer graph !"( I% a mo) e theater& mot o% " a!h e)e\$ .* ta8 %g a "e3ue%!e o# p !ture" a%\$ pro/e!t %g them at 0B per "e!o%\$ o% the "!ree%( Ea!h #rame " mo)e\$ %to po" t o% .eh %\$ the 'e%"& the "hutter " ope%e\$& a%\$ the #rame " \$ "p'a*e\$( The "hutter " mome%tar '* !'o"e\$ +h 'e the # 'm " a\$)a%!e\$ to the %e=t #rame& the% that #rame " \$ "p'a*e\$& a%\$ "o o%( A'though *ou:re +at!h %g 0B \$ ##ere%t #rame" ea!h "e!o%\$& *our .ra % .'e%\$" them a'' %to a "mooth a% mat o%( 1The o'\$ Char' e Chap' % mo) e" +ere "hot at 5I #rame" per "e!o%\$ a%\$ are %ot !ea.'* /er8*(2 I% #a!t& mo"t mo\$er% pro/e!tor" \$ "p'a* ea!h p !ture t+ !e at a rate o# BF per "e!o%\$ to re\$u!e #' !8er %g( Computer-graph !" "!ree%" t*p !a''* re#re"h 1re\$ra+ the p !ture2 appro= mate'* I7 to EI t me" per "e!o%\$& a%\$ "ome e)e% ru% at a.out 507 re#re"he" per "e!o%\$( C'ear'*& I7 per "e!o%\$ " "moother tha% ,7& a%\$ 507 " marg %a''* .etter tha% I7( Re#re"h rate" #a"ter tha% 507& ho+e)er& are .e*o%\$ the po %t o# \$ m % "h %g retur%"& " %!e the huma% e*e " o%'* "o goo\$( The 8e* rea"o% that mot o% p !ture pro/e!t o% +or8" " that ea!h #rame " !omp'ete +he% t " \$ "p'a*e\$( Suppo"e *ou tr* to \$o !omputer a% mat o% o# *our m '' o%-#rame mo) e + th a program ' 8e th "; o8en'window() 0or (i F # i < 1###### iLL) { clear'the'window() draw'0rame(i) wait'until'a'5<th'o0'a'second'is'over() : I# *ou a\$\$ the t me t ta8e" #or *our "*"tem to !'ear the "!ree% a%\$ to \$ra+ a t*p !a' #rame& th " program g )e" more a%\$ more \$ "tur. %g re"u't" \$epe%\$ %g o% ho+ !'o"e to 5C0B "e!o%\$ t ta8e" to !'ear a%\$ \$ra+( Suppo"e the \$ra+ %g ta8e" %ear'* a #u'' 5C0B "e!o%\$( Item" \$ra+% # r"t are ) " .'e #or the #u'' 5C0B "e!o%\$ a%\$ pre"e%t a "o' \$ mage o% the "!ree%9 tem" \$ra+% to+ar\$ the e%\$ are %"ta%t'* !'eare\$ a" the program "tart" o% the %e=t #rame( The* pre"e%t at .e"t a gho"t' 8e mage& " %!e #or mo"t o# the 5C0B "e!o%\$ *our e*e " ) e+ %g the !'eare\$ .a!8grou%\$ %"tea\$ o# the tem" that +ere u%'u!8* e%ough to .e \$ra+% 'a"t( The pro.'em " that th " program \$oe"%:t \$ "p'a* !omp'ete'* \$ra+% #rame"9 %"tea\$& *ou +at!h the \$ra+ %g a" t happe%"( Mo"t Ope%GL mp'eme%tat o%" pro) \$e \$ou.'e-.u##er %g - har\$+are or "o#t+are that "upp' e" t+o !omp'ete !o'or .u##er"( O%e " \$ "p'a*e\$ +h 'e the other " .e %g \$ra+%( 4he% the \$ra+ %g o# a #rame " !omp'ete& the t+o .u##er" are "+appe\$& "o the o%e that +a" .e %g ) e+e\$ " %o+ u"e\$ #or \$ra+ %g& a%\$ ) !e )er"a( Th " " ' 8e a mo) e pro/e!tor + th o%'* t+o #rame" % a 'oop9 +h 'e o%e " .e %g pro/e!te\$ o% the "!ree%& a% art "t " \$e"perate'* era" %g a%\$ re\$ra+ %g the #rame that:" %ot ) " .'e( A" 'o%g a" the art "t " 3u !8 e%ough& the ) e+er %ot !e" %o \$ ##ere%!e .et+ee% th " "etup a%\$ o%e +here a'' the #rame" are a'rea\$* \$ra+% a%\$ the pro/e!tor " " mp'* \$ "p'a* %g them o%e a#ter the other( 4 th \$ou.'e-.u##er %g& e)er* #rame " "ho+% o%'* +he% the \$ra+ %g " !omp'ete9 the ) e+er %e)er "ee" a part a''* \$ra+% #rame( A mo\$ # e\$ )er" o% o# the pre!e\$ %g program that \$oe" \$ "p'a* "mooth'* a% mate\$ graph !" m ght 'oo8 ' 8e th "; o8en'window'in'dou;le';u00er'mode() 0or (i F # i < 1###### iLL) { clear'the'window() draw'0rame(i)

swa8'the';u00ers() : The Re#re"h That Pau"e" For "ome Ope%GL mp'eme%tat o%"& % a\$\$ t o% to " mp'* "+app %g the ) e+a.'e a%\$ \$ra+a.'e .u##er"& the "+apRtheR.u##er"12 rout %e +a t" u%t ' the !urre%t "!ree% re#re"h per o\$ " o)er "o that the pre) ou" .u##er " !omp'ete'* \$ "p'a*e\$( Th " rout %e a'"o a''o+" the %e+ .u##er to .e !omp'ete'* \$ "p'a*e\$& "tart %g #rom the .eg %% %g( A""um %g that *our "*"tem re#re"he" the \$ "p'a* I7 t me" per "e!o%\$& th " mea%" that the #a"te"t #rame rate *ou !a% a!h e)e " I7 #rame" per "e!o%\$ 1 #p"2& a%\$ # a'' *our #rame" !a% .e !'eare\$ a%\$ \$ra+% % u%\$er 5CI7 "e!o%\$& *our a% mat o% + '' ru% "mooth'* at that rate( 4hat o#te% happe%" o% "u!h a "*"tem " that the #rame " too !omp' !ate\$ to \$ra+ % 5CI7 "e!o%\$& "o ea!h #rame " \$ "p'a*e\$ more tha% o%!e( I#& #or e=amp'e& t ta8e" 5CB6 "e!o%\$ to \$ra+ a #rame& *ou get ,7 #p"& a%\$ the graph !" are \$'e #or 5C,7-5CB6@5CD7 "e!o%\$ per #rame& or o%e-th r\$ o# the t me( I% a\$\$ t o%& the ) \$eo re#re"h rate " !o%"ta%t& +h !h !a% ha)e "ome u%e=pe!te\$ per#orma%!e !o%"e3ue%!e"( For e=amp'e& + th the 5CI7 "e!o%\$ per re#re"h mo% tor a%\$ a !o%"ta%t #rame rate& *ou !a% ru% at I7 #p"& ,7 #p"& 07 #p"& 56 #p"& 50 #p"& a%\$ "o o% 1I7C5& I7C0& I7C,& I7CB& I7C6& (((2( That mea%" that # *ou:re +r t %g a% app' !at o% a%\$ gra\$ua''* a\$\$ %g #eature" 1"a* t:" a #' ght " mu'ator& a%\$ *ou:re a\$\$ %g grou%\$ "!e%er*2& at # r"t ea!h #eature *ou a\$\$ ha" %o e##e!t o% the o)era'' per#orma%!e *ou "t '' get I7 #p"( The%& a'' o# a "u\$\$e%& *ou a\$\$ o%e %e+ #eature& a%\$ the "*"tem !a%:t 3u te \$ra+ the +ho'e th %g % 5CI7 o# a "e!o%\$& "o the a% mat o% "'o+" #rom I7 #p" to ,7 #p" .e!au"e t m ""e" the # r"t po"" .'e .u##er-"+app %g t me( A " m 'ar th %g happe%" +he% the \$ra+ %g t me per #rame " more tha% 5C,7 "e!o%\$ - the a% mat o% \$rop" #rom ,7 to 07 #p"( I# the "!e%e:" !omp'e= t* " !'o"e to a%* o# the mag ! t me" 15CI7 "e!o%\$& 0CI7 "e!o%\$& ,CI7 "e!o%\$& a%\$ "o o% % th " e=amp'e2& the% .e!au"e o# ra%\$om )ar at o%& "ome #rame" go "' ght'* o)er the t me a%\$ "ome "' ght'* u%\$er( The% the #rame rate " rregu'ar& +h !h !a% .e ) "ua''* \$ "tur. %g( I% th " !a"e& # *ou !a%:t " mp' #* the "!e%e "o that a'' the #rame" are #a"t e%ough& t m ght .e .etter to a\$\$ a% %te%t o%a'& t %* \$e'a* to ma8e "ure the* a'' m ""& g ) %g a !o%"ta%t& "'o+er& #rame rate( I# *our #rame" ha)e \$ra"t !a''* \$ ##ere%t !omp'e= t e"& a more "oph "t !ate\$ approa!h m ght .e %e!e""ar*( Mot o% @ Re\$ra+ ] S+ap The "tru!ture o# rea' a% mat o% program" \$oe" %ot \$ ##er too mu!h #rom th " \$e"!r pt o%( U"ua''*& t " ea" er to re\$ra+ the e%t re .u##er #rom "!rat!h #or ea!h #rame tha% to # gure out +h !h part" re3u re re\$ra+ %g( Th " " e"pe! a''* true + th app' !at o%" "u!h a" three-\$ me%" o%a' #' ght " mu'ator" +here a t %* !ha%ge % the p'a%e:" or e%tat o% !ha%ge" the po" t o% o# e)er*th %g out" \$e the + %\$o+( I% mo"t a% mat o%"& the o./e!t" % a "!e%e are " mp'* re\$ra+% + th \$ ##ere%t tra%"#ormat o%" a the ) e+po %t o# the ) e+er mo)e"& or a !ar mo)e" \$o+% the roa\$ a . t& or a% o./e!t " rotate\$ "' ght'*( I# " g% # !a%t re!omputat o% " re3u re\$ #or %o%-\$ra+ %g operat o%"& the atta %a.'e #rame rate o#te% "'o+" \$o+%( Keep % m %\$& ho+e)er& that the \$'e t me a#ter the "+apRtheR.u##er"12 rout %e !a% o#te% .e u"e\$ #or "u!h !a'!u'at o%"( Ope%GL \$oe"%:t ha)e a "+apRtheR.u##er"12 !omma%\$ .e!au"e the #eature m ght %ot .e a)a 'a.'e o% a'' har\$+are a%\$& % a%* !a"e& t:" h gh'* \$epe%\$e%t o% the + %\$o+ "*"tem( For e=amp'e& # *ou are u" %g the J 4 %\$o+ S*"tem a%\$ a!!e"" %g t \$ re!t'*& *ou m ght u"e the #o''o+ %g GLJ rout %e; )o \$ g'JS+apBu##er"1D "p'a* P\$p*& 4 %\$o+ + %\$o+29 1See Appe%\$ = C #or e3u )a'e%t rout %e" #or other + %\$o+ "*"tem"(2 I# *ou are u" %g the GLUT ' .rar*& *ou:'' +a%t to !a'' th " rout %e; )o \$ g'utS+apBu##er"1)o \$29

E=amp'e .e'o+ ''u"trate" the u"e o# g'utS+apBu##er"12 % a% e=amp'e that \$ra+" a "p %% %g "3uare( The #o''o+ %g e=amp'e a'"o "ho+" ho+ to u"e GLUT to !o%tro' a% %put \$e) !e a%\$ tur% o% a%\$ o## a% \$'e #u%!t o%( I% th " e=amp'e& the mou"e .utto%" togg'e the "p %% %g o% a%\$ o##(

E=amp'e; Dou.'e-Bu##ere\$ Program; \$ou.'e(! #include <%&D!l.h> #include<%&D!lu.h> #include<%&D!lut.h> #include<stdli;.h> static %&0loat s8in F #.# void init(void) { !l"lear"olor (#.#\$ #.#\$ #.#\$ #.#) !l>hadeBodel (%&',&A.) : void dis8la?(void) { !l"lear(%&'"(&()'*+,,-)'*I.) !lPushBatri4() !l)otate0(s8in\$ #.#\$ #.#\$ 1.#) !l"olor/0(1.#\$ 1.#\$ 1.#) !l)ect0(256.#\$ 256.#\$ 56.#\$ 56.#) !lPo8Batri4() !lut>wa8*u00ers() : void s8inGis8la?(void) { s8in F s8in L 5.# i0 (s8in > /M#.#) s8in F s8in 2 /M#.# !lutPost)edis8la?() :

void resha8e(int w\$ int h) { !l3iew8ort (#\$ #\$ (%&sizei) w\$ (%&sizei) h) !lBatri4Bode(%&'P)(E-".I(N) !l&oadIdentit?() !l(rtho(26#.#\$ 6#.#\$ 26#.#\$ 6#.#\$ 21.#\$ 1.#) !lBatri4Bode(%&'B(G-&3I-W) !l&oadIdentit?() : void mouse(int ;utton\$ int state\$ int 4\$ int ?) { switch (;utton) { case %&+.'&-,.'*+..(NA i0 (state FF %&+.'G(WN) !lutIdle,unc(s8inGis8la?) ;rea9 case %&+.'BIGG&-'*+..(NA i0 (state FF %&+.'G(WN) !lutIdle,unc(N+&&) ;rea9 de0aultA ;rea9 : : D= = )eNuest dou;le ;u00er dis8la? mode. = )e!ister mouse in8ut call;ac9 0unctions =D int main(int ar!c\$ char== ar!v) { !lutInit(Har!c\$ ar!v) !lutInitGis8la?Bode (%&+.'G(+*&- I %&+.')%*) !lutInitWindow>ize (56#\$ 56#) !lutInitWindowPosition (1##\$ 1##) !lut"reateWindow (ar!vJ#K) init () !lutGis8la?,unc(dis8la?) !lut)esha8e,unc(resha8e) !lutBouse,unc(mouse) !lutBain&oo8() return # :

11.RENDERING Re%\$er %g " the pro!e"" a !omputer u"e" to !reate a% mage #rom a \$ata # 'e( Mo"t ,D graph !" program" are %ot !apa.'e o# \$ra+ %g the +ho'e "!e%e o% the ru% + th a'' the !o'or"& te=ture"& ' ght"& a%\$ "ha\$ %g( I%"tea\$& the u"er ha%\$'e" a me"h +h !h " a rough repre"e%tat o% o# a% o./e!t"( 4he% the u"er " "at "# e\$ + th the me"h& he the% re%\$er" the mage(

A me"h

A re%\$ere\$ mage

A + re #rame Th " "%Wt rea''* a re%\$er %g metho\$& .* \$e# % t o%( Mo"t ,D graph !" program" repre"e%t o./e!t" a" me"he"( 4hat happe%" % + re #rame re%\$er %g "& e)er* "e!t o% o# the m"eh get" !o'ore\$ % + th the a)erage !o'or o# the te=ture( Th " !ome" % u"e#u'' #or "pe! a' e##e!t"& a%\$ #or 3u !8 pre) e+"( To ta8e + re #rame re%\$er %g o%e "tep #urther& "ome program" \$o a pro!e"" !a''e\$ h \$\$e% ' %e remo)a'( It " /u"t ' 8e %orma' + re #rame re%\$er %g& e=!ept the part" o# the me"h that +ou'\$ %ot .e ) " .'e # the me"h +a" a "o' \$ are %ot re%\$ere\$( Re%\$er %g u"ua''* ta8e" a 'o%g t me( The t me t ta8e" to re%\$er a% mage \$epe%\$" o% the 3ua' t* o# re%\$er %g( There are a !oup'e o# \$ ##ere%t 3ua' t e" o# re%\$er %g(