机械CADChapter 5Basic Graphics Concepts.docx
《机械CADChapter 5Basic Graphics Concepts.docx》由会员分享,可在线阅读,更多相关《机械CADChapter 5Basic Graphics Concepts.docx(15页珍藏版)》请在冰豆网上搜索。
![机械CADChapter 5Basic Graphics Concepts.docx](https://file1.bdocx.com/fileroot1/2023-2/4/1ef3dd1a-0a27-4119-b7be-6b723e5df352/1ef3dd1a-0a27-4119-b7be-6b723e5df3521.gif)
机械CADChapter5BasicGraphicsConcepts
Chapter5BasicGraphicsConcepts
5.1Introduction
WhenweuseCADsystemstobuildamodel,geometrytransformationsareoftenperformedtochangetheposition,orientation,andsizeofthemodelingobjects.Geometrytransformationsareoftenperformedinhomogenouscoordinates,andmatricesaresuitabletorepresentthesetransformations.
Visualizationisimportantbothduringandaftermodelgenerations,Inordertodisplaya3Dobject,techniqueslikeperspectiveprojections,hiddenlineandsurfaceremovalareused.Variousshadingmodelsareusedtogivetheobjectarealisticimage.Thischaptergivesanintroductiontothesebasictechniquesusedinmodelgenerationsandvisualization.
5.2GeometryTransformation
5.2.13DTransformations
5.2.1.1Translation
ApointP(x,y,z)maybetranslatedintotoanewpositionP*(x*,y*,z*)byaddingtranslationamountsd(dx,dy,dz)tothecoordinatesofthepoint,i.e.
P*=P+d(5.1)
whereP*isthefinalpositionvector,Pistheinitialpositionvector,anddisshowninFig.5.1.
Inscalarform,Eq.(5.1)canbewrittenas
(5.2)
5.2.1.2Scaling
Thepointcanbescaledbysxalongxaxis,sya1ongyaxisandszalongzaxis,whichmaybemathematicallyexpressedas
P*=[S]P(5.3)
where[S]isadiagonalmatrix,
(5.4)
Inscalarform,Eq.(5.3)maybewrittenas
(5.5)
5.2.1.3Reflection
Reflection(ormirror)operationsareoftenusedtogeneratesymmetricmodels.Reflectionoperationsrelativetothemodelcoordinatesystemcanbeexpressedas
P*=[M]P(5.6)
Where
(5.7)
wherem11,m22,m33=
1.
Forexample,thetransformationmatrixtoreflectPrelativetoxyplaneis
(5.8)
5.2.1.4Rotation
AtypicalrotationoperationisdemonstratedinFig.5.2,wherepointPisrotatedanangel
aboutzaxis,andthenewpositionisP*.
Fromthefigure,itcanbeobtainedthat
.Utilizingthetrigonometricfunctions,wegetthematrixformfortherotationaboutzaxis
P*=[R]P(5.9)
Where
(5.10)
Therotationsaboutxandyaxiscanbederivedinthesimilarway.
5.2.2HomogenousRepresentation
Thetranslationtransformationinpreviouschapterisrepresentedbymatrixaddition,whilescalingandrotationbymatrixmultiplications.Itisconvenienttorepresentalloperationsbymatrixmultiplication,suchas
P*=[T]P(5.11)
where[T]isthetransformationmatrixwewanttodeduce,PandP*arethecoordinatesofpointsbeforeandafterthetransformations.Thiscanbedonewithhomogenouscoordinates,andthetransformationmatrix[T]becomesa4
4matrix.
Foranypoint(x,y,z)inCartesiancoordinates,wedefinethefollowingrepresentation:
①Fromthe3Dcoordinatetothehomogenouscoordinate:
(x,y,z)=>(.x,y,z,1)
②Promthehomogenouscoordinatetothe3Dcoordinate:
(x,y,z,W)=>(x/W,y/W,z/W)(W
).
③Hormogenizing:
(x,y,z,W))=>(x/W,y/W,z/W,1).
Forexample,(4,0,0,2)and(2,0,0,1)representthesamecoordinates(2,0,0).
Wenowusethehomogenouscoordinatestorepresentthegeometrytransformationdiscussedinpreviouschapter.
GiveP=[xyz1]T,thefollowingoperationsmaybedefined.
(1)Translation
P*=T(dx,dy,dz)P(5.12)
Where
(5.13)
(2)Scaling
P*=S(sx,sy,sz)P(5.14)
Where
(5.15)
(3)Rotaiton
(5.16)
Whereforrotationaboutxaxis
(5.17a)
forrotationaboutyaxis
(5.17b)
forrotationaboutzaxis
(5.17c)
(4)Compositetransformation
Inpractice,aseriesoftransformationsmaybeappliedtoageometrymodel,resultinginacompositetransformation.Compositetransformationmatrixisequaltotheproductofthesequenceofthegiventransformationmatrices.Theorderofmultiplicationofthematricesisimportantbecausematrixmultiplicationisnotcommutative.
Mostofthetransformationsthatwenormallydealwithcanbeobtainedasacompositetransformationofbasictransformations.Ingeneralwehave
(5.18)
where[Ti]aretransformationmatricesand[T]istheproductofthem.
5.3MappingofGeometryModels
Thegeometrytransformationsdiscussedsofarassumethatthecoordinatesystemstaysunchangedandtheobjectistransformedwithrespecttotheoriginofthecoordinatesystem.Analternativebutequivalentwayofthinkingistotakethegeometrytransformationasachangeofcoordinatesystem.Thegeometrytransformationscanberegardedasmappingsofthegeometrymodelbetweendifferentcoordinatesystems,andtherelatedmatricesarecalledmappingmatrices.
Thisviewisusefulduringthemodelgeneration,asitisoftenconvenienttobuildsomepartofthemodelinthelocal(working)coordinatesystems.Thesoftwaremapsthesecoordinatestoglobalcoordinates.
5.3.1Translation
Figure5.3showsthatpointPisdescribedintwocoordinatesystemsxyzandx*y*z*.ThemappingbetweenthesetwocoordinatesystemscanbewrittenasP*=[T]P,where[T]isthesameasT(dx,dy,dz)inEq.(5.13).
5.3.2Rotation
Figure5.4showstherotationalmappingbetweentwocoordinatesystems.Thesetwocoordinatesystemssharethesameoriginbuttheirorientationsaredifferent.Itisalsoassumedthatthexyandthex*y*planesarecoincident.
Theunitvectorsi*,j*,K*ofthecoordinatesystemx*y*z*canbeexpressedas
(5.19)
Inmatrixform,
(5.20)
5.3.3GeneralMapping
ForageneralmappingasshowninFig.5.5,wehaveP*=[T]P
Where
(5.21)
Inwhich[R]istheorientationvectorsoftheorigintothexyzcoordinatesystem,whiledisthepositionvector,bothexpressedinx*y*z*system.
5.4ProjectionsofGeometryModels
Projectionisusedtoreducethedimensionofamodelfrom3Dto2D.Therearetwotypesofprojections:
parallelprojectionandperspectiveprojection.
5.4.1ParallelProjection
Parallelprojectioncanbedividedintoorthographicandobliqueprojections.Inorthographicprojection,directionofprojectionandprojectionplanenormalareparallel,whileinobliqueprojection,directionofprojectionandprojectionplanenormalarenotparallel.
Thematrixformoforthographicprojectionis:
Pv=[T]P(5.22)
Where
(5.23)
Orthographicprojectionpreservesrelativeproportionsandiscommonlyusedindraftingtoproducedrawingof3Dobjects.
5.4.2PerspectiveProjection
Ifthedistancebetweentheprojectioncenterandtheprojectionplanisfinite,thentheprojectionisperspective.Perspectiveprojectionisrealisticbecauseitresembleshuman’sviewing,andtheobjectbecomessmallerasitismovedawayfromtheviewplane.
Figure5.9showsthatacubeviewedinperspective.Theprojectionplaneisparalleltothexyplaneandperpendiculartothezaxis.Linesthatareparalleltothexoryaxisremainparallel,andxandydistancesbecomeshorteraszbecomesmorenegative.
Toderivethetransformationmatrixinperspectiveprojection,weplacethecentreofprojectionintheoriginofthecoordinatesystemandtheprojectionplanisperpendiculartothezvaxis,seeFig.5.10.Assumethat(xv,yv,zv)and(xp,yp,zp)arecoordinatesbeforeandaftertheperspectiveprojection.Fromthefigure,wegetzp=d,yp=dyv/zv,Similarlyxp=dxv/zv.Thiscanbewritteninhomogenousform,
(5.24)
5.5HiddenSurfaceRemoval
Togivea3Dpictureofthemodel,hiddenlinesandsurfacesmustberemoved.Linesareassumedtobetheedgesofthesurfaceandwerefertothegeneralprocessofmovinghiddensurfacesashiddensurfaceremoval.
Therearevariousalgorithmsforhiddensurfaceremoval.Thesealgorithmscanbecharacterizedastwogroups:
objectprecisionandimageprecision.
Objectprecisionisbasedontheobjectgeometryanddecideswhichpartoftheobjectisvisibleandthendrawsthesesurfaces.Theprecisionisindependentoftheresolutiononscreen.
Imageprecisionisapixelbasedmethod.Thismethodgoesthrougheachpixelonthescreen,anddeterminestheobjectclosesttotheprojectorandthendrawsthepixel.Theresultsdependontheresolution.
5.5.1VisualTechniques
Theoperationsusedinthetypicalimage-precisionandobject-precisionalgorithmsareof-tencostly.Weneedtomaketheseoperationsaseffectivelyaspossible.Thefollowingtechniquesprovidesomegeneralwaystodothat.
5.5.1.1Coherence
①Objectcoherence:
Iftwoobjectsareentirelyseparated,weneedonlytocomparetwoobjects,notbetweencomponentfacesoredgesoftheobjects.
②Facecoherence:
Surfacecomputationcanbemodifiedincrementallytoapplytoadjacentparts.
③Edgecoherence:
Anedgecanchangeitsvisibilityonlywhenitcrossesbehindavisibleedge.
④Scan-linecoherence:
Onescan-lineofanimagetypicallydifferslittlefromthepreviousline.
⑤Areacoherence:
Agroupofadjacentpixelsisoftencoveredbythesamevisibleface.
⑥Depthcoherence:
Oncethedepthatonepointofthesurfaceiscalculated,thedepthofpointsontherestofthesurfacecanoftenbedeterminedbysimpledifferenceequation.
⑦Framecoherence:
Calculationsmadeforonepicturecanbeusedforthenextinsequence.
5.5.1.2PerspectiveTransformation
Theideawiththeperspectivetransformationistotransfertheperspectiveprojectionintotheparallelprojectionofthetransformedobjects,asshowninFig5.11.
ThepyramidinFig.5.11iscutbyafrontclippingplaneandabackclippingplane,bothplanesareperpendiculartothedirectionofprojection.Onlytheobjectsinsidethetruncatedpyramidaredisplayedandthistruncatedpyramidiscalledviewingfrustum.Theviewingfrustumbecomesaboxafterperspectivetransformation.
Theadvantagesofperspectivetransformationarethefollowing:
①Providingz-information,whichcanbeusedinz-bufferalgorithmandtexturemapping.
②Simplifyingclipping,asinthecaseofapyramidbecomingabox.
③Invertible