Preface
ThefirsteditionofthisbookbeganlifeaspartofSpringer’s Essential seriesand containedtenchaptersandapproximately220pages.Thissixthandlasteditionhas twentychaptersandapproximately600pages.Overtheinterveningeditions,Ihave revisedandextendedpreviousdescriptionsandintroducednewchaptersonsubjects thatIbelievearerelevanttocomputergraphics,suchasdifferentialcalculusand interpolation,andnewsubjectsthatIhadtolearnabout,suchasquaternionsand geometricalgebra.Hopefully,thiseditionexploresenoughmathematicalideasto satisfymostpeopleworkingincomputergraphics.
AlthoughthefirsteditionofthisbookwasproducedonahumblePCusingWORD, subsequenteditionswereproducedonanAppleiMacusingLATEX.Irecommendto anybuddingauthorsthattheyshouldlearnLATEXanduseSpringer’stemplatesto createtheirfirstmanuscript.Furthermore,today’scomputersaresofastthatIoften compiletheentirebookforthesakeofchangingasinglecharacter—itonlytakes5 or6seconds!
Ihaveusedcolourinthetexttoemphasisethepatternsbehindcertainnumbers andintheillustrationstoclarifythemathematics.
Itisextremelydifficulttoensurethattherearenospellingmistakes,missing brackets,spuriouspunctuationmarksand,aboveall,mathematicalerrors.Itruly havedonemybesttocorrectthetextandassociatedequations,butifIhavemissed some,thenIapologisenow.
Inallofmybooks,Itrytomentionthenamesofimportantmathematicians associatedwithaninventionordiscoveryandtheperiodoverwhichtheywerealive. Inthisbook,Imention50suchpeople,andtherelevantdatesareattachedtothefirst citation.
WhilstwritingthisbookIhaveborneinmindwhatitwaslikeformewhenI wasstudyingdifferentareasofmathematicsforthefirsttime.Inspiteofreadingand rereadinganexplanationseveraltimes,itcouldtakedaysbefore‘thepennydropped’ andaconceptbecameapparent.Hopefully,thereaderwillfindthefollowingexplanationsusefulindevelopingtheirunderstandingofthesespecificareasofmathematics andenjoythesoundofvariouspenniesdropping!
IwouldliketothankHelenDesmond,EditorforComputerScience,forallowing metogiveupholidaysandhobbiesinordertocompleteanotherbook!
Breinton,UK May2022
JohnVince
2.6.1TheArithmeticofPositiveandNegative
2.7.1CommutativeLaw.............................10
2.7.2AssociativeLaw...............................10
2.7.3DistributiveLaw..............................11
2.8TheBaseofaNumberSystem............................11
2.8.1Background..................................11 2.8.2OctalNumbers................................12 2.8.3BinaryNumbers...............................13 2.8.4HexadecimalNumbers.........................13 2.8.5AddingBinaryNumbers........................16
2.8.6SubtractingBinaryNumbers....................18
4.4TheTrigonometricRatios................................53
4.9.1Double-AngleIdentities........................61
4.9.2Multiple-AngleIdentities.......................62 4.9.3Half-AngleIdentities...........................63
5CoordinateSystems
5.5.12DPolygons..................................67
5.5.2AreaofaShape...............................67
5.6TheoremofPythagorasin2D.............................68 5.73DCartesianCoordinates................................69
5.7.1TheoremofPythagorasin3D...................70 5.8PolarCoordinates.......................................70
5.9SphericalPolarCoordinates..............................71
5.10CylindricalCoordinates..................................72
5.11Summary..............................................73
5.12WorkedExamples.......................................73
5.12.1AreaofaShape...............................73
5.12.2DistanceBetweenTwoPoints...................73
5.12.3PolarCoordinates.............................74
5.12.4SphericalPolarCoordinates.....................74 5.12.5CylindricalCoordinates........................75
6Determinants
6.2LinearEquationswithTwoVariables.......................78
6.3LinearEquationswithThreeVariables.....................81
6.3.1Sarrus’sRule.................................88
6.4MathematicalNotation...................................88
6.4.1Matrix.......................................88
6.4.2OrderofaDeterminant.........................89
6.4.3ValueofaDeterminant.........................89
6.4.4PropertiesofDeterminants......................91
6.5Summary..............................................91
6.6WorkedExamples.......................................92
6.6.1DeterminantExpansion.........................92
6.6.2ComplexDeterminant..........................92
6.6.3SimpleExpansion.............................93
6.6.4SimultaneousEquations........................93
7Vectors .......................................................95
7.1Introduction............................................95
7.2Background............................................95
7.32DVectors.............................................96
7.3.1VectorNotation...............................96
7.3.2GraphicalRepresentationofVectors..............97
7.3.3MagnitudeofaVector..........................98
7.43DVectors.............................................99
7.4.1VectorManipulation...........................100
7.4.2ScalingaVector...............................100
7.4.3VectorAdditionandSubtraction.................101
7.4.4PositionVectors...............................102
7.4.5UnitVectors..................................102
7.4.6CartesianVectors..............................103
7.4.7Products.....................................103
7.4.8ScalarProduct................................104
7.4.9TheDotProductinLightingCalculations.........105
7.4.10TheScalarProductinBack-FaceDetection........106
7.4.11TheVectorProduct............................107
7.4.12TheRight-HandRule..........................112
7.5DerivingaUnitNormalVectorforaTriangle...............112
7.6SurfaceAreas...........................................113
7.6.1Calculating2DAreas..........................114
7.7Summary..............................................114
7.8WorkedExamples.......................................115
7.8.1PositionVector................................115
7.8.2UnitVector...................................115
7.8.3VectorMagnitude.............................115
7.8.4AngleBetweenTwoVectors....................116
7.8.5VectorProduct................................116 References....................................................117
8.3MatrixNotation.........................................122
8.3.1MatrixDimensionorOrder.....................122
8.3.2SquareMatrix.................................122
8.3.3ColumnVector................................123
8.3.4RowVector...................................123
8.3.5NullMatrix...................................123
8.3.6UnitMatrix...................................123
8.3.7Trace........................................124
8.3.8DeterminantofaMatrix........................125
8.3.9Transpose....................................125
8.3.10SymmetricMatrix.............................126
8.3.11AntisymmetricMatrix..........................128
8.4MatrixAdditionandSubtraction..........................130
8.4.1ScalarMultiplication...........................130
8.5MatrixProducts.........................................130
8.5.1RowandColumnVectors.......................131
8.5.2RowVectorandaMatrix.......................131
8.5.3MatrixandaColumnVector....................132
8.5.4SquareMatrices...............................133
8.5.5RectangularMatrices..........................134
8.6InverseMatrix..........................................134
8.6.1InvertingaPairofMatrices.....................141
8.7OrthogonalMatrix......................................141
8.8DiagonalMatrix........................................142
8.9Summary..............................................143
8.10WorkedExamples.......................................143
8.10.1MatrixInversion...............................143
8.10.2IdentityMatrix................................144
8.10.3SolvingTwoEquationsUsingMatrices...........144
8.10.4SolvingThreeEquationsUsingMatrices..........145
8.10.5SolvingTwoComplexEquations................146
8.10.6SolvingThreeComplexEquations...............147
8.10.7SolvingTwoComplexEquations................148
8.10.8SolvingThreeComplexEquations...............149
9ComplexNumbers ............................................151
9.1Introduction............................................151
9.2DefinitionofaComplexNumber..........................151
9.2.1AdditionandSubtractionofComplexNumbers....152
9.2.2MultiplyingaComplexNumberbyaScalar.......153
9.2.3ProductofComplexNumbers...................153
9.2.4SquareofaComplexNumber...................154
9.2.5NormofaComplexNumber....................154
9.2.6ComplexConjugateofaComplexNumber........154
9.2.7QuotientofComplexNumbers..................155
9.2.8InverseofaComplexNumber...................156
9.2.9Square-Rootof ±i .............................156
9.3OrderedPairs...........................................158
9.3.1AdditionandSubtractionofOrderedPairs........158
9.3.2MultiplyinganOrderedPairbyaScalar..........159
9.3.3ProductofOrderedPairs.......................159
9.3.4SquareofanOrderedPair......................160
9.3.5NormofanOrderedPair.......................161
9.3.6ComplexConjugateofanOrderedPair...........161
9.3.7QuotientofanOrderedPair.....................161
9.3.8InverseofanOrderedPair......................162
9.3.9Square-Rootof ±i .............................163
9.4MatrixRepresentationofaComplexNumber...............164
9.4.1AddingandSubtractingComplexNumbers.......165
9.4.2ProductofTwoComplexNumbers...............166
9.4.3NormSquaredofaComplexNumber............166
9.4.4ComplexConjugateofaComplexNumber........167
9.4.5InverseofaComplexNumber...................167
9.4.6QuotientofaComplexNumber..................168
9.4.7Square-Rootof ±i .............................169 9.5Summary..............................................170
9.6WorkedExamples.......................................170
9.6.1AddingandSubtractingComplexNumbers.......170
9.6.2ProductofComplexNumbers...................171
9.6.3MultiplyingaComplexNumberby i .............172
9.6.4TheNormofaComplexNumber................173
9.6.5TheComplexConjugateofaComplexNumber....173
9.6.6TheQuotientofTwoComplexNumbers..........174
9.6.7DivideaComplexNumberby i ..................175
9.6.8DivideaComplexNumberby i ................176
9.6.9TheInverseofaComplexNumber...............177
9.6.10TheInverseof i ...............................178
9.6.11TheInverseof i
10.3.1Translation...................................182
10.3.2Scaling.......................................182
10.3.3Reflection....................................183
10.4TransformsasMatrices..................................184
10.4.1SystemsofNotation...........................184
10.5HomogeneousCoordinates...............................184
11.20.1AddingandSubtractingQuaternions.............256
11.20.2NormofaQuaternion..........................257
11.20.3Unit-normQuaternions.........................257
11.20.4QuaternionProduct............................257 11.20.5SquareofaQuaternion.........................258 11.20.6InverseofaQuaternion.........................258
12.4QuaternionsinMatrixForm..............................271
12.8.1SummaryofDefinitions........................281
14.9SurfacePatches.........................................319
14.9.1PlanarSurfacePatch...........................319
14.9.2QuadraticBézierSurfacePatch..................320
14.9.3CubicBézierSurfacePatch.....................322 14.10Summary..............................................324
15AnalyticGeometry ............................................325
15.1Introduction............................................325
15.2Background............................................325
15.2.1Angles.......................................325
15.2.2InterceptTheorems............................326
15.2.3GoldenSection................................327
15.2.4Triangles.....................................327
15.2.5CentreofGravityofaTriangle..................328
15.2.6IsoscelesTriangle.............................328
15.2.7EquilateralTriangle............................329
15.2.8RightTriangle................................329
15.2.9TheoremofThales.............................329
15.2.10TheoremofPythagoras.........................329
15.2.11Quadrilateral..................................330
15.2.12Trapezoid....................................330 15.2.13Parallelogram.................................331
15.2.14Rhombus.....................................331
15.2.15RegularPolygon..............................332
15.2.16Circle........................................332
15.32DAnalyticGeometry...................................334
15.3.1EquationofaStraightLine.....................334
15.3.2TheHessianNormalForm......................335
15.3.3SpacePartitioning.............................337
15.3.4TheHessianNormalFormfromTwoPoints.......337
15.4IntersectionPoints.......................................338
15.4.1IntersectingStraightLines......................338
15.4.2IntersectingLineSegments.....................339
15.5PointInsideaTriangle...................................341
15.5.1AreaofaTriangle.............................341
15.5.2HessianNormalForm..........................343
15.6IntersectionofaCirclewithaStraightLine.................345 15.73DGeometry...........................................347
15.7.1EquationofaStraightLine.....................347
15.7.2IntersectingTwoStraightLines..................348
15.8EquationofaPlane......................................351
15.8.1CartesianFormofthePlaneEquation............351
15.8.2GeneralFormofthePlaneEquation..............353
15.8.3ParametricFormofthePlaneEquation...........354
15.8.4ConvertingfromtheParametrictotheGeneral
17.18TheRelationshipBetweenQuaternionsandBivectors........421
17.19ReflectionsandRotations................................422
17.19.12DReflections................................422
17.19.23DReflections................................423
17.19.32DRotations..................................424
17.20Rotors.................................................426
18Calculus:Derivatives ..........................................437 18.1Introduction............................................437 18.2Background............................................437 18.3SmallNumericalQuantities...............................437 18.4EquationsandLimits....................................439 18.4.1QuadraticFunction............................439
18.4.2CubicEquation................................440
18.4.3FunctionsandLimits...........................442
18.4.4GraphicalInterpretationoftheDerivative.........444
18.4.5DerivativesandDifferentials....................445
18.4.6IntegrationandAntiderivatives..................445
18.5FunctionTypes.........................................447
18.6DifferentiatingGroupsofFunctions........................448
18.6.1SumsofFunctions.............................448
18.6.2FunctionofaFunction.........................450
18.6.3FunctionProducts.............................454
18.6.4FunctionQuotients............................458
18.7DifferentiatingImplicitFunctions.........................460
18.8DifferentiatingExponentialandLogarithmicFunctions.......463
18.8.1ExponentialFunctions.........................463
18.8.2LogarithmicFunctions.........................465
18.9DifferentiatingTrigonometricFunctions....................467
18.9.1Differentiatingtan.............................467
18.9.2Differentiatingcsc.............................468
18.9.3Differentiatingsec.............................469
18.9.4Differentiatingcot.............................470
18.9.5Differentiatingarcsin,arccosandarctan..........470
18.9.6Differentiatingarccsc,arcsecandarccot..........471
18.10DifferentiatingHyperbolicFunctions.......................472
18.10.1Differentiatingsinh,coshandtanh...............474
18.11HigherDerivatives......................................475
18.12HigherDerivativesofaPolynomial........................475
18.13IdentifyingaLocalMaximumorMinimum.................477
18.14PartialDerivatives.......................................480
18.14.1VisualisingPartialDerivatives...................483
18.14.2MixedPartialDerivatives.......................485
18.15ChainRule.............................................486
18.16TotalDerivative.........................................488
18.17Summary..............................................489 Reference.....................................................490
19Calculus:Integration ..........................................491
19.1Introduction............................................491
19.2IndefiniteIntegral.......................................491
19.3IntegrationTechniques...................................492
19.3.1ContinuousFunctions..........................492
19.3.2DifficultFunctions.............................493
19.3.3TrigonometricIdentities........................493
19.3.4ExponentNotation.............................495
19.3.5CompletingtheSquare.........................497
19.3.6TheIntegrandContainsaDerivative..............498
19.3.7ConvertingtheIntegrandintoaSeries ofFractions...................................500
19.3.8IntegrationbyParts............................501
19.3.9IntegrationbySubstitution......................505
19.3.10PartialFractions...............................510
19.4AreaUnderaGraph.....................................512
19.5CalculatingAreas.......................................513
19.6PositiveandNegativeAreas..............................521
19.7AreaBetweenTwoFunctions.............................523
19.8Areaswiththey-Axis....................................524
19.9AreawithParametricFunctions...........................525
19.10TheRiemannSum......................................527
19.11Summary..............................................529
20WorkedExamples .............................................531
20.1Introduction............................................531
20.2AreaofRegularPolygon.................................531
20.3AreaofAnyPolygon....................................532
20.4DihedralAngleofaDodecahedron........................533
20.5VectorNormaltoaTriangle..............................534
20.6AreaofaTriangleUsingVectors..........................535
20.7GeneralFormoftheLineEquationfromTwoPoints.........535
20.8AngleBetweenTwoStraightLines........................536
20.9TestifThreePointsLieonaStraightLine..................537 20.10PositionandDistanceoftheNearestPointonaLine toaPoint..............................................538
Chapter1 Introduction
1.1MathematicsforComputerGraphics
Computergraphicscontainsmanyareasofspecialismsuchasdatavisualisation,computeranimation,filmspecialeffects,computergamesandvirtualreality.Fortunately, noteveryoneworkingincomputergraphicsrequiresaknowledgeofmathematics, butthosethatdo,oftenlookforabookthatintroducesthemtosomebasicideas ofmathematics,withoutturningthemintomathematicians.Thisistheobjectiveof thisbook.OverthefollowingchaptersIintroducethereadertosomeusefulmathematicaltopicsthatwillhelpthemunderstandthesoftwaretheyworkwith,andhow tosolveawidevarietyofgeometricandalgebraicproblems.Thesetopicsinclude numberssystems,algebra,trigonometry,2Dand3Dgeometry,vectors,equations, matrices,complexnumbers,determinants,transforms,quaternions,interpolation, curves,patchesandcalculus.Ihavewrittenaboutsomeofthesetopicstoagreater levelofdetailinotherbooks,whichyoumaybeinterestedinexploring.
1.2UnderstandingMathematics
Oneoftheproblemswithmathematicsisitsincrediblebreadthanddepth.Itembraces everythingfromgeometry,calculus,topology,statistics,complexfunctionstonumbertheoryandpropositionalcalculus.Allofthesesubjectscanbestudiedsuperficiallyortoamind-numbingcomplexity.Fortunately,nooneisrequiredtounderstand everything,whichiswhymathematicianstendtospecialiseinoneortwoareasand developaspecialistknowledge.Ifit’sanycomfort,evenEinsteinaskedfriendsand colleaguestoexplainbranchesofmathematicstohelphimwithhistheories.
©Springer-VerlagLondonLtd.,partofSpringerNature2022
J.Vince, MathematicsforComputerGraphics,UndergraduateTopics inComputerScience, https://doi.org/10.1007/978-1-4471-7520-9_1
1.3WhatMakesMathematicsDifficult?
‘Whatmakesmathematicsdifficult?’isadifficultquestiontoanswer,butonethat hastobeaskedandanswered.Therearemanyanswerstothisquestion,andIbelieve thatproblemsbeginwithmathematicalnotationandhowtoreadit;howtoanalyse aproblemandexpressasolutionusingmathematicalstatements.Unlikelearninga foreignlanguage—whichIfindverydifficult—mathematicsisalanguagethatneeds tobelearnedbydiscoveringfactsandbuildinguponthemtodiscovernewfacts. Consequently,agoodmemoryisalwaysanadvantage,aswellasasenseoflogic.
Mathematicscanbedifficultforanyone,includingmathematicians.Forexample, whentheideaof √ 1wasoriginallyproposed,itwascriticisedandlookeddown uponbymathematicians,mainlybecauseitspurposewasnotfullyunderstood.Eventually,ittransformedtheentiremathematicallandscape,includingphysics.Similarly, whentheGermanmathematicianGeorgCantor(1845–1919),publishedhispapers onsettheoryandtransfinitesets,somemathematicianshoundedhiminadisgraceful manner.TheGermanmathematicianLeopoldKronecker(1823–1891),calledCantor a‘scientificcharlatan’,a‘renegade’,anda‘corrupterofyouth’,anddideverything tohinderCantor’sacademiccareer[1].Similarly,theFrenchmathematicianand physicistHenriPoincaré(1854–1912),calledCantor’sideasa‘gravedisease’[2], whilsttheAustrian-BritishphilosopherandlogicianLudwigWittgenstein(1889–1951),complainedthatmathematicsis‘riddenthroughandthroughwiththeperniciousidiomsofsettheory’[3].Howwrongtheyallwere.Today,settheoryisa majorbranchofmathematicsandhasfounditswayintoeverymathcurriculum.So don’tbesurprisedtodiscoverthatsomemathematicalideasareinitiallydifficultto understand—youareingoodcompany.
1.4BackgroundtoThisBook
DuringmyworkinglifeincomputeranimationIcameacrossawiderangeofstudents withanequallywiderangeofmathematicalknowledge.Somestudentspossesseda rudimentarybackgroundinmathematics,whileothershadbeentaughtcalculusand supportingsubjects.Teachingsuchacohortthemathematicsofcomputergraphics wasachallenge,tosaytheleast,butsomehowIdid.Bytheendofathree-year undergraduatecoursetheywerecompetentprogrammersandcouldprogramawide varietyofmathematicaltechniques.Thefirst-editionofthisbookemployedmuchof myteachingmaterialandhasbeenrevisedandextended.
1.5HowtoUseThisBook
Initially,I’drecommendtoanyreadertostartatthebeginningandstartreading chaptersonsubjectswithwhichtheyarefamiliar.Oneneverknowswhatmaybe
learntfromreadingaboutafamiliarsubjectbyanon-mathematician.Forthose readerswithagoodbackgroundinmathematics,shouldquickreadchapterson topicscoveredelse-where,andsettledownonnewtopics.Howeveryouapproach thisbook,Isincerelyhopethatyoudiscoversomethingnewthatincreasesyour knowledgeofthesubject.
1.6SymbolsandNotation
Oneofthereasonswhymanypeoplefindmathematicsinaccessibleisduetoits symbolsandnotation.Let’slookatsymbolsfirst.TheEnglishalphabetpossessesa reasonablerangeoffamiliarcharactershapes:
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z whichfindtheirwayintoeverybranchofmathematicsandphysics,andpermitus towriteequationssuchas
and
Itisimportantthatwhenweseeanequation,weareabletoreaditaspartofthe text.Inthecaseof E = mc 2 ,thisisreadas‘ E equals m , c squared’,where E stands forenergy, m formass, c thespeedoflight,whichismultipliedbyitself.Inthe caseof A = π r 2 ,thisisreadas‘ A equalspi, r squared’,where A standsforarea, π theratioofacircle’scircumferencetoitsdiameter,and r thecircle’sradius.Greek symbols,whichhappentolookniceandimpressive,havealsofoundtheirwayinto manyequations,andoftendisrupttheflowofreading,simplybecausewedon’t knowtheirEnglishnames.Forexample,theEnglishtheoreticalphysicistPaulDirac (1902–1984),derivedanequationforamovingelectronusingthesymbols αi and β ,whichare4 × 4matrices,where
andisreadas
‘thesumoftheproductsalpha-i beta,andbetaalpha-i ,equalszero.’ Althoughwedonotcomeacrossmovingelectronsinthisbook,wedohavetobe familiarwiththefollowingGreeksymbols:
γ gamma o omicron
delta
pi epsilon
zeta
eta
theta
iota
kappa
lambda
mu
rho
sigma
tau
upsilon
phi
chi
psi
omega andsomeupper-casesymbols: Γ Gamma Sigma
Delta
Upsilon
Theta Phi Λ Lambda Psi
Xi Omega
Pi
Beingabletoreadanequationdoesnotmeanthatweunderstandit—butwearea littlecloserthanjustbeingabletostareatajumbleofsymbols!Therefore,infuture, whenIintroduceanewmathematicalobject,Iwilltellyouhowitshouldberead.
References
1.DaubenJW(1979)GeorgCantorhismathematicsandphilosophyoftheinfinite.Princeton UniversityPress,Princeton
2.DaubenJW(2004)GeorgCantorandthebattlefortransfinitesettheory(PDF).In:Proceedings ofthe9thACMSconference(WestmontCollege,SantaBarbara,Calif.),pp1–22
3.RodychV(2007)Wittgenstein’sphilosophyofmathematics.In:ZaltaEN(ed)TheStanford encyclopediaofphilosophy.MetaphysicsResearchLab,StanfordUniversity