ebook img

Mathematical and Computer Programming Techniques for Computer Graphics PDF

556 Pages·2010·5.34 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Mathematical and Computer Programming Techniques for Computer Graphics

“Comninos” — 2005/8/31 — 20:17 — page i — #1 Mathematical and Computer Programming Techniques for Computer Graphics “Comninos” — 2005/8/31 — 20:17 — page iii — #3 Peter Comninos Mathematical and Computer Programming Techniques for Computer Graphics With311Figures “Comninos” — 2005/8/31 — 20:17 — page iv — #4 PeterComninos,Dip(Comp.Prog.),BSc(Hons)(Comp.Sc.),PhD(Comp.Sc.) TheNationalCentreforComputerAnimation WeymouthHouse BournemouthUniversity PooleBH125BB UnitedKingdom [email protected] BritishLibraryCataloguinginPublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary LibraryofCongressControlNumber:2005925503 ISBN-10:1-85233-902-0 Printedonacid-freepaper ISBN-13:978-1-8233-902-9 ©Springer-VerlagLondonLimited2006 Apartfromanyfairdealingforthepurposesofresearchorprivatestudy,orcriticismorreview,as permittedundertheCopyright,DesignsandPatentsAct1988,thispublicationmayonlyberepro- duced,storedortransmitted,inanyformorbyanymeans,withthepriorpermissioninwritingof thepublishers,orinthecaseofreprographicreproductioninaccordancewiththetermsoflicences issuedbytheCopyrightLicensingAgency.Enquiriesconcerningreproductionoutsidethoseterms shouldbesenttothepublishers. Theuseofregisterednames,trademarks,etc. inthispublicationdoesnotimply,evenintheab- senceofaspecificstatement,thatsuchnamesareexemptfromtherelevantlawsandregulations andthereforefreeforgeneraluse. Thepublishermakesnorepresentation,expressorimplied,withregardtotheaccuracyoftheinfor- mationcontainedinthisbookandcannotacceptanylegalresponsibilityorliabilityforanyerrors oromissionsthatmaybemade. PrintedintheUnitedStatesofAmerica (SPI/MVY) 9 8 7 6 5 4 3 2 1 SpringerScience+BusinessMedia springeronline.com “Comninos” — 2005/8/31 — 20:17 — page v — #5 “Theknowledgeofwhichgeometryaimsistheknowledgeoftheeternal.” PlatoRepublic,VII,52. “Thereisgeometryinthehummingofthestrings.” Pythagoras “Mathematics is the most beautiful and most powerful creation of the human spirit. MathematicsisasoldasMan.” StefanBanach “The mathematician’s best work is art, a high perfect art, as daring as the most secretdreamsofimagination,clearandlimpid. Mathematicalgeniusandartistic geniustouchoneanother.” Go¨staMittag-Leffler “Itisnotonlyimportant,itisessential!” Dr.Strangelove “Comninos” — 2005/8/31 — 20:17 — page vii — #7 Preface This book introduces undergraduate and postgraduate students to mathematics andrelatedcomputerprogrammingtechniquesusedinComputerGraphics. Ina gradualapproach,thebookexposesstudentstotheunderlyingmathematicalideas andleadsthemtowardsalevelofsufficientunderstandingofdetailtobeableto implement libraries and programs for 2D and 3D graphics. Through the use of numerouscodeexamples,thestudentsareencouragedtoexploreandexperiment withdatastructuresandcomputerprograms(intheCprogramminglanguage)and tomastertherelatedmathematicaltechniques. This book is meant for students with a minimum prerequisite knowledge of mathematics.Itassumesverylittleandanyhighschoolgraduateshouldbeableto followthisbook.Theintendedreaderisexpectedtohavehadsomebasicexposure to topics such as functions, trigonometric functions, elementary geometry and number theory, and elements of set theory. The reader is also expected to have somefamiliaritywithsomecomputerprogramminglanguagesuchasC,although anyalgorithmiclanguagewillservethepurpose. Thebookincludesasimplebuteffectivesetofroutines,organisedasalibrary, that covers both 2D and 3D graphics. This parallel approach of exposing the studentstothemathematicaltheoryandshowingthemhowtoincorporateitinto example programs is the major strength of this book. It both demystifies the mathematicsanditdemonstratesitsrelevanceto2Dand3Dcomputergraphics, thusmotivatingandrewardingthereader. Thisbookisorganisedintotenchaptersandfourappendices. Chapters1–4are characterisedassurvivalkits, astheyintroducethebasicmathematicalconcepts andtechniquesthatareappliedandareessentialforathoroughunderstandingof theremainingsixchapters. Thematerialpresentedinthisbookhasbeenusedto teachmathematicalandprogrammingtechniquestobothComputerScientistsand Artists. ForaBachelordegreethatcoversthemathematicsforcomputergraphics over three years, Chapter 1 would normally be taught at the end of year one, Chapters2–9wouldnormallybetaughtinyeartwoofthecourseandChapter10 maybetaughtattheendofyeartwoorthebeginningofyearthree. Chapter 1 introduces readers to concepts of settheory and function theory. It assumesnopriorknowledgeofthesetopicsanditisself-contained. vii “Comninos” — 2005/8/31 — 20:17 — page viii — #8 viii Preface Chapter2dealswithvectorsandvectoralgebra. Itintroducesreaderstothese topicsassumingnopriorknowledgesavearudimentaryunderstandingof2Dand 3D geometry and some elements of trigonometry. Once readers have mastered the material presented in this chapter, they will be able to solve complex vector algebraproblemsandtoimplementtheirsolutionsincomputerprograms.Appen- dix1,whichisassociatedwiththischapter,presentsanexampleimplementation ofa3Dvector-algebralibrary. Chapter3dealswithmatricesandmatrixalgebra. Itintroducesreaderstothese topicsassumingnopriorknowledgeofmatricesbutrequiringagoodunderstand- ingofvectoralgebra. Oncereadershavemasteredthematerialpresentedinthis chapter,theywillbeabletosolvecomplexmatrixalgebraproblemsandtoimple- menttheirsolutionsincomputerprograms. Appendix2,whichisassociatedwith thischapter,presentsanexampleimplementationofa4Dmatrix-algebralibrary. Chapter4dealswithvectorspaces,whichisoneofthemostabstractsubjects dealt with in this book and thus one of the topics that some students find more difficult. This chapter requires a good understanding of both vector and matrix algebra.Itisself-containedand,althoughitintroducestheveryimportantconcept ofthechangeofbasismatrix,itmaybeomittedbytheuninterestedreader. Chapters5and6dealwiththeconceptsof2Dtransformationsand2Dclipping algorithmsrespectively,andtheirimplementation. Appendix3,whichisassoci- ated with these two chapters, presents an example implementation of a compre- hensive2Dgraphicslibrary. Chapter 7 deals with the concepts of viewing and projection transformations, 3Dclipping,andtheirimplementation. Appendix4,whichisassociatedwiththis chapter, presents an example implementation of a comprehensive 3D graphics library. Chapter 9 examines the data structures required to represent 3D models and someofthehidden-surfaceremovalandrenderingtechniquesusedinthecreation of computer generated images. This chapter also introduces readers to some of thesimpleempiricallightingandshadingmodelsusedinreal-timegraphics. Finally, Chapter10presentsamuchmoredetailedexpositionofthenatureof lightandexamines,insomedetail,physically-basedlightingandshadingmodels, andrenderingtechniquesandalgorithms. Thematerialpresentedinthischapter ismoremathematicallychallenging. Mostofthematerialpresentedinthisbookhasbeendesignedtobeaccessible to B.A., B.Sc., M.A. and M.Sc. students of a computer animation, digital spe- cialeffectsortechnicaldirectiondegreecourse. Thisbookhoweverwillalsobe usefultocomputersciencestudentsstudyingagraphicsoranimationunitandto technicaldirectorsinCGIproduction. ThevectorandmatrixnotationofthisbookisdesignedtoappealtobothNorth AmericanandInternationalreaders. “Comninos” — 2005/8/31 — 20:17 — page ix — #9 Acknowledgements IexpressmyunreservedgratitudetocountlessstudentsattheNationalCentrefor ComputerAnimationwhohavehelpedme“debug”thistextandimproveitsread- ability. My sincere thanks also go to my wife Danie`le and my daughter Celina. Withouttheirsupportandunderstandingwritingthisbookwouldhavebeenim- possible. Last but not least I would like to express my gratitude to my colleague and friend Peter Hardie for allowing me to use his computer art on the cover of this book. More information on Peter’s work can be found online at http://ncca.bournemouth.ac.uk/newhome/announce phsab.html. ix “Comninos” — 2005/8/31 — 20:17 — page xi — #11 Contents Preface vii Acknowledgements ix SomeDefinitionsofTerms 1 1 SetTheorySurvivalKit 3 1.1 SomeBasicNotationsandDefinitions. . . . . . . . . . . . . . . 4 1.1.1 SetsandElements . . . . . . . . . . . . . . . . . . . . . 4 1.1.2 NotationandSetSpecification . . . . . . . . . . . . . . 4 1.1.3 SetMembership . . . . . . . . . . . . . . . . . . . . . . 5 1.1.4 FiniteandInfiniteSets . . . . . . . . . . . . . . . . . . 6 1.2 EqualityofSets . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.3 TheNullSetorEmptySet . . . . . . . . . . . . . . . . . . . . . 6 1.4 Subsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.5 Supersets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.6 ProperSubsetsandSupersets . . . . . . . . . . . . . . . . . . . 7 1.7 ComparableSets . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.8 TheUniversalSet . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.9 DisjointSets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.10 Venn-EulerDiagrams . . . . . . . . . . . . . . . . . . . . . . . 8 1.11 LineDiagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.12 BasicSetOperations . . . . . . . . . . . . . . . . . . . . . . . . 11 1.12.1 SetUnion . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.12.2 SetIntersection . . . . . . . . . . . . . . . . . . . . . . 12 1.12.3 SetDifference . . . . . . . . . . . . . . . . . . . . . . . 13 1.12.4 TheSymmetricDifferenceofTwoSets. . . . . . . . . . 14 1.12.5 TheComplementofaSet . . . . . . . . . . . . . . . . . 18 Theorem1.1 . . . . . . . . . . . . . . . . . . . . . . . . 19 1.12.6 TheoremsonComparableSets . . . . . . . . . . . . . . 20 Theorem1.2 . . . . . . . . . . . . . . . . . . . . . . . . 20 Theorem1.3 . . . . . . . . . . . . . . . . . . . . . . . . 20 xi “Comninos” — 2005/8/31 — 20:17 — page xii — #12 xii Contents Theorem1.4 . . . . . . . . . . . . . . . . . . . . . . . 20 Theorem1.5 . . . . . . . . . . . . . . . . . . . . . . . 21 Theorem1.6 . . . . . . . . . . . . . . . . . . . . . . . 22 1.13 TheAlgebraofSets . . . . . . . . . . . . . . . . . . . . . . . . 22 1.13.1 TheRulesoftheAlgebraofSets . . . . . . . . . . . . 22 Theorem1.7 . . . . . . . . . . . . . . . . . . . . . . . 23 Theorem1.8 . . . . . . . . . . . . . . . . . . . . . . . 23 1.13.2 TheDualityPrinciple . . . . . . . . . . . . . . . . . . 24 Theorem1.9 . . . . . . . . . . . . . . . . . . . . . . . 24 1.14 NumbersandSets . . . . . . . . . . . . . . . . . . . . . . . . . 25 1.14.1 ClassesofNumbers . . . . . . . . . . . . . . . . . . . 25 1.14.2 Closure . . . . . . . . . . . . . . . . . . . . . . . . . . 25 1.14.3 TheSetofRealNumbersR . . . . . . . . . . . . . . . 26 1.14.4 TheSetofRationalNumbersQ . . . . . . . . . . . . . 26 1.14.5 TheSetofIrrationalNumbersQ(cid:1) . . . . . . . . . . . . 27 1.14.6 TheSetofNaturalNumbersN . . . . . . . . . . . . . 27 1.14.7 TheSetofIntegerNumbersZ . . . . . . . . . . . . . . 28 1.14.8 OtherusefulSetsofNumbers . . . . . . . . . . . . . . 28 1.14.8.1 TheSetofComplexNumbersC . . . . . . . 28 1.14.8.2 TheSetofAlgebraicNumbersA. . . . . . . 28 1.14.8.3 TheSetofTranscendentalNumbersT . . . . 28 1.14.9 OrderingRelationsorInequalities . . . . . . . . . . . . 29 TheReflexivityProperty . . . . . . . . . . . 29 TheTrichotomyProperty . . . . . . . . . . . 29 TheAntisymmetryProperty . . . . . . . . . 29 TheTransitivityProperty . . . . . . . . . . . 29 TheAdditionalandSubtractionProperty . . 29 TheMultiplicationandDivisionProperty . . 30 Examples . . . . . . . . . . . . . . . . . . . 30 1.14.10 TheAbsoluteValueorModulusofaNumber . . . . . . 30 1.14.11 RealNumberIntervals . . . . . . . . . . . . . . . . . . 32 1.14.12 PropertiesofRealNumberIntervals . . . . . . . . . . 34 1.14.13 RealNumberIntervalArithmetic . . . . . . . . . . . . 34 1.14.14 BoundedandUnboundedRealNumberSets . . . . . . 35 1.15 OrderedPairsandOrderedn-tuples . . . . . . . . . . . . . . . . 36 1.16 TheCartesianProductofSets . . . . . . . . . . . . . . . . . . . 37 1.17 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 1.17.1 TheFormalDefinitionofaFunction . . . . . . . . . . 39 1.17.2 Mappings,OperatorsandTransformations . . . . . . . 41 1.17.3 EqualityofFunctions . . . . . . . . . . . . . . . . . . 41 1.17.4 TheRangeofaFunction. . . . . . . . . . . . . . . . . 43 1.17.5 DifferentTypesofFunctions . . . . . . . . . . . . . . 43 1.17.5.1 Many-to-OneFunctions . . . . . . . . . . . 43 1.17.5.2 InjectiveFunctionsorOne-to-OneFunctions 43 1.17.5.3 SurjectiveFunctionsorOntoFunctions . . . 44

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.