Vous êtes sur la page 1sur 5

//Logo Image

PDF Version
Lastupdated:YehLiangHsu(20101212).
Note:ThisisthecoursematerialforME550Geometricmodelingandcomputergraphics,YuanZeUniversity.Partofthismaterialis
adaptedfromCAD/CAM Theory and Practice, by Ibrahim Zeid, McGrawHill, 1991.This material is be used strictly for teaching and
learningofthiscourse.

HiddenLineandSurface
1.Vectorgraphicsandrastergraphics
Vectorgraphicdeviceswereintroducedinthemid1960s.Thedisplayprocessorreadsthedisplaylist,thelistofgraphiccommandssent
fromtheapplicationprogram,storedinthedisplayunitandcasttheelectronbeamsontothedisplaydevice.Thoughvectordevicescanachieve
highresolution(e.g.,4096by4096),thecostofsuchdevicesishigh.
Autodesk launched AutoCAD in 1982, which is the first commercially successful 2D vectorbased drafting program. Vector graphics
employsgeometricelementslikepoints,lines,curves,andpolygonstorepresentimages.Sincetheseelementsaredefinedmathematically,
theycanbestoredinadatabaseandlatermanipulated,forexample,copied,moved,rotated,scaled,arrayed.

Raster graphic device, which were introduced in the mid 1970s, is now the main stream of graphic display devices. The display
processorreceivesthegraphicscommandsfromtheapplicationprograms,convertsthemintoapixelbypixelrepresentation,
andstoresthoserasterimagesintheframebuffer.Thedisplayprocessoralsoreadsthecontentofthebufferandcaststheelectronbeams
ontophosphorcoatinginsidethesurfaceofthedisplaydevice. Lightemissionofthephosphorlastsonlyabrieftime,andthusrefresh
isrequired,usuallyevery1/30secondsfornormalTVsetsor1/60secondforhighendrasterdevices.Theelectronbeamisrepeatedlyscanned
totheright,withscanlinesloopingdownwards.Sincethetotalnumberofpixelsisfixed,thetimerequiredfortherefreshwillbeconstant
regardlessofthecomplexityoftheimagetobedrawn.
Therasterimagestoredintheframebuffermaycarrygraylevelofcolorinformationifmorethanonebitisallocatedfor
eachpixeloftherasterimage.Considerusing3bitsforeachpixel,thefirstbitrepresentstheon/offstateforthecolorred,thesecondbitfor
green,andthethirdbitforblue.Eightcolorscanbedefinedanddisplayedsimultaneouslyonthedisplaydevice.Becauseofthedecliningpriceof
memory chips, raster graphic devices with 24bit per pixel (8 each for red, green, and blue) tend to be prevalent. In those devices, 256 (28)
different levels can be defined for each color and a total of 16,777,216 (224) colors can be defined and display simultaneously on the display
device.

2.Visibilitytechniques
Theproblemofremovinghiddenedgesandsurfacescanalsobeviewedasavisibilityproblem.Therefore,aclearunderstandingofitand
itssolutionisusefulandcanbeextendedtosolverelevantengineeringproblems.Consider,forexample,thevisionandpathplanningproblemsin
roboticsapplications.Inthepathplanningproblem,theknowledgeofwhenagivensurfacechangesfromvisibletohiddencanbeutilizedtofind
theminimumpathoftherobotendeffector.Anotherexampleisthedisplayoffiniteelementmesheswherethehiddenelementsareremoved.

Hidden line and hidden surface algorithms have been classified as objectspace methods, imagespace methods, or a
combinationofboth(hybridmethods).Anobjectspacealgorithmutilizesthespatialandgeometricalrelationshipsamongtheobjectsinthe
scene to determine hidden and visible parts of these objects.An imagespace algorithm, on the other hand, concentrates on the final image to
determine what is visible, say, within each raster pixel in the case of raster displays. Most hidden surface algorithms use raster imagespace
methodswhilemosthiddenlinealgorithmsuseobjectspacemethods.
The visibility of parts of objects of a scene depends on the location of the viewing eye, the viewing direction, the type of projection
(orthogonalorperspective),andthedepthorthedistancefromvariousfacesofvariousobjectsinthescenetotheviewingeye.
Thedepthcomparisonisthecentralcriterionutilizedbyhiddenlinealgorithmstodeterminevisibility.Thedepthcomparisondetermines
if a projected point
correspondingpoints

and

in a given view obscures another point


. This is equivalent to determining of the two original
lieonthesameprojector.Fororthographicprojections,projectorsareparallel.Therefore, twopoints and

areonthesameprojectorif
theviewingeye.

and

.Iftheyare,acomparisonof

and

decideswhichpointiscloserto

Visibilitytechniquesattempttoestablishrelationshipsamongpolygonsandedgesintheviewingplane.Thetechniquesnormallycheckfor
overlappingofpairsofpolygons(sometimesreferredtoaslateralcomparisons)intheviewingplane(thescreen).Ifoverlappingoccurs,depth
comparisonsareusedtodetermineifpartorallofonepolygonishiddenbyanother.
Assignment1
GeneratetwooverlappingobjectsusingyourCADsoftware.Displaytheobjectswithhiddenlinesremoved.Displaytheobjectsusing
differentlocationoftheviewingeye,differentviewingdirection,anddifferenttypeofprojection(orthogonalorperspective).Discussyour
findings.IsthereanyspecialfunctionsprovidedbyyourCADsoftware?

2.1Minimaxtest
Minimax test (also called the overlap or bounding box test) checks if two polygons overlap. The test provides a quick method to
determineiftwopolygonsdonotoverlap.Itsurroundseachpolygonwithaboxbyfindingitsextents(minimumandmaximumxandy
coordinates) and then checks for the intersection for any two boxes in both the X and Y directions. If two boxed do not intersect, their
correspondingpolygonsdonotoverlap(seeFigure1).Insuchacase,nofurthertestingoftheedgesofthepolygonsisrequired.
Iftheminimaxtestfails(twoboxesintersect),thetwopolygonsmayormaynotoverlap,asshowninFigure1.Eachedgeofonepolygonis
comparedagainstalltheedgesoftheotherpolygontodetectintersections.Theminimaxtestcanbeappliedfirsttoanytwoedgestospeedupthis
process.
Assignment2
Generate an example similar to those in Figure 1 to show that the two polygons may not overlap when the two boxes intersect.
Completetheminimaxtestcomparingtheedgesofthepolygons.

Figure1.Minimaxtestsfortypicalpolygonsandedges
2.2Containmenttest

The containment test checks whether a given point lies inside a given polygon or polyhedron . There are three methods to
computecontainmentorsurroundedness.Foraconvexpolygon,onecansubstitutethe and coordinatesofthepointintothelineequationof
eachedge.Ifallsubstitutionsresultinthesamesign,thepointisonthesamesideofeachedgeandisthereforesurrounded.Thistestrequiresthat
thesignsofthecoefficientsofthelineequationsbechosencorrectly.
Fornonconvexpolygons,twoothermethodscanbeused.Inthefirstmethod,wedrawalinefromthepointundertestingtoinfinityasshown
inFigure2a.Thesemiinfinitelineisintersectedwiththepolygonedges.Iftheintersectioncountiseven,thepointisoutsidethepolygon( in
Figure2a).Ifitisodd,thepointisinside( intheFigure).Ifoneofthepolygonedgesliesonthesemiinfiniteline,asingularcaseariseswhich
needsspecialtreatmenttoguaranteetheconsistencyoftheresults.Thesecondmethodfornonconvexpolygons(Figure2b)computesthesumof
theanglessubtendedbyeachoftheorientededgesasseenfromthetestpoint.Ifthesumiszero,thepointisoutsidethepolygon.Ifthesumis
or
the point is inside. The minus sign reflects whether the vertices of the polygon are ordered in a clockwise direction instead of
counterclockwise.

Figure2.Containmenttestfornonconvexpolygons

3.Hiddenlinealgorithms
3.1Computingsilhouettes

Asetofedgesthatseparatesvisiblefacesfrominvisiblefacesofanobjectwithrespecttoagivenviewingdirectioniscalled
silhouette edges (or silhouettes). The signs of the components of normal vectors of the object faces can be utilized to determine the
silhouette.Anedgethatispartofthesilhouetteischaracterizedastheintersectionofonevisiblefaceandoneinvisibleface.An
edge that is the intersection of two visible faces is visible, but does not contribute to the silhouette. The intersection of two invisible faces

producesaninvisibleedge.Figure3ashowsthesilhouetteofacube.Figure4showsthesilhouettecurveofacurvedsurface.
Assignment3
GenerateacurvedsurfaceusingyourCADsoftware.Trytoseeifyoucandisplayitssilhouettecurve.

Figure3.Silhouetteedgesofapolyhedralobject.

Figure4.Silhouettecurveofacurvedsurface
3.2Thepriorityalgorithm
Thisalgorithmisalsoknownasthedepthorzalgorithm. Thealgorithmisbasedonsortingallthefaces(polygons)inthescene
accordingtothelargestzcoordinatevalueofeach.Thisstepissometimesknownasassignmentofpriorities.Ifafaceintersectsmorethan
oneface,othervisibilitytestsbesidesthezdepthareneededtoresolveanyambiguities.

The priority algorithm is based on assigning priorities to the faces in the face list. The priority assignment is determined by
comparing two faces at any one time. The priority list is continuously changed and the final list is obtained after few iterations. Here is how
prioritiescanbeassigned.Figure5bshowsthechangesoftheprioritylistoftheobjectsinFigure5a.Thefirstfaceinthefacelist( inFigure
5b)isassignedthehighestpriority1.

isintersectedwiththeotherfacesinthelist,thatis,

facemaybeanareaasinthecaseof

and

,anedgeasforfaces

caseofanareaofintersection(AinFigure5a),the

and

to

.Theintersectionbetween

,oranemptyset(nointersection)asforfaces

andanother

and

.Inthe

coordinatesofapointCinsideAcanbecomputed(noticethecornerpointsofAare

known).Forbothfaces and ,thetwocorresponding valuesofpointCcanbecalculatedandcompared.Thefacewiththehighest


valuesisassignedthehighestpriority.Inthecaseofanedgeofintersection,bothfacesareassignedthesamepriority.Theyobviouslydonot
obscureeachother,especiallyaftertheremovalofthebackfaces.Inthecaseofnofaceintersection,nopriorityisassigned.
LetusapplytheabovestategytothesceneofFigure5. intersects
intersectinanarea.Usingthedepthtest,andassumingthedepthof

and inedges.Thereforebothfacesareassignedpriority1. and


islessthanthatof , isassignedpriority2.Whenweintersect

faces and ,weobtainanemptyset,thatis,nopriorityassignmentispossible.Inthiscase,theface ismovedtotheendofthefacelistand


thesortingprocesstodetermineprioritiesstartsalloveragain.Ineachiteration,thefirstfaceinthefacelistisassignedpriority1.Theendofeach
iterationisdetectedbynointersection.Figure5bshowsfouriterationsbeforeobtainingthefinalprioritylist.Initeration4,faces to are
assignedthepriority1first.When isintersectedwith ,thedepthtestshowsthat hashigherpriority.Thus, isassignedpriority1and

priorityof

to

isdroppedto2.

Figure5.Thepriorityalgorithm.
Reorder the face and priority lists so that the highest priority is on top of the list. In this case, the face and priority lists are
and

respectively.

Inthecaseofarasterdisplay,hiddenlineremovalisdonebythehardware(framebufferofthedisplay).Wesimplydisplaythefacesinthe
reverseorderoftheirpriority.Anyfacesthatwouldhavetobehiddenbyotherswouldthusbedisplayedfirst,butwouldbecoveredlatereither
partiallyorentirelybyfacesofhigherpriority.
Inthecaseofavectordisplay,thehiddenlineremovalmustbedonebysoftwarebydeterminingcoverings.Forthispurpose,theedgesofa
facearecomparedwithallotheredgesofhigherpriority.Anedgelistcanbecreatedthatmaintainsalistofalllinesegmentsthatwillhavetobe
drawnasvisible.Visibilitytechniquessuchasthecontainmenttestandedgeintersectionareusefulinthiscase.Figure5cshowsthescenewith
hiddenlinesremoved.
Assignment4
Generate two overlapping wedges in positions similar to the blocks in Figure 5 using your CAD software. Display the objects in
isometricviewthenrunthepriorityalgorithmtodeterminetheprioritylistofthefaces.

4.Thezbufferalgorithm
Thisisalsoknownasthedepthbufferalgorithm.Inadditiontotheframe(refresh)buffer,thisalgorithmrequiresazbufferin
whichzvaluescanbesortedforeachpixel.The zbufferisinitializedtothesmallestz value, while the frame buffer is initialized to the
backgroundpixelvalue.Boththeframeandzbuffersareindexedbypixelcoordinates(x,y).Thesecoordinatesareactuallyscreencoordinates.
Thezbufferalgorithmworksasfollows.Foreachpolygoninthescene,findallthepixels(x,y)thatlieinsideorontheboundariesofthepolygon
whenprojectedontothescreen.Foreachofthesepixels,calculatethedepthzofthepolygonat(x,y).Ifz>depth(x,y),thepolygonisclosertothe
viewingeyethanothersalreadystoredinthepixel.Inthiscase,thezbufferisupdatedbysettingthedepth(x,y)toz.Similarly,theintensityofthe
framebufferlocationcorrespondingtothepixelisupdatedtotheintensityofthepolygonat(x,y).Afterallthepolygonshavebeenprocessed,the
framebuffercontainsthesolution.
Assignment5
RenderthetwoobjectsgeneratedinAssignment4withdifferentcolorsthendisplaythemagain.Drawaflowcharttodescribehowthe
imageofeachpixelisdeterminedusingtheconceptofthezbufferalgorithm.

5.SectionedViews
Asectionedviewofasolidisessentiallyaviewofthepartofasolidthatisbeyondsomeplanez=V.Thissolidisprojectedas
usualonthexyplanetogiveasectionalviewofthesolidinrespecttothesectionplane.Practically,thismeansthat
(1)Alllinesthatareabovethisplanearenotplotted.
(2)Polygonsthatareentirelyabovethisplanedonothidelinesthatarebelowthisplane.
(3)Linesthatintersectwiththesectionplaneareplotteduptothisplane.
(4) For polygons that are intersecting with the section plane, their parts above the section plane has to be replaced with the line of
intersection.
Assignment6
GenerateablockwithathroughholeusingyourCADsoftware.Displayitssectionedviewacrossthecenterofthehole.

Vous aimerez peut-être aussi