You are previewing Mathematics for 3D Game Programming and Computer Graphics, Third Edition.

Mathematics for 3D Game Programming and Computer Graphics, Third Edition

Cover of Mathematics for 3D Game Programming and Computer Graphics, Third Edition by Eric Lengyel Published by Course Technology PTR
  1. Copyright
  2. Preface
    1. What’s New in the Third Edition
    2. Contents Overview
    3. Website and Code Listings
    4. Notational Conventions
  3. 1. The Rendering Pipeline
    1. 1.1. Graphics Processors
    2. 1.2. Vertex Transformation
    3. 1.3. Rasterization and Fragment Operations
  4. 2. Vectors
    1. 2.1. Vector Properties
    2. 2.2. The Dot Product
    3. 2.3. The Cross Product
    4. 2.4. Vector Spaces
    5. Chapter 2 Summary
    6. Exercises for Chapter 2
  5. 3. Matrices
    1. 3.1. Matrix Properties
    2. 3.2. Linear Systems
    3. 3.3. Matrix Inverses
    4. 3.4. Determinants
    5. 3.5. Eigenvalues and Eigenvectors
    6. 3.6. Diagonalization
    7. Chapter 3 Summary
    8. Exercises for Chapter 3
  6. 4. Transforms
    1. 4.1. Linear Transformations
      1. 4.1.1. Orthogonal Matrices
      2. 4.1.2. Handedness
    2. 4.2. Scaling Transforms
    3. 4.3. Rotation Transforms
      1. 4.3.1. Rotation About an Arbitrary Axis
    4. 4.4. Homogeneous Coordinates
      1. 4.4.1. Four-Dimensional Transforms
      2. 4.4.2. Points and Directions
      3. 4.4.3. Geometrical Interpretation of the w aCoordinate
    5. 4.5. Transforming Normal Vectors
    6. 4.6. Quaternions
      1. 4.6.1. Quaternion Mathematics
      2. 4.6.2. Rotations with Quaternions
      3. 4.6.3. Spherical Linear Interpolation
    7. Chapter 4 Summary
    8. Exercises for Chapter 4
  7. 5. Geometry for 3D Engines
    1. 5.1. Lines in 3D Space
      1. 5.1.1. Distance Between a Point and a Line
      2. 5.1.2. Distance Between Two Lines
    2. 5.2. Planes in 3D Space
      1. 5.2.1. Intersection of a Line and a Plane
      2. 5.2.2. Intersection of Three Planes
      3. 5.2.3. Transforming Planes
    3. 5.3. The View Frustum
      1. 5.3.1. Field of View
      2. 5.3.2. Frustum Planes
    4. 5.4. Perspective-Correct Interpolation
      1. 5.4.1. Depth Interpolation
      2. 5.4.2. Vertex Attribute Interpolation
    5. 5.5. Projections
      1. 5.5.1. Perspective Projections
      2. 5.5.2. Orthographic Projections
      3. 5.5.5. Extracting Frustum Planes
    6. 5.6. Reflections and Oblique Clipping
    7. Chapter 5 Summary
    8. Exercises for Chapter 5
  8. 6. Ray Tracing
    1. 6.1. Root Finding
      1. 6.1.1. Quadratic Polynomials
      2. 6.1.2. Cubic Polynomials
      3. 6.1.3. Quartic Polynomials
      4. 6.1.4. Newton’s Method
      5. 6.1.5. Refinement of Reciprocals and Square Roots
    2. 6.2. Surface Intersections
      1. 6.2.1. Intersection of a Ray and a Triangle
      2. 6.2.2. Intersection of a Ray and a Box
      3. 6.2.3. Intersection of a Ray and a Sphere
      4. 6.2.4. Intersection of a Ray and a Cylinder
      5. 6.2.5. Intersection of a Ray and a Torus
    3. 6.3. Normal Vector Calculation
    4. 6.4. Reflection and Refraction Vectors
      1. 6.4.1. Reflection Vector Calculation
      2. 6.4.2. Refraction Vector Calculation
    5. Chapter 6 Summary
    6. Exercises for Chapter 6
  9. 7. Lighting and Shading
    1. 7.1. RGB Color
    2. 7.2. Light Sources
      1. 7.2.1. Ambient Light
      2. 7.2.2. Directional Light Sources
      3. 7.2.3. Point Light Sources
      4. 7.2.4. Spot Light Sources
    3. 7.3. Diffuse Reflection
    4. 7.4. Specular Reflection
    5. 7.5. Texture Mapping
      1. 7.5.1. Standard Texture Maps
      2. 7.5.2. Projective Texture Maps
      3. 7.5.3. Cube Texture Maps
      4. 7.5.4. Filtering and Mipmaps
    6. 7.6. Emission
    7. 7.7. Shading Models
      1. 7.7.1. Calculating Normal Vectors
      2. 7.7.2. Gouraud Shading
      3. 7.7.3. Blinn-Phong Shading
    8. 7.8. Bump Mapping
      1. 7.8.1. Bump Map Construction
      2. 7.8.2. Tangent Space
      3. 7.8.3. Calculating Tangent Vectors
      4. 7.8.4. Implementation
    9. 7.9. A Physical Reflection Model
      1. 7.9.1. Bidirectional Reflectance Distribution Functions
      2. 7.9.2. Cook-Torrance Illumination
      3. 7.9.3. The Fresnel Factor
      4. 7.9.4. The Microfacet Distribution Function
      5. 7.9.5. The Geometrical Attenuation Factor
      6. 7.9.6. Implementation
    10. Chapter 7 Summary
    11. Exercises for Chapter 7
  10. 8. Visibility Determination
    1. 8.1. Bounding Volume Construction
      1. 8.1.1. Principal Component Analysis
      2. 8.1.2. Bounding Box Construction
      3. 8.1.3. Bounding Sphere Construction
      4. 8.1.4. Bounding Ellipsoid Construction
      5. 8.1.5. Bounding Cylinder Construction
    2. 8.2. Bounding Volume Tests
      1. 8.2.1. Bounding Sphere Test
      2. 8.2.2. Bounding Ellipsoid Test
      3. 8.2.3. Bounding Cylinder Test
      4. 8.2.4. Bounding Box Test
    3. 8.3. Spatial Partitioning
      1. 8.3.1. Octrees
      2. 8.3.2. Binary Space Partitioning Trees
    4. 8.4. Portal Systems
      1. 8.4.1. Portal Clipping
      2. 8.4.2. Reduced View Frustums
    5. Chapter 8 Summary
    6. Exercises for Chapter 8
  11. 9. Polygonal Techniques
    1. 9.1. Depth Value Offset
      1. 9.1.1. Projection Matrix Modification
      2. 9.1.2. Offset Value Selection
      3. 9.1.3. Implementation
    2. 9.2. Decal Application
      1. 9.2.1. Decal Mesh Construction
      2. 9.2.2. Polygon Clipping
    3. 9.3. Billboarding
      1. 9.3.1. Unconstrained Quads
      2. 9.3.2. Constrained Quads
      3. 9.3.3. Polyboards
    4. 9.4. Polygon Reduction
    5. 9.5. T-Junction Elimination
    6. 9.6. Triangulation
    7. Chapter 9 Summary
    8. Exercises for Chapter 9
  12. 10. Shadows
    1. 10.1. Shadow Casting Set
    2. 10.2. Shadow Mapping
      1. 10.2.1. Rendering the Shadow Map
      2. 10.2.2. Rendering the Main Scene
      3. 10.2.3. Self-Shadowing
    3. 10.3. Stencil Shadows
      1. 10.3.1. Algorithm Overview
      2. 10.3.2. Infinite View Frustums
      3. 10.3.3. Silhouette Determination
      4. 10.3.4. Shadow Volume Construction
      5. 10.3.5. Determining Cap Necessity
      6. 10.3.6. Rendering Shadow Volumes
      7. 10.3.7. Scissor Optimization
    4. Chapter 10 Summary
    5. Exercises for Chapter 10
  13. 11. Curves and Surfaces
    1. 11.1. Cubic Curves
    2. 11.2. Hermite Curves
    3. 11.3. Bézier Curves
      1. 11.3.1. Cubic Bezier Curves
      2. 11.3.2. Bézier Curve Truncation
      3. 11.3.3. The de Casteljau Algorithm
    4. 11.4. Catmull-Rom Splines
    5. 11.5. Cubic Splines
    6. 11.6. B-Splines
      1. 11.6.1. Uniform B-Splines
      2. 11.6.2. B-Spline Globalization
      3. 11.6.3. Nonuniform B-Splines
      4. 11.6.4. NURBS
    7. 11.7. Bicubic Surfaces
    8. 11.8. Curvature and Torsion
    9. Chapter 11 Summary
    10. Exercises for Chapter 11
  14. 12. Collision Detection
    1. 12.1. Plane Collisions
      1. 12.1.1. Collision of a Sphere and a Plane
      2. 12.1.2. Collision of a Box and a Plane
      3. 12.1.3. Spatial Partitioning
    2. 12.2. General Sphere Collisions
    3. 12.3. Sliding
    4. 12.4. Collision of Two Spheres
    5. Chapter 12 Summary
    6. Exercises for Chapter 12
  15. 13. Linear Physics
    1. 13.1. Position Functions
    2. 13.2. Second-Order Differential Equations
      1. 13.2.1. Homogeneous Equations
      2. 13.2.2. Nonhomogeneous Equations
      3. 13.2.3. Initial Conditions
    3. 13.3. Projectile Motion
    4. 13.4. Resisted Motion
    5. 13.5. Friction
    6. Chapter 13 Summary
    7. Exercises for Chapter 13
  16. 14. Rotational Physics
    1. 14.1. Rotating Environments
      1. 14.1.1. Angular Velocity
      2. 14.1.2. The Centrifugal Force
      3. 14.1.3. The Coriolis Force
    2. 14.2. Rigid Body Motion
      1. 14.2.1. Center of Mass
      2. 14.2.2. Angular Momentum and Torque
      3. 14.2.3. The Inertia Tensor
      4. 14.2.4. Principal Axes of Inertia
      5. 14.2.5. Transforming the Inertia Tensor
    3. 14.3. Oscillatory Motion
      1. 14.3.1. Spring Motion
      2. 14.3.2. Pendulum Motion
    4. Chapter 14 Summary
    5. Exercises for Chapter 14
  17. 15. Fluid and Cloth Simulation
    1. 15.1. Fluid Simulation
      1. 15.1.1. The Wave Equation
      2. 15.1.2. Approximating Derivatives
      3. 15.1.3. Evaluating Surface Displacement
      4. 15.1.4. Implementation
    2. 15.2. Cloth Simulation
      1. 15.2.1. The Spring System
      2. 15.2.2. External Forces
      3. 15.2.3. Implementation
    3. Chapter 15 Summary
    4. Exercises for Chapter 15
  18. 16. Numerical Methods
    1. 16.1. Trigonometric Functions
    2. 16.2. Linear Systems
      1. 16.2.1. Triangular Systems
      2. 16.2.2. Gaussian Elimination
      3. 16.2.3. LU Decomposition
      4. 16.2.4. Error Reduction
      5. 16.2.5. Tridiagonal Systems
    3. 16.3. Eigenvalues and Eigenvectors
    4. 16.4. Ordinary Differential Equations
      1. 16.4.1. Euler’s Method
      2. 16.4.2. Taylor Series Method
      3. 16.4.3. Runge-Kutta Method
      4. 16.4.4. Higher-Order Differential Equations
    5. Chapter 16 Summary
    6. Exercises for Chapter 16
  19. A. Complex Numbers
    1. A.1. Definition
    2. A.2. Addition and Multiplication
    3. A.3. Conjugates and Inverses
    4. A.4. The Euler Formula
  20. B. Trigonometry Reference
    1. B.1. Function Definitions
    2. B.2. Symmetry and Phase Shifts
    3. B.3. Pythagorean Identities
    4. B.4. Exponential Identities
    5. B.5. Inverse Functions
    6. B.6. Laws of Sines and Cosines
  21. C. Coordinate Systems
    1. C.1. Cartesian Coordinates
    2. C.2. Cylindrical Coordinates
    3. C.3. Spherical Coordinates
    4. C.4. Generalized Coordinates
  22. D. Taylor Series
    1. D.1. Derivation
    2. D.2. Power Series
    3. D.3. The Euler Formula
  23. E. Answers to Exercises
    1. Chapter 2
    2. Chapter 3
    3. Chapter 4
    4. Chapter 5
    5. Chapter 6
    6. Chapter 7
    7. Chapter 8
    8. Chapter 9
    9. Chapter 10
    10. Chapter 11
    11. Chapter 12
    12. Chapter 13
    13. Chapter 14
    14. Chapter 15
    15. Chapter 16
O'Reilly logo

Chapter 4. Transforms

Throughout any 3D graphics engine architecture, it is often necessary to transform a set of vectors from one coordinate space to another. For instance, vertex coordinates for a model may be stored in object space, but need to be transformed to camera space before the model can be rendered. In this chapter, we concern ourselves with linear transformations among different Cartesian coordinate frames. Such transformations include simple scales and translations, as well as arbitrary rotations.

Linear Transformations

Suppose that we have established a 3D coordinate system C consisting of an origin and three coordinate axes, in which a point P has the coordinates 〈x, y, z〉. The values x, y, and z can be thought of as the distances ...

The best content for your career. Discover unlimited learning on demand for around $1/day.