ebook img

Mathematics for Computer Graphics PDF

250 Pages·2006·1.304 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 Mathematics for Computer Graphics

MATHEMATICS FOR COMPUTER GRAPHICS John Vince Mathematics for Computer Graphics SecondEdition With175Illustrations JohnVince,MTech,PhD,DSc,FBCS,CEng MediaSchool, UniversityofBournemouth,TalbotCampus,FernBarrow,PooleBH125BB,UK LibraryofCongressControlNumber:2005928172 ISBN-10:1-84628-034-6 ISBN-13:978-1-84628-034-4 ISBN1-85233-380-41stedition Printedonacid-freepaper. (cid:1)c Springer-VerlagLondonLimited2006 Apartfromanyfairdealingforthepurposesofresearchorprivatestudy,orcriticismorreview,asper- mittedundertheCopyright,DesignsandPatentsAct1988,thispublicationmayonlybereproduced, storedortransmitted,inanyformorbyanymeans,withthepriorpermissioninwritingofthepublish- ers,orinthecaseofreprographicreproductioninaccordancewiththetermsoflicencesissuedbythe CopyrightLicensingAgency.Enquiriesconcerningreproductionoutsidethosetermsshouldbesentto thepublishers. Theuseofregisterednames,trademarks,etc.inthispublicationdoesnotimply,evenintheabsenceof aspecificstatement,thatsuchnamesareexemptfromtherelevantlawsandregulationsandtherefore freeforgeneraluse. Thepublishermakesnorepresentation,expressorimplied,withregardtotheaccuracyoftheinfor- mationcontainedinthisbookandcannotacceptanylegalrepsonsibilityorliabilityforanyerrorsor omissionsthatmaybemade. PrintedintheUnitedStatesofAmerica. (SPI/MVY) 9 8 7 6 5 4 3 2 1 SpringerScience+BusinessMedia springeronline.com Dedication I dedicate this book to my wife Annie, who has had to tolerate a year of me reading math books in bed, on planes, boats, trains, in hotels, in the garden, in the bath, on holiday, and probably in my sleep! Contents Preface xiii 1 Mathematics 1 1.1 Is Mathematics Difficult? . . . . . . . . . . . . . . . . . . . . . 2 1.2 Who should Read this Book?. . . . . . . . . . . . . . . . . . . 2 1.3 Aims and Objectives of this Book . . . . . . . . . . . . . . . . 3 1.4 Assumptions Made in this Book . . . . . . . . . . . . . . . . . 3 1.5 How to Use the Book . . . . . . . . . . . . . . . . . . . . . . . 3 2 Numbers 5 2.1 Natural Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2 Prime Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4 Rational Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.5 Irrational Numbers . . . . . . . . . . . . . . . . . . . . . . . . 6 2.6 Real Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.7 The Number Line . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.8 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3 Algebra 11 3.1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2 Algebraic Laws . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2.1 Associative Law . . . . . . . . . . . . . . . . . . . . . . 12 3.2.2 Commutative Law. . . . . . . . . . . . . . . . . . . . . 13 3.2.3 Distributive Law . . . . . . . . . . . . . . . . . . . . . 13 3.3 Solving the Roots of a Quadratic Equation . . . . . . . . . . . 14 viii MathematicsforComputerGraphics 3.4 Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.4.1 Laws of Indices . . . . . . . . . . . . . . . . . . . . . . 15 3.4.2 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.5 Logarithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.6 Further Notation . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4 Trigonometry 17 4.1 The Trigonometric Ratios . . . . . . . . . . . . . . . . . . . . 18 4.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.3 Inverse Trigonometric Ratios . . . . . . . . . . . . . . . . . . . 19 4.4 Trigonometric Relationships . . . . . . . . . . . . . . . . . . . 19 4.5 The Sine Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.6 The Cosine Rule . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.7 Compound Angles . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.8 Perimeter Relationships . . . . . . . . . . . . . . . . . . . . . . 21 4.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 5 Cartesian Coordinates 23 5.1 The Cartesian xy-plane . . . . . . . . . . . . . . . . . . . . . . 23 5.1.1 Function Graphs . . . . . . . . . . . . . . . . . . . . . 24 5.1.2 Geometric Shapes . . . . . . . . . . . . . . . . . . . . . 25 5.1.3 Polygonal Shapes . . . . . . . . . . . . . . . . . . . . . 25 5.1.4 Areas of Shapes . . . . . . . . . . . . . . . . . . . . . . 26 5.1.5 Theorem of Pythagoras in 2D . . . . . . . . . . . . . . 27 5.2 3D Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . 28 5.2.1 Theorem of Pythagoras in 3D . . . . . . . . . . . . . . 28 5.2.2 3D Polygons . . . . . . . . . . . . . . . . . . . . . . . . 28 5.2.3 Euler’s Rule . . . . . . . . . . . . . . . . . . . . . . . . 29 5.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 6 Vectors 31 6.1 2D Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 6.1.1 Vector Notation . . . . . . . . . . . . . . . . . . . . . . 32 6.1.2 Graphical Representation of Vectors. . . . . . . . . . . 32 6.1.3 Magnitude of a Vector . . . . . . . . . . . . . . . . . . 34 6.2 3D Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 6.2.1 Vector Manipulation . . . . . . . . . . . . . . . . . . . 35 6.2.2 Multiplying a Vector by a Scalar . . . . . . . . . . . . 36 6.2.3 Vector Addition and Subtraction . . . . . . . . . . . . 36 6.2.4 Position Vectors . . . . . . . . . . . . . . . . . . . . . . 37 6.2.5 Unit Vectors . . . . . . . . . . . . . . . . . . . . . . . . 37 6.2.6 Cartesian Vectors . . . . . . . . . . . . . . . . . . . . . 38 6.2.7 Vector Multiplication . . . . . . . . . . . . . . . . . . . 39 6.2.8 Scalar Product. . . . . . . . . . . . . . . . . . . . . . . 40 Contents ix 6.2.9 Example of the Dot Product . . . . . . . . . . . . . . 41 6.2.10 The Dot Product in Lighting Calculations . . . . . . . 42 6.2.11 The Dot Product in Back-Face Detection . . . . . . . 43 6.2.12 The Vector Product . . . . . . . . . . . . . . . . . . . 44 6.2.13 The Right-Hand Rule . . . . . . . . . . . . . . . . . . 47 6.3 Deriving a Unit Normal Vector for a Triangle . . . . . . . . . 47 6.4 Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.4.1 Calculating 2D Areas . . . . . . . . . . . . . . . . . . 48 6.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 7 Transformation 51 7.1 2D Transformations . . . . . . . . . . . . . . . . . . . . . . . . 51 7.1.1 Translation . . . . . . . . . . . . . . . . . . . . . . . . 51 7.1.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . 51 7.1.3 Reflection . . . . . . . . . . . . . . . . . . . . . . . . . 52 7.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 7.2.1 Systems of Notation . . . . . . . . . . . . . . . . . . . 56 7.2.2 The Determinant of a Matrix . . . . . . . . . . . . . . 56 7.3 Homogeneous Coordinates . . . . . . . . . . . . . . . . . . . . 57 7.3.1 2D Translation . . . . . . . . . . . . . . . . . . . . . . 58 7.3.2 2D Scaling . . . . . . . . . . . . . . . . . . . . . . . . 58 7.3.3 2D Reflections . . . . . . . . . . . . . . . . . . . . . . 59 7.3.4 2D Shearing . . . . . . . . . . . . . . . . . . . . . . . 61 7.3.5 2D Rotation . . . . . . . . . . . . . . . . . . . . . . . 62 7.3.6 2D Scaling . . . . . . . . . . . . . . . . . . . . . . . . 64 7.3.7 2D Reflections . . . . . . . . . . . . . . . . . . . . . . 65 7.3.8 2D Rotation about an Arbitrary Point . . . . . . . . . 65 7.4 3D Transformations . . . . . . . . . . . . . . . . . . . . . . . . 66 7.4.1 3D Translation . . . . . . . . . . . . . . . . . . . . . . 66 7.4.2 3D Scaling . . . . . . . . . . . . . . . . . . . . . . . . 66 7.4.3 3D Rotations . . . . . . . . . . . . . . . . . . . . . . . 67 7.4.4 Gimbal Lock . . . . . . . . . . . . . . . . . . . . . . . 70 7.4.5 Rotating about an Axis . . . . . . . . . . . . . . . . . 72 7.4.6 3D Reflections . . . . . . . . . . . . . . . . . . . . . . 73 7.5 Change of Axes . . . . . . . . . . . . . . . . . . . . . . . . . . 73 7.5.1 2D Change of Axes . . . . . . . . . . . . . . . . . . . 74 7.6 Direction Cosines . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.6.1 Positioning the Virtual Camera . . . . . . . . . . . . . 77 7.6.2 Direction Cosines . . . . . . . . . . . . . . . . . . . . 77 7.6.3 Euler Angles . . . . . . . . . . . . . . . . . . . . . . . 79 7.7 Rotating a Point about an Arbitrary Axis . . . . . . . . . . . 83 7.7.1 Quaternions . . . . . . . . . . . . . . . . . . . . . . . 90 7.7.2 Adding and Subtracting Quaternions . . . . . . . . . 91 7.7.3 Multiplying Quaternions . . . . . . . . . . . . . . . . 91 7.7.4 The Inverse Quaternion . . . . . . . . . . . . . . . . . 91 x MathematicsforComputerGraphics 7.7.5 Rotating Points about an Axis . . . . . . . . . . . . 92 7.7.6 Roll, Pitch and Yaw Quaternions . . . . . . . . . . . 95 7.7.7 Quaternions in Matrix Form . . . . . . . . . . . . . . 96 7.7.8 Frames of Reference . . . . . . . . . . . . . . . . . . 98 7.8 Transforming Vectors . . . . . . . . . . . . . . . . . . . . . . 98 7.9 Determinants . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.10 Perspective Projection . . . . . . . . . . . . . . . . . . . . . . 103 7.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 8 Interpolation 107 8.1 Linear Interpolant . . . . . . . . . . . . . . . . . . . . . . . . 107 8.2 Non-Linear Interpolation . . . . . . . . . . . . . . . . . . . . 110 8.2.1 Trigonometric Interpolation . . . . . . . . . . . . . . 110 8.2.2 Cubic Interpolation . . . . . . . . . . . . . . . . . . . 111 8.3 Interpolating Vectors . . . . . . . . . . . . . . . . . . . . . . 116 8.4 Interpolating Quaternions . . . . . . . . . . . . . . . . . . . . 119 8.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 9 Curves and Patches 123 9.1 The Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 9.2 The Ellipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 9.3 B´ezier Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 9.3.1 Bernstein Polynomials . . . . . . . . . . . . . . . . . 125 9.3.2 Quadratic B´ezier Curves . . . . . . . . . . . . . . . . 129 9.3.3 Cubic Bernstein Polynomials . . . . . . . . . . . . . 130 9.4 A recursive B´ezier Formula . . . . . . . . . . . . . . . . . . . 133 9.5 B´ezier Curves Using Matrices . . . . . . . . . . . . . . . . . . 133 9.5.1 Linear Interpolation . . . . . . . . . . . . . . . . . . 134 9.6 B-Splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 9.6.1 Uniform B-Splines . . . . . . . . . . . . . . . . . . . 137 9.6.2 Continuity . . . . . . . . . . . . . . . . . . . . . . . . 139 9.6.3 Non-Uniform B-Splines . . . . . . . . . . . . . . . . . 140 9.6.4 Non-Uniform Rational B-Splines . . . . . . . . . . . 141 9.7 Surface Patches. . . . . . . . . . . . . . . . . . . . . . . . . . 141 9.7.1 Planar Surface Patch . . . . . . . . . . . . . . . . . . 141 9.7.2 Quadratic B´ezier Surface Patch . . . . . . . . . . . . 142 9.7.3 Cubic B´ezier Surface Patch . . . . . . . . . . . . . . 144 9.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 10 Analytic Geometry 147 10.1 Review of Geometry . . . . . . . . . . . . . . . . . . . . . . . 147 10.1.1 Angles . . . . . . . . . . . . . . . . . . . . . . . . . . 148 10.1.2 Intercept Theorems . . . . . . . . . . . . . . . . . . . 148 10.1.3 Golden Section . . . . . . . . . . . . . . . . . . . . . 149 10.1.4 Triangles . . . . . . . . . . . . . . . . . . . . . . . . . 149 Contents xi 10.1.5 Centre of Gravity of a Triangle . . . . . . . . . . . . 150 10.1.6 Isosceles Triangle . . . . . . . . . . . . . . . . . . . 150 10.1.7 Equilateral Triangle . . . . . . . . . . . . . . . . . . 151 10.1.8 Right Triangle . . . . . . . . . . . . . . . . . . . . . 151 10.1.9 Theorem of Thales. . . . . . . . . . . . . . . . . . . 152 10.1.10 Theorem of Pythagoras . . . . . . . . . . . . . . . . 152 10.1.11 Quadrilaterals . . . . . . . . . . . . . . . . . . . . . 152 10.1.12 Trapezoid. . . . . . . . . . . . . . . . . . . . . . . . 153 10.1.13 Parallelogram . . . . . . . . . . . . . . . . . . . . . 153 10.1.14 Rhombus . . . . . . . . . . . . . . . . . . . . . . . . 153 10.1.15 Regular Polygon (n-gon) . . . . . . . . . . . . . . . 154 10.1.16 Circle . . . . . . . . . . . . . . . . . . . . . . . . . . 154 10.2 2D Analytical Geometry . . . . . . . . . . . . . . . . . . . . . 156 10.2.1 Equation of a Straight Line . . . . . . . . . . . . . . 156 10.2.2 The Hessian Normal Form . . . . . . . . . . . . . . 158 10.2.3 Space Partitioning . . . . . . . . . . . . . . . . . . . 159 10.2.4 The Hessian Normal Form from Two Points . . . . 160 10.3 Intersection Points . . . . . . . . . . . . . . . . . . . . . . . . 161 10.3.1 Intersection Point of Two Straight Lines . . . . . . 161 10.3.2 Intersection Point of Two Line Segments . . . . . . 161 10.4 Point Inside a Triangle. . . . . . . . . . . . . . . . . . . . . . 164 10.4.1 Area of a Triangle . . . . . . . . . . . . . . . . . . . 164 10.4.2 Hessian Normal Form . . . . . . . . . . . . . . . . . 165 10.5 Intersection of a Circle with a Straight Line . . . . . . . . . . 168 10.6 3D Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 10.6.1 Equation of a Straight Line . . . . . . . . . . . . . . 170 10.6.2 Point of Intersection of Two Straight Lines . . . . . 171 10.7 Equation of a Plane . . . . . . . . . . . . . . . . . . . . . . . 173 10.7.1 Cartesian Form of the Plane Equation. . . . . . . . 174 10.7.2 General Form of the Plane Equation. . . . . . . . . 176 10.7.3 Parametric Form of the Plane Equation . . . . . . . 176 10.7.4 Converting From the Parametric to the General Form . . . . . . . . . . . . . . . . . . . . . . . . . . 177 10.7.5 Plane Equation from Three Points . . . . . . . . . . 179 10.8 Intersecting Planes . . . . . . . . . . . . . . . . . . . . . . . . 181 10.8.1 Intersection of Three Planes . . . . . . . . . . . . . 184 10.8.2 Angle between Two Planes . . . . . . . . . . . . . . 186 10.8.3 Angle between a Line and a Plane . . . . . . . . . . 187 10.8.4 Intersection of a Line with a Plane. . . . . . . . . . 189 10.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 11 Barycentric Coordinates 193 11.1 Ceva’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . 193 11.2 Ratios and Proportion . . . . . . . . . . . . . . . . . . . . . . 195 11.3 Mass Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 xii MathematicsforComputer Graphics 11.4 Linear Interpolation . . . . . . . . . . . . . . . . . . . . . . 202 11.5 Convex Hull Property . . . . . . . . . . . . . . . . . . . . . 208 11.6 Areas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 11.7 Volumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 11.8 B´ezier Curves and Patches . . . . . . . . . . . . . . . . . . . 220 11.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 12 Worked Examples 223 12.1 Calculate the Area of Regular Polygon . . . . . . . . . . . . 223 12.2 Calculate the Area of any Polygon . . . . . . . . . . . . . . 224 12.3 Calculate the Dihedral Angle of a Dodecahedron . . . . . . 224 12.4 Vector Normal to a Triangle . . . . . . . . . . . . . . . . . . 226 12.5 Area of a Triangle using Vectors. . . . . . . . . . . . . . . . 227 12.6 General Form of the Line Equation from Two Points . . . . 227 12.7 Calculate the Angle between Two Straight Lines . . . . . . 228 12.8 Test If Three Points Lie on a Straight Line. . . . . . . . . . 229 12.9 Find the Position and Distance of the Nearest Point on a Line to a Point . . . . . . . . . . . . . . . . . . . . . . . . . 230 12.10 Position of a Point Reflected in a Line . . . . . . . . . . . . 232 12.11 Calculate the Intersection of a Line and a Sphere . . . . . . 234 12.12 Calculate If a Sphere Touches a Plane . . . . . . . . . . . . 238 12.13 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 13 Conclusion 241 References 243 Index 245

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.