logo资料库

Course - Mathematics for 3D Game Programming and Computer Graphi....pdf

第1页 / 共566页
第2页 / 共566页
第3页 / 共566页
第4页 / 共566页
第5页 / 共566页
第6页 / 共566页
第7页 / 共566页
第8页 / 共566页
资料共566页,剩余部分请下载后查看
Cover
Contents
Preface
What’s New in the Third Edition
Contents Overview
Website and Code Listings
Notational Conventions
Chapter 1 The Rendering Pipeline
1.1 Graphics Processors
1.2 Vertex Transformation
1.3 Rasterization and Fragment Operations
Chapter 2 Vectors
2.1 Vector Properties
2.2 The Dot Product
2.3 The Cross Product
2.4 Vector Spaces
Chapter 2 Summary
Exercises for Chapter 2
Chapter 3 Matrices
3.1 Matrix Properties
3.2 Linear Systems
3.3 Matrix Inverses
3.4 Determinants
3.5 Eigenvalues and Eigenvectors
3.6 Diagonalization
Chapter 3 Summary
Exercises for Chapter 3
Chapter 4 Transforms
4.1 Linear Transformations
4.1.1 Orthogonal Matrices
4.1.2 Handedness
4.2 Scaling Transforms
4.3 Rotation Transforms
4.3.1 Rotation About an Arbitrary Axis
4.4 Homogeneous Coordinates
4.4.1 Four-Dimensional Transforms
4.4.2 Points and Directions
4.4.3 Geometrical Interpretation of the w Coordinate
4.5 Transforming Normal Vectors
4.6 Quaternions
4.6.1 Quaternion Mathematics
4.6.2 Rotations with Quaternions
4.6.3 Spherical Linear Interpolation
Chapter 4 Summary
Exercises for Chapter 4
Chapter 5 Geometry for 3D Engines
5.1 Lines in 3D Space
5.1.1 Distance Between a Point and a Line
5.1.2 Distance Between Two Lines
5.2 Planes in 3D Space
5.2.1 Intersection of a Line and a Plane
5.2.2 Intersection of Three Planes
5.2.3 Transforming Planes
5.3 The View Frustum
5.3.1 Field of View
5.3.2 Frustum Planes
5.4 Perspective-Correct Interpolation
5.4.1 Depth Interpolation
5.4.2 Vertex Attribute Interpolation
5.5 Projections
5.5.1 Perspective Projections
5.5.2 Orthographic Projections
5.5.3 Extracting Frustum Planes
5.6 Reflections and Oblique Clipping
Chapter 5 Summary
Exercises for Chapter 5
Chapter 6 Ray Tracing
6.1 Root Finding
6.1.1 Quadratic Polynomials
6.1.2 Cubic Polynomials
6.1.3 Quartic Polynomials
6.1.4 Newton’s Method
6.1.5 Refinement of Reciprocals and Square Roots
6.2 Surface Intersections
6.2.1 Intersection of a Ray and a Triangle
6.2.2 Intersection of a Ray and a Box
6.2.3 Intersection of a Ray and a Sphere
6.2.4 Intersection of a Ray and a Cylinder
6.2.5 Intersection of a Ray and a Torus
6.3 Normal Vector Calculation
6.4 Reflection and Refraction Vectors
6.4.1 Reflection Vector Calculation
6.4.2 Refraction Vector Calculation
Chapter 6 Summary
Exercises for Chapter 6
Chapter 7 Lighting and Shading
7.1 RGB Color
7.2 Light Sources
7.2.1 Ambient Light
7.2.2 Directional Light Sources
7.2.3 Point Light Sources
7.2.4 Spot Light Sources
7.3 Diffuse Reflection
7.4 Specular Reflection
7.5 Texture Mapping
7.5.1 Standard Texture Maps
7.5.2 Projective Texture Maps
7.5.3 Cube Texture Maps
7.5.4 Filtering and Mipmaps
7.6 Emission
7.7 Shading Models
7.7.1 Calculating Normal Vectors
7.7.2 Gouraud Shading
7.7.3 Blinn-Phong Shading
7.8 Bump Mapping
7.8.1 Bump Map Construction
7.8.2 Tangent Space
7.8.3 Calculating Tangent Vectors
7.8.4 Implementation
7.9 A Physical Reflection Model
7.9.1 Bidirectional Reflectance Distribution Functions
7.9.2 Cook-Torrance Illumination
7.9.3 The Fresnel Factor
7.9.4 The Microfacet Distribution Function
7.9.5 The Geometrical Attenuation Factor
7.9.6 Implementation
Chapter 7 Summary
Exercises for Chapter 7
Chapter 8 Visibility Determination
8.1 Bounding Volume Construction
8.1.1 Principal Component Analysis
8.1.2 Bounding Box Construction
8.1.3 Bounding Sphere Construction
8.1.4 Bounding Ellipsoid Construction
8.1.5 Bounding Cylinder Construction
8.2 Bounding Volume Tests
8.2.1 Bounding Sphere Test
8.2.2 Bounding Ellipsoid Test
8.2.3 Bounding Cylinder Test
8.2.4 Bounding Box Test
8.3 Spatial Partitioning
8.3.1 Octrees
8.3.2 Binary Space Partitioning Trees
8.4 Portal Systems
8.4.1 Portal Clipping
8.4.2 Reduced View Frustums
Chapter 8 Summary
Exercises for Chapter 8
Chapter 9 Polygonal Techniques
9.1 Depth Value Offset
9.1.1 Projection Matrix Modification
9.1.2 Offset Value Selection
9.1.3 Implementation
9.2 Decal Application
9.2.1 Decal Mesh Construction
9.2.2 Polygon Clipping
9.3 Billboarding
9.3.1 Unconstrained Quads
9.3.2 Constrained Quads
9.3.3 Polyboards
9.4 Polygon Reduction
9.5 T-Junction Elimination
9.6 Triangulation
Chapter 9 Summary
Exercises for Chapter 9
Chapter 10 Shadows
10.1 Shadow Casting Set
10.2 Shadow Mapping
10.2.1 Rendering the Shadow Map
10.2.2 Rendering the Main Scene
10.2.3 Self-Shadowing
10.3 Stencil Shadows
10.3.1 Algorithm Overview
10.3.2 Infinite View Frustums
10.3.3 Silhouette Determination
10.3.4 Shadow Volume Construction
10.3.5 Determining Cap Necessity
10.3.6 Rendering Shadow Volumes
10.3.7 Scissor Optimization
Chapter 10 Summary
Exercises for Chapter 10
Chapter 11 Curves and Surfaces
11.1 Cubic Curves
11.2 Hermite Curves
11.3 Bézier Curves
11.3.1 Cubic Bézier Curves
11.3.2 Bézier Curve Truncation
11.3.3 The de Casteljau Algorithm
11.4 Catmull-Rom Splines
11.5 Cubic Splines
11.6 B-Splines
11.6.1 Uniform B-Splines
11.6.2 B-Spline Globalization
11.6.3 Nonuniform B-Splines
11.6.4 NURBS
11.7 Bicubic Surfaces
11.8 Curvature and Torsion
Chapter 11 Summary
Exercises for Chapter 11
Chapter 12 Collision Detection
12.1 Plane Collisions
12.1.1 Collision of a Sphere and a Plane
12.1.2 Collision of a Box and a Plane
12.1.3 Spatial Partitioning
12.2 General Sphere Collisions
12.3 Sliding
12.4 Collision of Two Spheres
Chapter 12 Summary
Exercises for Chapter 12
Chapter 13 Linear Physics
13.1 Position Functions
13.2 Second-Order Differential Equations
13.2.1 Homogeneous Equations
13.2.2 Nonhomogeneous Equations
13.2.3 Initial Conditions
13.3 Projectile Motion
13.4 Resisted Motion
13.5 Friction
Chapter 13 Summary
Exercises for Chapter 13
Chapter 14 Rotational Physics
14.1 Rotating Environments
14.1.1 Angular Velocity
14.1.2 The Centrifugal Force
14.1.3 The Coriolis Force
14.2 Rigid Body Motion
14.2.1 Center of Mass
14.2.2 Angular Momentum and Torque
14.2.3 The Inertia Tensor
14.2.4 Principal Axes of Inertia
14.2.5 Transforming the Inertia Tensor
14.3 Oscillatory Motion
14.3.1 Spring Motion
14.3.2 Pendulum Motion
Chapter 14 Summary
Exercises for Chapter 14
Chapter 15 Fluid and Cloth Simulation
15.1 Fluid Simulation
15.1.1 The Wave Equation
15.1.2 Approximating Derivatives
15.1.3 Evaluating Surface Displacement
15.1.4 Implementation
15.2 Cloth Simulation
15.2.1 The Spring System
15.2.2 External Forces
15.2.3 Implementation
Chapter 15 Summary
Exercises for Chapter 15
Chapter 16 Numerical Methods
16.1 Trigonometric Functions
16.2 Linear Systems
16.2.1 Triangular Systems
16.2.2 Gaussian Elimination
16.2.3 LU Decomposition
16.2.4 Error Reduction
16.2.5 Tridiagonal Systems
16.3 Eigenvalues and Eigenvectors
16.4 Ordinary Differential Equations
16.4.1 Euler’s Method
16.4.2 Taylor Series Method
16.4.3 Runge-Kutta Method
16.4.4 Higher-Order Differential Equations
Chapter 16 Summary
Exercises for Chapter 16
Appendix A: Complex Numbers
A.1 Definition
A.2 Addition and Multiplication
A.3 Conjugates and Inverses
A.4 The Euler Formula
Appendix B: Trigonometry Reference
B.1 Function Definitions
B.2 Symmetry and Phase Shifts
B.3 Pythagorean Identities
B.4 Exponential Identities
B.5 Inverse Functions
B.6 Laws of Sines and Cosines
Appendix C: Coordinate Systems
C.1 Cartesian Coordinates
C.2 Cylindrical Coordinates
C.3 Spherical Coordinates
C.4 Generalized Coordinates
Appendix D: Taylor Series
D.1 Derivation
D.2 Power Series
D.3 The Euler Formula
Appendix E: Answers to Exercises
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Z
Mathematics for 3D Game Programming and Computer Graphics Third Edition Eric Lengyel Course Technology PTR A part of Cengage Learning Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
Mathematics for 3D Game Programming and Computer Graphics, Third Edition By Eric Lengyel Publisher and General Manager, Course Technology PTR: Stacy L. Hiquet Associate Director of Marketing: Sarah Panella Manager of Editorial Services: Heather Talbot Marketing Manager: Jordan Castellani Senior Acquisitions Editor: Emi Smith Cover Designer: Mike Tanamachi Proofreader: Mike Beady Printed in China 1 2 3 4 5 6 7 13 12 11 © 2012 Course Technology, a part of Cengage Learning. ALL RIGHTS RESERVED. No part of this work covered by the copyright herein may be reproduced, transmitted, stored, or used in any form or by any means graphic, electronic, or mechanical, including but not limited to photocopying, recording, scanning, digitizing, taping, Web distribution, information networks, or information storage and retrieval systems, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the publisher. For product information and technology assistance, contact us at Cengage Learning Customer & Sales Support, 1-800-354-9706 For permission to use material from this text or product, submit all requests online at cengage.com/permissions Further permissions questions can be emailed to permissionrequest@cengage.com All trademarks are the property of their respective owners. All images © Cengage Learning unless otherwise noted. Library of Congress Control Number: 2011924487 ISBN-13: 978-1-4354-5886-4 ISBN-10: 1-4354-5886-9 eISBN-10: 1-4354-5887-7 Course Technology, a part of Cengage Learning 20 Channel Center Street Boston, MA 02210 USA Cengage Learning is a leading provider of customized learning solutions with office locations around the globe, including Singapore, the United Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at: international.cengage.com/region Cengage Learning products are represented in Canada by Nelson Education, Ltd. For your lifelong learning solutions, visit courseptr.com Visit our corporate website at cengage.com
Contents Preface What’s New in the Third Edition Contents Overview Website and Code Listings Notational Conventions Chapter 1  The Rendering Pipeline 1.1 Graphics Processors 1.2 Vertex Transformation 1.3 Rasterization and Fragment Operations Chapter 2  Vectors 2.1 Vector Properties 2.2 The Dot Product 2.3 The Cross Product 2.4 Vector Spaces Chapter 2 Summary Exercises for Chapter 2 Chapter 3  Matrices 3.1 Matrix Properties 3.2 Linear Systems 3.3 Matrix Inverses 3.4 Determinants 3.5 Eigenvalues and Eigenvectors 3.6 Diagonalization   xiii  xiii  xiv  xvii  xvii  1  1  4  6  11  11  15  19  26  29  30  31  31  34  40  47  54  58  iii 
iv  Chapter 3 Summary Exercises for Chapter 3 Chapter 4  Transforms 4.1 Linear Transformations 4.1.1 Orthogonal Matrices 4.1.2 Handedness 4.2 Scaling Transforms 4.3 Rotation Transforms 4.3.1 Rotation About an Arbitrary Axis 4.4 Homogeneous Coordinates 4.4.1 Four-Dimensional Transforms 4.4.2 Points and Directions 4.4.3 Geometrical Interpretation of the w Coordinate 4.5 Transforming Normal Vectors 4.6 Quaternions 4.6.1 Quaternion Mathematics 4.6.2 Rotations with Quaternions 4.6.3 Spherical Linear Interpolation Chapter 4 Summary Exercises for Chapter 4 Chapter 5  Geometry for 3D Engines 5.1 Lines in 3D Space 5.1.1 Distance Between a Point and a Line 5.1.2 Distance Between Two Lines 5.2 Planes in 3D Space 5.2.1 Intersection of a Line and a Plane 5.2.2 Intersection of Three Planes 5.2.3 Transforming Planes 5.3 The View Frustum 5.3.1 Field of View 5.3.2 Frustum Planes 5.4 Perspective-Correct Interpolation 5.4.1 Depth Interpolation 5.4.2 Vertex Attribute Interpolation 5.5 Projections 5.5.1 Perspective Projections 5.5.2 Orthographic Projections Contents  62  64  67  67  68  70  70  71  74  75  76  77  78  78  80  80  82  86  89  91  93  93  93  94  97  98  99  101  102  103  106  107  108  110  111  112  116 
  5.5.3 Extracting Frustum Planes 5.6 Reflections and Oblique Clipping Chapter 5 Summary Exercises for Chapter 5 Chapter 6  Ray Tracing 6.1 Root Finding 6.1.1 Quadratic Polynomials 6.1.2 Cubic Polynomials 6.1.3 Quartic Polynomials 6.1.4 Newton’s Method 6.1.5 Refinement of Reciprocals and Square Roots 6.2 Surface Intersections 6.2.1 Intersection of a Ray and a Triangle 6.2.2 Intersection of a Ray and a Box 6.2.3 Intersection of a Ray and a Sphere 6.2.4 Intersection of a Ray and a Cylinder 6.2.5 Intersection of a Ray and a Torus 6.3 Normal Vector Calculation 6.4 Reflection and Refraction Vectors 6.4.1 Reflection Vector Calculation 6.4.2 Refraction Vector Calculation Chapter 6 Summary Exercises for Chapter 6 Chapter 7  Lighting and Shading 7.1 RGB Color 7.2 Light Sources 7.2.1 Ambient Light 7.2.2 Directional Light Sources 7.2.3 Point Light Sources 7.2.4 Spot Light Sources 7.3 Diffuse Reflection 7.4 Specular Reflection 7.5 Texture Mapping 7.5.1 Standard Texture Maps 7.5.2 Projective Texture Maps 7.5.3 Cube Texture Maps 7.5.4 Filtering and Mipmaps v  118  120  126  129  131  131  131  132  135  136  139  140  141  143  144  145  147  148  149  150  151  153  154  157  157  158  158  159  159  160  161  162  164  166  167  169  171 
vi  Contents  7.9.1 Bidirectional Reflectance Distribution Functions 7.9.2 Cook-Torrance Illumination 7.9.3 The Fresnel Factor 7.9.4 The Microfacet Distribution Function 7.9.5 The Geometrical Attenuation Factor 7.9.6 Implementation Chapter 7 Summary Exercises for Chapter 7 Chapter 8  Visibility Determination 8.1 Bounding Volume Construction 7.6 Emission 7.7 Shading Models 7.7.1 Calculating Normal Vectors 7.7.2 Gouraud Shading 7.7.3 Blinn-Phong Shading 7.8 Bump Mapping 7.8.1 Bump Map Construction 7.8.2 Tangent Space 7.8.3 Calculating Tangent Vectors 7.8.4 Implementation 7.9 A Physical Reflection Model 8.1.1 Principal Component Analysis 8.1.2 Bounding Box Construction 8.1.3 Bounding Sphere Construction 8.1.4 Bounding Ellipsoid Construction 8.1.5 Bounding Cylinder Construction 8.2 Bounding Volume Tests 8.2.1 Bounding Sphere Test 8.2.2 Bounding Ellipsoid Test 8.2.3 Bounding Cylinder Test 8.2.4 Bounding Box Test 8.3 Spatial Partitioning 8.3.1 Octrees 8.3.2 Binary Space Partitioning Trees 8.4 Portal Systems 8.4.1 Portal Clipping 8.4.2 Reduced View Frustums 174  175  175  176  177  178  178  180  180  185  187  187  191  192  195  198  200  205  209  211  211  212  215  217  218  220  221  221  222  226  228  230  230  232  235  236  238 
  Chapter 8 Summary Exercises for Chapter 8 Chapter 9  Polygonal Techniques 9.1 Depth Value Offset 9.1.1 Projection Matrix Modification 9.1.2 Offset Value Selection 9.1.3 Implementation 9.2 Decal Application 9.2.1 Decal Mesh Construction 9.2.2 Polygon Clipping 9.3 Billboarding 9.3.1 Unconstrained Quads 9.3.2 Constrained Quads 9.3.3 Polyboards 9.4 Polygon Reduction 9.5 T-Junction Elimination 9.6 Triangulation Chapter 9 Summary Exercises for Chapter 9 Chapter 10  Shadows 10.1 Shadow Casting Set 10.2 Shadow Mapping 10.2.1 Rendering the Shadow Map 10.2.2 Rendering the Main Scene 10.2.3 Self-Shadowing 10.3 Stencil Shadows 10.3.1 Algorithm Overview 10.3.2 Infinite View Frustums 10.3.3 Silhouette Determination 10.3.4 Shadow Volume Construction 10.3.5 Determining Cap Necessity 10.3.6 Rendering Shadow Volumes 10.3.7 Scissor Optimization Chapter 10 Summary Exercises for Chapter 10 vii  240  244  245  245  246  247  248  249  250  252  254  254  257  258  260  264  267  274  277  279  279  281  281  283  284  286  286  291  294  299  303  307  309  314  315 
分享到:
收藏