3D Math Primer for Graphics and Game Development

Book description

3D Math Primer for Graphics and Game Development covers fundamental 3D math concepts that are especially useful for computer game developers and programmers. The authors discuss the mathematical theory in detail and then provide the geometric interpretation necessary to make 3D math intuitive. Important Notice: The digital edition of this book is missing some of the images or content found in the physical edition.

Table of contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Contents
  5. Acknowledgements
  6. Chapter 1 Introduction
    1. 1.1 What is 3D Math?
    2. 1.2 Why You Should Read This Book
    3. 1.3 What You Should Know Before Reading This Book
    4. 1.4 Overview
  7. Chapter 2 The Cartesian Coordinate System
    1. 2.1 1D Mathematics
    2. 2.2 2D Cartesian Mathematics
      1. 2.2.1 An Example: The Hypothetical City of Cartesia
      2. 2.2.2 Arbitrary 2D Coordinate Spaces
      3. 2.2.3 Specifying Locations in 2D Using Cartesian Coordinates
    3. 2.3 From 2D to 3D
      1. 2.3.1 Extra Dimension, Extra Axis
      2. 2.3.2 Specifying Locations in 3D
      3. 2.3.3 Left-handed vs. Right-handed Coordinate Spaces
      4. 2.3.4 Some Important Conventions Used in This Book
    4. 2.4 Exercises
  8. Chapter 3 Multiple Coordinate Spaces
    1. 3.1 Why Multiple Coordinate Spaces?
    2. 3.2 Some Useful Coordinate Spaces
      1. 3.2.1 World Space
      2. 3.2.2 Object Space
      3. 3.2.3 Camera Space
      4. 3.2.4 Inertial Space
    3. 3.3 Nested Coordinate Spaces
    4. 3.4 Specifying Coordinate Spaces
    5. 3.5 Coordinate Space Transformations
    6. 3.6 Exercises
  9. Chapter 4 Vectors
    1. 4.1 Vector — A Mathematical Definition
      1. 4.1.1 Vectors vs. Scalars
      2. 4.1.2 Vector Dimension
      3. 4.1.3 Notation
    2. 4.2 Vector — A Geometric Definition
      1. 4.2.1 What Does a Vector Look Like?
      2. 4.2.2 Position vs. Displacement
      3. 4.2.3 Specifying Vectors
      4. 4.2.4 Vectors as a Sequence of Displacements
    3. 4.3 Vectors vs. Points
      1. 4.3.1 Relative Position
      2. 4.3.2 The Relationship Between Points and Vectors
    4. 4.4 Exercises
  10. Chapter 5 Operations on Vectors
    1. 5.1 Linear Algebra vs. What We Need
    2. 5.2 Typeface Conventions
    3. 5.3 The Zero Vector
    4. 5.4 Negating a Vector
      1. 5.4.1 Official Linear Algebra Rules
      2. 5.4.2 Geometric Interpretation
    5. 5.5 Vector Magnitude (Length)
      1. 5.5.1 Official Linear Algebra Rules
      2. 5.5.2 Geometric Interpretation
    6. 5.6 Vector Multiplication by a Scalar
      1. 5.6.1 Official Linear Algebra Rules
      2. 5.6.2 Geometric Interpretation
    7. 5.7 Normalized Vectors
      1. 5.7.1 Official Linear Algebra Rules
      2. 5.7.2 Geometric Interpretation
    8. 5.8 Vector Addition and Subtraction
      1. 5.8.1 Official Linear Algebra Rules
      2. 5.8.2 Geometric Interpretation
      3. 5.8.3 Vector from One Point to Another
    9. 5.9 The Distance Formula
    10. 5.10 Vector Dot Product
      1. 5.10.1 Official Linear Algebra Rules
      2. 5.10.2 Geometric Interpretation
      3. 5.10.3 Projecting One Vector onto Another
    11. 5.11 Vector Cross Product
      1. 5.11.1 Official Linear Algebra Rules
      2. 5.11.2 Geometric Interpretation
    12. 5.12 Linear Algebra Identities
    13. 5.13 Exercises
  11. Chapter 6 A Simple 3D Vector Class
    1. 6.1 Class Interface
    2. 6.2 Class Vector3 Definition
    3. 6.3 Design Decisions
      1. 6.3.1 Floats vs. Doubles
      2. 6.3.2 Operator Overloading
      3. 6.3.3 Provide Only the Most Important Operations
      4. 6.3.4 Don’t Overload Too Many Operators
      5. 6.3.5 Use Const Member Functions
      6. 6.3.6 Use Const & Arguments
      7. 6.3.7 Member vs. Nonmember Functions
      8. 6.3.8 No Default Initialization
      9. 6.3.9 Don’t Use Virtual Functions
      10. 6.3.10 Don’t Use Information Hiding
      11. 6.3.11 Global Zero Vector Constant
      12. 6.3.12 No “point3” Class
      13. 6.3.13 A Word on Optimization
  12. Chapter 7 Introduction to Matrices
    1. 7.1 Matrix — A Mathematical Definition
      1. 7.1.1 Matrix Dimensions and Notation
      2. 7.1.2 Square Matrices
      3. 7.1.3 Vectors as Matrices
      4. 7.1.4 Transposition
      5. 7.1.5 Multiplying a Matrix with a Scalar
      6. 7.1.6 Multiplying Two Matrices
      7. 7.1.7 Multiplying a Vector and a Matrix
      8. 7.1.8 Row vs. Column Vectors
    2. 7.2 Matrix — A Geometric Interpretation
      1. 7.2.1 How Does a Matrix Transform Vectors?
      2. 7.2.2 What Does a Matrix Look Like?
      3. 7.2.3 Summary
    3. 7.3 Exercises
  13. Chapter 8 Matrices and Linear Transformations
    1. 8.1 Transforming an Object vs. Transforming the Coordinate Space
    2. 8.2 Rotation
      1. 8.2.1 Rotation in 2D
      2. 8.2.2 3D Rotation about Cardinal Axes
      3. 8.2.3 3D Rotation about an Arbitrary Axis
    3. 8.3 Scale
      1. 8.3.1 Scaling along Cardinal Axes
      2. 8.3.2 Scale in an Arbitrary Direction
    4. 8.4 Orthographic Projection
      1. 8.4.1 Projecting onto a Cardinal Axis or Plane
      2. 8.4.2 Projecting onto an Arbitrary Line or Plane
    5. 8.5 Reflection
    6. 8.6 Shearing
    7. 8.7 Combining Transformations
    8. 8.8 Classes of Transformations
      1. 8.8.1 Linear Transformations
      2. 8.8.2 Affine Transformations
      3. 8.8.3 Invertible Transformations
      4. 8.8.4 Angle-preserving Transformations
      5. 8.8.5 Orthogonal Transformations
      6. 8.8.6 Rigid Body Transformations
      7. 8.8.7 Summary of Types of Transformations
    9. 8.9 Exercises
  14. Chapter 9 More on Matrices
    1. 9.1 Determinant of a Matrix
      1. 9.1.1 Official Linear Algebra Rules
      2. 9.1.2 Geometric Interpretation
    2. 9.2 Inverse of a Matrix
      1. 9.2.1 Official Linear Algebra Rules
      2. 9.2.2 Geometric Interpretation
    3. 9.3 Orthogonal Matrices
      1. 9.3.1 Official Linear Algebra Rules
      2. 9.3.2 Geometric Interpretation
      3. 9.3.3 Orthogonalizing a Matrix
    4. 9.4 4×4 Homogenous Matrices
      1. 9.4.1 4D Homogenous Space
      2. 9.4.2 4×4 Translation Matrices
      3. 9.4.3 General Affine Transformations
      4. 9.4.4 Perspective Projection
      5. 9.4.5 A Pinhole Camera
      6. 9.4.6 Perspective Projection Using 4×4 Matrices
    5. 9.5 Exercises
  15. Chapter 10 Orientation and Angular Displacement in 3D
    1. 10.1 What is Orientation?
    2. 10.2 Matrix Form
      1. 10.2.1 Which Matrix?
      2. 10.2.2 Advantages of Matrix Form
      3. 10.2.3 Disadvantages of Matrix Form
      4. 10.2.4 Summary
    3. 10.3 Euler Angles
      1. 10.3.1 What are Euler Angles?
      2. 10.3.2 Other Euler Angle Conventions
      3. 10.3.3 Advantages of Euler Angles
      4. 10.3.4 Disadvantages of Euler Angles
      5. 10.3.5 Summary
    4. 10.4 Quaternions
      1. 10.4.1 Quaternion Notation
      2. 10.4.2 Quaternions as Complex Numbers
      3. 10.4.3 Quaternions as an Axis-Angle Pair
      4. 10.4.4 Quaternion Negation
      5. 10.4.5 Identity Quaternion(s)
      6. 10.4.6 Quaternion Magnitude
      7. 10.4.7 Quaternion Conjugate and Inverse
      8. 10.4.8 Quaternion Multiplication (Cross Product)
      9. 10.4.9 Quaternion “Difference”
      10. 10.4.10 Quaternion Dot Product
      11. 10.4.11 Quaternion Log, Exp, and Multiplication by a Scalar
      12. 10.4.12 Quaternion Exponentiation
      13. 10.4.13 Quaternion Interpolation — aka “Slerp”
      14. 10.4.14 Quaternion Splines — aka “Squad”
      15. 10.4.15 Advantages/Disadvantages of Quaternions
    5. 10.5 Comparison of Methods
    6. 10.6 Converting between Representations
      1. 10.6.1 Converting Euler Angles to a Matrix
      2. 10.6.2 Converting a Matrix to Euler Angles
      3. 10.6.3 Converting a Quaternion to a Matrix
      4. 10.6.4 Converting a Matrix to a Quaternion
      5. 10.6.5 Converting Euler Angles to a Quaternion
      6. 10.6.6 Converting a Quaternion to Euler Angles
    7. 10.7 Exercises
  16. Chapter 11 Transformations in C++
    1. 11.1 Overview
    2. 11.2 Class EulerAngles
    3. 11.3 Class Quaternion
    4. 11.4 Class RotationMatrix
    5. 11.5 Class Matrix4×3
  17. Chapter 12 Geometric Primitives
    1. 12.1 Representation Techniques
      1. 12.1.1 Implicit Form
      2. 12.1.2 Parametric Form
      3. 12.1.3 “Straightforward” Forms
      4. 12.1.4 Degrees of Freedom
    2. 12.2 Lines and Rays
      1. 12.2.1 Two Points Representation
      2. 12.2.2 Parametric Representation of Rays
      3. 12.2.3 Special 2D Representations of Lines
      4. 12.2.4 Converting between Representations
    3. 12.3 Spheres and Circles
    4. 12.4 Bounding Boxes
      1. 12.4.1 Representing AABBs
      2. 12.4.2 Computing AABBs
      3. 12.4.3 AABBs vs. Bounding Spheres
      4. 12.4.4 Transforming AABBs
    5. 12.5 Planes
      1. 12.5.1 Implicit Definition — The Plane Equation
      2. 12.5.2 Definition Using Three Points
      3. 12.5.3 “Best-fit” Plane for More Than Three Points
      4. 12.5.4 Distance from Point to Plane
    6. 12.6 Triangles
      1. 12.6.1 Basic Properties of a Triangle
      2. 12.6.2 Area of a Triangle
      3. 12.6.3 Barycentric Space
      4. 12.6.4 Special Points
    7. 12.7 Polygons
      1. 12.7.1 Simple vs. Complex Polygons
      2. 12.7.2 Self-intersecting Polygons
      3. 12.7.3 Convex vs. Concave Polygons
      4. 12.7.4 Triangulation and Fanning
    8. 12.8 Exercises
  18. Chapter 13 Geometric Tests
    1. 13.1 Closest Point on 2D Implicit Line
    2. 13.2 Closest Point on Parametric Ray
    3. 13.3 Closest Point on Plane
    4. 13.4 Closest Point on Circle/Sphere
    5. 13.5 Closest Point in AABB
    6. 13.6 Intersection Tests
    7. 13.7 Intersection of Two Implicit Lines in 2D
    8. 13.8 Intersection of Two Rays in 3D
    9. 13.9 Intersection of Ray and Plane
    10. 13.10 Intersection of AABB and Plane
    11. 13.11 Intersection of Three Planes
    12. 13.12 Intersection of Ray and Circle/Sphere
    13. 13.13 Intersection of Two Circles/Spheres
    14. 13.14 Intersection of Sphere and AABB
    15. 13.15 Intersection of Sphere and Plane
    16. 13.16 Intersection of Ray and Triangle
    17. 13.17 Intersection of Ray and AABB
    18. 13.18 Intersection of Two AABBs
    19. 13.19 Other Tests
    20. 13.20 Class AABB3
    21. 13.21 Exercises
  19. Chapter 14 Triangle Meshes
    1. 14.1 Representing Meshes
      1. 14.1.1 Indexed Triangle Mesh
      2. 14.1.2 Advanced Techniques
      3. 14.1.3 Specialized Representations for Rendering
      4. 14.1.4 Vertex Caching
      5. 14.1.5 Triangle Strips
      6. 14.1.6 Triangle Fans
    2. 14.2 Additional Mesh Information
      1. 14.2.1 Texture Mapping Coordinates
      2. 14.2.2 Surface Normals
      3. 14.2.3 Lighting Values
    3. 14.3 Topology and Consistency
    4. 14.4 Triangle Mesh Operations
      1. 14.4.1 Piecewise Operations
      2. 14.4.2 Welding Vertices
      3. 14.4.3 Detaching Faces
      4. 14.4.4 Edge Collapse
      5. 14.4.5 Mesh Decimation
    5. 14.5 A C++ Triangle Mesh Class
  20. Chapter 15 3D Math for Graphics
    1. 15.1 Graphics Pipeline Overview
    2. 15.2 Setting the View Parameters
      1. 15.2.1 Specifying the Output Window
      2. 15.2.2 Pixel Aspect Ratio
      3. 15.2.3 The View Frustum
      4. 15.2.4 Field of View and Zoom
    3. 15.3 Coordinate Spaces
      1. 15.3.1 Modeling and World Space
      2. 15.3.2 Camera Space
      3. 15.3.3 Clip Space
      4. 15.3.4 Screen Space
    4. 15.4 Lighting and Fog
      1. 15.4.1 Math on Colors
      2. 15.4.2 Light Sources
      3. 15.4.3 The Standard Lighting Equation — Overview
      4. 15.4.4 The Specular Component
      5. 15.4.5 The Diffuse Component
      6. 15.4.6 The Ambient Component
      7. 15.4.7 Light Attenuation
      8. 15.4.8 The Lighting Equation — Putting It All Together
      9. 15.4.9 Fog
      10. 15.4.10 Flat Shading and Gouraud Shading
    5. 15.5 Buffers
    6. 15.6 Texture Mapping
    7. 15.7 Geometry Generation/Delivery
      1. 15.7.1 LOD Selection and Procedural Modeling
      2. 15.7.2 Delivery of Geometry to the API
    8. 15.8 Transformation and Lighting
      1. 15.8.1 Transformation to Clip Space
      2. 15.8.2 Vertex Lighting
    9. 15.9 Backface Culling and Clipping
      1. 15.9.1 Backface Culling
      2. 15.9.2 Clipping
    10. 15.10 Rasterization
  21. Chapter 16 Visibility Determination
    1. 16.1 Bounding Volume Tests
      1. 16.1.1 Testing Against the View Frustum
      2. 16.1.2 Testing for Occlusion
    2. 16.2 Space Partitioning Techniques
    3. 16.3 Grid Systems
    4. 16.4 Quadtrees and Octrees
    5. 16.5 BSP Trees
      1. 16.5.1 “Old School” BSPs
      2. 16.5.2 Arbitrary Dividing Planes
    6. 16.6 Occlusion Culling Techniques
      1. 16.6.1 Potentially Visible Sets
      2. 16.6.2 Portal Techniques
  22. Chapter 17 Afterword
  23. Appendix A Math Review
    1. Summation Notation
    2. Angles, Degrees, and Radians
    3. Trig Functions
    4. Trig Identities
  24. Appendix B References
  25. Index

Product information

  • Title: 3D Math Primer for Graphics and Game Development
  • Author(s): Fletcher Dunn, Ian Parberry
  • Release date: June 2002
  • Publisher(s): Jones & Bartlett Learning
  • ISBN: 9781449612719