交互式计算机图形学第五版17章课后题答案.docx
《交互式计算机图形学第五版17章课后题答案.docx》由会员分享,可在线阅读,更多相关《交互式计算机图形学第五版17章课后题答案.docx(17页珍藏版)》请在冰豆网上搜索。
交互式计算机图形学第五版17章课后题答案
Angel:
InteractiveComputerGraphics,FifthEdition
Chapter1Solutions
Themainadvantageofthepipelineisthateachprimitivecanbe
processedindependently.Notonlydoesthisarchitectureleadtofast
performance,itreducesmemoryrequirementsbecauseweneednotkeepall
objectsavailable.Themaindisadvantageisthatwecannothandlemost
globaleffectssuchasshadows,reflections,andblendinginaphysically
correctmanner.
WederivethisalgorithmlaterinChapter6.First,wecanformthe
(
tetrahedronbyfindingfourequallyspacedpointsonaunitspherecentered
attheorigin.Oneapproachistostartwithonepointonthezaxis
(0,0,1).Wethencanplacetheotherthreepointsinaplaneofconstantz.
Oneofthesethreepointscanbeplacedontheyaxis.Tosatisfythe
requirementthatthepointsbeequidistant,thepointmustbeat
(0,2p2/3,−1/3).Theothertwocanbefoundbysymmetrytobeat
(−
p6/3,−
p2/3,−1/3)and(p6/3,−
p2/3,−1/3).
、
Wecansubdivideeachfaceofthetetrahedronintofourequilateral
trianglesbybisectingthesidesandconnectingthebisectors.However,the
bisectorsofthesidesarenotontheunitcirclesowemustpushthese
pointsouttotheunitcirclebyscalingthevalues.Wecancontinuethis
processrecursivelyoneachofthetrianglescreatedbythebisectionprocess.
InExercise,wesawthatwecouldintersectthelineofwhichthe
linesegmentispartindependentlyagainsteachofthesidesofthewindow.
Wecoulddothisprocessiteratively,eachtimeshorteningthelinesegment
ifitintersectsonesideofthewindow.
(
Inaone–pointperspective,twofacesofthecubeisparalleltothe
projectionplane,whileinatwo–pointperspectiveonlytheedgesofthe
cubeinonedirectionareparalleltotheprojection.Inthegeneralcaseofa
three–pointperspectivetherearethreevanishingpointsandnoneofthe
edgesofthecubeareparalleltotheprojectionplane.
Eachframefora480x640pixelvideodisplaycontainsonlyabout
300kpixelswhereasthe2000x3000pixelmovieframehas6Mpixels,or
about18timesasmanyasthevideodisplay.Thus,itcantake18timesas
]
muchtimetorendereachframeifthereisalotofpixel-levelcalculations.
TherearesinglebeamCRTs.Oneschemeistoarrangethephosphors
inverticalstripes(red,green,blue,red,green,....).Themajordifficultyis
thatthebeammustchangeveryrapidly,approximatelythreetimesasfast
aeachbeaminathreebeamsystem.Theelectronicsinsuchasystemthe
electroniccomponentsmustalsobemuchfaster(andmoreexpensive).
?
Chapter2Solutions
Wecansolvethisproblemseparatelyinthexandydirections.The
transformationislinear,thatisxs=ax+b,ys=cy+d.Wemust
maintainproportions,sothatxsinthesamerelativepositioninthe
viewportasxisinthewindow,hence
x−xmin
xmax−xmin
=
xs−u
%
w
xs=u+w
x−xmin
xmax−xmin
.
Likewise
ys=v+h
x−xmin
ymax−ymin
、
.
Mostpracticaltestsworkonalinebylinebasis.Usuallyweuse
scanlines,eachofwhichcorrespondstoarowofpixelsintheframebuffer.
Ifwecomputetheintersectionsoftheedgesofthepolygonwithaline
passingthroughit,theseintersectionscanbeordered.Thefirst
intersectionbeginsasetofpointsinsidethepolygon.Thesecond
intersectionleavesthepolygon,thethirdreentersandsoon.
Therearetwofundamentalapproaches:
vertexlistsandedgelists.
Withvertexlistswestorethevertexlocationsinanarray.Themeshis
@
representedasalistofinteriorpolygons(thosepolygonswithnoother
polygonsinsidethem).Eachinteriorpolygonisrepresentedasanarrayof
pointersintothevertexarray.Todrawthemesh,wetraversethelistof
interiorpolygons,drawingeachpolygon.
Onedisadvantageofthevertexlististhatifwewishtodrawtheedgesin
themesh,byrenderingeachpolygonsharededgesaredrawntwice.We
canavoidthisproblembyforminganedgelistoredgearray,eachelement
isapairofpointerstoverticesinthevertexarray.Thus,wecandraweach
edgeoncebysimplytraversingtheedgelist.However,thesimpleedgelist
hasnoinformationonpolygonsandthusifwewanttorenderthemeshin
(
someotherwaysuchasbyfillinginteriorpolygonswemustaddsomething
tothisdatastructurethatgivesinformationastowhichedgesformeach
polygon.
Aflexiblemeshrepresentationwouldconsistofanedgelist,avertexlist
andapolygonlistwithpointerssowecouldknowwhichedgesbelongto
whichpolygonsandwhichpolygonsshareagivenvertex.
TheMaxwelltrianglecorrespondstothetrianglethatconnectsthe
red,green,andblueverticesinthecolorcube.
|
Considerthelinesdefinedbythesidesofthepolygon.Wecanassign
adirectionforeachoftheselinesbytraversingtheverticesina
counter-clockwiseorder.Oneverysimpletestisobtainedbynotingthat
anypointinsidetheobjectisontheleftofeachoftheselines.Thus,ifwe
substitutethepointintotheequationforeachofthelines(ax+by+c),we
shouldalwaysgetthesamesign.
Thereareeightverticesandthus256=28possibleblack/white
colorings.Ifweremovesymmetries(black/whiteandrotational)thereare
14uniquecases.SeeAngel,InteractiveComputerGraphics(Third
!
Edition)orthepaperbyLorensenandKlineinthereferences.
Chapter3Solutions
Thegeneralproblemishowtodescribeasetofcharactersthatmight
havethickness,curvature,andholes(suchasinthelettersaandq).
Supposethatweconsiderasimpleexamplewhereeachcharactercanbe
approximatedbyasequenceoflinesegments.Onepossibilityistousea
>
move/linesystemwhere0isamoveand1aline.Thenacharactercanbe
describedbyasequenceoftheform(x0,y0,b0),(x1,y1,b1),(x2,y2,b2),.....
wherebiisa0or1.ThisapproachisusedintheexampleintheOpenGL
ProgrammingGuide.Amoreelaboratefontcanbedevelopedbyusing
polygonsinsteadoflinesegments.
Thereareacoupleofpotentialproblems.Oneisthattheapplication
programcanmapdifferentpointsinobjectcoordinatestothesamepoint
inscreencoordinates.Second,agivenpositiononthescreenwhen
transformedbackintoobjectcoordinatesmaylieoutsidetheuser’s
。
window.
Eachscanisallocated1/60second.Foragivenscanwehavetotake
10%ofthetimefortheverticalretracewhichmeansthatwestarttodraw
scanlinenat.9n/(60*1024)secondsfromthebeginningoftherefresh.
Butallocating10%ofthistimeforthehorizontalretraceweareatpixelm
onthislineattime.81nm/(60*1024).
Whenthedisplayischanging,primitivesthatmoveorareremoved
fromthedisplaywillleaveatraceormotionbluronthedisplayasthe
(
phosphorspersist.Longpersistencephosphorshavebeenusedintextonly
displayswheremotionblurislessofaproblemandthelongpersistence
givesaverystableflicker-freeimage.
Chapter4Solutions
Ifthescalingmatrixisuniformthen
RS=RS(α,α,α)=αR=SR
·
ConsiderRx(θ),ifwemultiplyandusethestandardtrigonometric
identitiesforthesineandcosineofthesumoftwoangles,wefind
Rx(θ)Rx(φ)=Rx(θ+φ)
Bysimplymultiplyingthematriceswefind
T(x1,y1,z1)T(x2,y2,z2)=T(x1+x2,y1+y2,z1+z2)
Thereare12degreesoffreedominthethree–dimensionalaffine
transformation.Considerapointp=[x,y,z,1]Tthatistransformedto
p_=[x_y_,z_,1]TbythematrixM.Hencewehavetherelationship
p_=MpwhereMhas12unknowncoefficientsbutpandp_areknown.
%
Thuswehave3equationsin12unknowns(thefourthequationissimply
theidentity1=1).Ifwehave4suchpairsofpointswewillhave12
equationsin12unknownswhichcouldbesolvedfortheelementsofM.
Thusifweknowhowaquadrilateralistransformedwecandeterminethe
affinetransformation.
Intwodimensions,thereare6degreesoffreedominMbutpandp_have
onlyxandycomponents.Henceifweknow3pointsbothbeforeandafter
transformation,wewillhave6equationsin6unknownsandthusintwo
dimensionsifweknowhowatriangleistransformedwecandeterminethe
affinetransformation.
¥
Itiseasytoshowbysimplymultiplyingthematricesthatthe
concatenationoftworotationsyieldsarotationandthattheconcatenation
oftwotranslationsyieldsatranslation.Ifwelookattheproductofa
rotationandatranslation,wefindthattheleftthreecolumnsofRTare
theleftthreecolumnsofRandtherightcolumnofRTistheright
columnofthetranslationmatrix.IfwenowconsiderRTR_whereR_isa
rotationmatrix,theleftthreecolumnsareexactlythesameastheleft
threecolumnsofRR_andtheandrightcolumnstillhas1asitsbottom
element.Thus,theformisthesameasRTwithanalteredrotation(which
;
istheconcatenationofthetworotations)andanalteredtranslation.
Inductively,wecanseethatanyfurtherconcatenationswithrotationsand
translationsdonotalterthisform.
Ifwedoatranslationby-hweconverttheproblemtoreflectionabout
alinepassingthroughtheorigin.Frommwecanfindananglebywhich
wecanrotatesothelineisalignedwitheitherthexoryaxis.Nowreflect
aboutthexoryaxis.Finallyweundotherotationandtranslationsothe
sequenceisoftheformT−1R−1SRT.
.
Themostsensibleplacetoputtheshearissecondsothattheinstance
transformationbecomesI=TRHS.Wecanseethatthisordermakes
senseifweconsideracubecenteredattheoriginwhosesidesarealigned
withtheaxes.Thescalegivesusthedesiredsizeandproportions.The
shearthenconvertstherightparallelepipedtoageneralparallelepiped.