logo资料库

Essential Mathematics for Games and Interactive Applications 2nd Edition.pdf

第1页 / 共705页
第2页 / 共705页
第3页 / 共705页
第4页 / 共705页
第5页 / 共705页
第6页 / 共705页
第7页 / 共705页
第8页 / 共705页
资料共705页,剩余部分请下载后查看
Title
Contents
Preface
Introduction
1 Real-World Computer Number Representation
1.1 Introduction
1.2 Representing Real Numbers
1.2.1 Approximations
1.2.2 Precision and Error
1.3 Floating-Point Numbers
1.3.1 Review: Scientific Notation
1.3.2 Restricted Scientific Notation
1.4 Binary "Scientific Notation"
1.5 IEEE 754 Floating-Point Standard
1.5.1 Basic Representation
1.5.2 Range and Precision
1.5.3 Arithemtic Operations
1.5.4 Special Values
1.5.5 Very Small Values
1.5.6 Catastrophic Cancelation
1.5.7 Double Precision
1.6 Real-World Floating-Point
1.6.1 Internal FPU Precision
1.6.2 Performance
1.6.3 IEEE Specification Compliance
1.6.4 Graphics Processing Units and Half-Precision Floating-Point Formats
1.7 Code
1.8 Chapter Summary
2 Vectors and Points
2.1 Introduction
2.2 Vectors
2.2.1 Geometric Vectors
2.2.2 Linear Combinations
2.2.3 Vector Representation
2.2.4 Basic Vector Class Implementation
2.2.5 Vector Length
2.2.6 Dot Product
2.2.7 Gram-Schmidt Orthogonalization
2.2.8 Cross Product
2.2.9 Triple Products
2.2.10 Real Vector Spaces
2.2.11 Basis Vectors
2.3 Points
2.3.1 Points as Geometry
2.3.2 Affine Spaces
2.3.3 Affine Combinations
2.3.4 Point Implementation
2.3.5 Polar and Spherical Coordinates
2.4 Lines
2.4.1 Definition
2.4.2 Parameterized Lines
2.4.3 Generalized Line Equation
2.4.4 Collinear Points
2.5 Planes
2.5.1 Parameterized Planes
2.5.2 Generalized Plane Equation
2.5.3 Coplanar Points
2.6 Polygons and Triangles
2.7 Chapter Summary
3 Matrices and Linear Transformations
3.1 Introduction
3.2 Matrices
3.2.1 Introduction to Matrices
3.2.2 Simple Operations
3.2.3 Vector Representation
3.2.4 Block Matrices
3.2.5 Matrix Product
3.2.6 Identity Matrix
3.2.7 Performing Vector Operations with Matrices
3.2.8 Implementation
3.3 Linear Transformation
3.3.1 Definition
3.3.2 Null Space and Range
3.3.3 Linear Transformation and Basis Vectors
3.3.4 Matrices and Linear Transformations
3.3.5 Combination Linear Transformations
3.4 Systems of Linear Equations
3.4.1 System of Linear Equations
3.4.2 Solving Linear Systems
3.4.3 Gaussian Elimination
3.5 Matrix Inverse
3.5.1 Definition
3.5.2 Simple Inverses
3.6 Determinant
3.6.1 Definition
3.6.2 Computing the Determinant
3.6.3 Determinants and Elementary Row Operations
3.6.4 Adjoint Matrix and Inverse
3.7 Eigenvalues and Eigenvectors
3.8 Chapter Summary
4 Affine Transformations
4.1 Introduction
4.2 Affine Transformation
4.2.1 Matrix Definition
4.2.2 Formal Definition
4.2.3 Formal Representation
4.3 Standard Affine Transformation
4.3.1 Translation
4.3.2 Rotation
4.3.3 Scaling
4.3.4 Reflection
4.3.5 Shear
4.3.6 Applying an Affine Transformation around an Arbitray Point
4.3.7 Transformation Plane Normals
4.4 Using Affine Transformations
4.4.1 Manipulation of Game Objects
4.4.2 Matrix Decomposition
4.4.3 Avoiding Matrix Decomposition
4.5 Object Hierarchies
4.6 Chapter Summary
5 Orientation Representation
5.1 Introduction
5.2 Roation Matrices
5.3 Fixed and Euler Angles
5.3.1 Definition
5.3.2 Format Conversion
5.3.3 Concatenation
5.3.4 Vector Rotation
5.3.5 Other Issues
5.4 Axis-Angle Representation
5.4.1 Definition
5.4.2 Format Conversion
5.4.3 Concatenation
5.4.4 Vector Rotation
5.4.5 Axis-Angle Summary
5.5 Quaternions
5.5.1 Definition
5.5.2 Quaternions as Rotations
5.5.3 Addition and Scalar Multiplication
5.5.4 Negation
5.5.5 Magnitude and Normalization
5.5.6 Dot Producti
5.5.7 Format Conversion
5.5.8 Concatenation
5.5.9 Identity and Inverse
5.5.10 Vector Rotation
5.5.11 Shortest Path of Rotation
5.5.12 Quaternions and Transformations
5.6 Chapter Summary
6 Viewing and Projection
6.1 Introduction
6.2 View Frame and View Transformation
6.2.1 Definition a Virtual Camera
6.2.2 Constructing the View-to-World Transformation
6.2.3 Controlling the Camera
6.2.4 Constructing the World-to-View Transformation
6.3 Projective Transformation
6.3.1 Definition
6.3.2 Normalized Device Coordinates
6.3.3 View Frustum
6.3.4 Homogeneous Coordinates
6.3.5 Perspective Projection
6.3.6 Oblique Perspective
6.3.7 Orthographic Parallel Projection
6.3.8 Oblique Parallel Projection
6.4 Culling and Clipping
6.4.1 Why Cull Or Clip?
6.4.2 Culling
6.4.3 General Plane Clipping
6.4.4 Homogeneous Clipping
6.5 Screen Transformation
6.5.1 Pixel Aspect Ratio
6.6 Picking
6.7 Management of Viewing Transformations
6.8 Chpater Summary
7 Geometry and Programmable Shading
7.1 Introduction
7.2 Color Representation
7.2.1 RGB Color Model
7.2.2 Colors as "Vectors"
7.2.3 Color Range Limitation
7.2.4 Operations on Colors
7.2.5 Alpha Values
7.2.6 Color Storage Formats
7.3 Points and Vertices
7.3.1 Per-Vertex Attributes
7.3.2 An Object's Vertices
7.4 Surface Representation
7.4.1 Vertices and Surface Ambiguity
7.4.2 Triangles
7.4.3 Connecting Vertices into Triangles
7.4.4 Drawing Geometry
7.5 Rendering Pipeline
7.5.1 Fixed-Function versus Programmable Pipelines
7.6 Shaders
7.6.1 Using Shaders to Move from Vertex to Triangle to Fragment
7.6.2 Shader Input and Output Values
7.6.3 Shader Operations and Language Constructors
7.7 Vertex Shaders
7.7.1 Vertex Shader Inputs
7.7.2 Vertex Shader Outputs
7.7.3 Basic Vertex Shaders
7.7.4 Linking Vertex and Fragment Shaders
7.8 Fragment Shaders
7.8.1 Fragment Shader Inputs
7.8.2 Fragment Shader Outputs
7.8.3 Compiling, Linking, and Using Shaders
7.8.4 Setting Uniform Values
7.9 Basic Coloring Methods
7.9.1 Per-Object Colors
7.9.2 Per-Vertex Colors
7.9.3 Per-Triangle Colors
7.9.4 Sharp Edges and Vertex Colors
7.9.5 More About Basic Shading
7.9.6 Limitation of Basic Shading Methods
7.10 Texture Mapping
7.10.1 Introduction
7.10.2 Shading via Image Lookup
7.10.3 Texture Images
7.10.4 Texture Samplers
7.11 Texture Coordinates
7.11 Mapping Texture Coordinates onto Objects
7.11.2 Generating Texture Coordinates
7.11.3 Texture Coordinate Discontinuities
7.11.4 Mapping Outside the Unit Square
7.11.5 Texture Samplers in Shader Code
7.12 The Steps of Texturing
7.12.1 Other Forms of Texture Coordinates
7.12.2 From Texture Coordinates to a Texture Sample Color
7.13 Limitations of Static Shading
7.14 Chapter Summary
8 Lighting
8.1 Introduction
8.2 Basics of Light Approximation
8.2.1 Measuring Light
8.2.2 Light as a Ray
8.3 A Simple Approximation of Lighting
8.4 Types of Light Sources
8.4.1 Directional Lights
8.4.2 Point Lights
8.4.3 Spotlights
8.4.4 Other Types of Light Sources
8.5 Surface Materials and Light Interaction
8.6 Categories of Light
8.6.1 Emission
8.6.2 Ambient
8.6.3 Diffuse
8.6.4 Specular
8.7 Combing Lighting Equation
8.8 Lighting and Shading
8.8.1 Flat-Shaded Lighting
8.8.2 Per-Vertex Lighting
8.8.3 Per-Fragment Lighting
8.9 Textures and Lighting
8.9.1 Basic Modulation
8.9.2 Specular Lighting and Textures
8.9.3 Textures as Materials
8.10 Advanced Lighting
8.10.1 Normal Mapping
8.11 Reflective Objects
8.12 Shadows
8.13 Chapter Summary
9 Rasterization
9.1 Introduction
9.2 Displays and Framebuffers
9.3 Conceptual Rasterization Pipeline
9.3.1 Rasterization Stages
9.4 Determining the Fragments: Pixels Covered by a Triangle
9.4.1 Fragments
9.4.2 Depth Complexity
9.4.3 Converting Triangles to Fragments
9.4.4 Handling Partial Fragments
9.5 Determining Visible Geometry
9.5.1 Depth Buffering
9.5.2 Depth Buffering in Practice
9.6 Computing Fragment Shading Inputs
9.6.1 Uniform Values
9.6.2 Per-Vertex Attributes
9.6.3 Interpolating Texture Coordinates
9.6.4 Other Sources of Texture Coordinates
9.7 Evaluating The Fragment Shaders
9.8 Rasterizing Textures
9.8.1 Texture Coordinate Review
9.8.2 Mapping a Coordinate to a Texel
9.8.3 Mipmapping
9.9 From Fragments to Pixels
9.9.1 Pixel Blending
9.9.2 Antialiasing
9.9.3 Antialiasing in Practice
9.10 Chapter Summary
10 Interpolation
10.1 Introduction
10.2 Interpolation of Position
10.2.1 General Defintions
10.2.2 Linear Interpolation
10.2.3 Hermite Curves
10.2.4 Catmull-Rom Splines
10.2.5 Kochanek-Bartels Splines
10.2.6 Bezier Curves
10.2.7 Other Curve Types
10.3 Interpolation of Orientation
10.3.1 General Discussion
10.3.2 Linear Interpolation
10.3.3 Spherical Linear Interpolation
10.3.4 Performance Improvements
10.4 Sampling Curves
10.4.1 Forward Differencing
10.4.2 Midpoint Subdivision
10.4.3 Computing Arc Length
10.5 Controlling Speed along a Curve
10.5.1 Moving at Constant Speed
10.5.2 Moving at Variable Speed
10.6 Camera Control
10.7 Chapter Summary
11 Random Numbers
11.1 Introduction
11.2 Probability
11.2.1 Basic Probability
11.2.2 Random Variables
11.2.3 Mean and Standard Deviation
11.2.4 Special Probability Distributions
11.3 Determining Randomness
11.3.1 Chi-Square Test
11.3.2 Spectral Test
11.4 Random Number Generators
11.4.1 Linear Congruential Methods
11.4.2 Lagged Fibonacci Methods
11.4.3 Carry Methods
11.4.4 Mersenne Twister
11.4.5 Conclusions
11.5 Special Apllications
11.5.1 Integer and Range Integers
11.5.2 Floating-Point Nubmers
11.5.3 Nonuniform Distributions
11.5.4 Spherical Sampling
11.5.5 Disc Sampling
11.5.6 Noise and Turbulence
11.6 Chapter Summary
12 Intersection Testing
12.1 Introduction
12.2 Closest Point and Distance Tests
12.2.1 Closest Point on Line to Point
12.2.2 Line-Point Distance
12.2.3 Closest Point on Line Segment to Point
12.2.4 Line Segment-Point Distance
12.2.5 Closest Points Between Two Lines
12.2.6 Line-Line Distance
12.2.7 Closest Points Between Two Line Segments
12.2.8 Line Segment-Line Segment Distance
12.29 General Linear Components
12.3 Object Intersection
12.3.1 Shperes
12.3.2 Axis-Aligned Bounding Boxes
12.3.3 Swept Shperes
12.3.4 Object-Oriented Boxes
12.3.5 Triangles
12.4 A Simple Collision System
12.4.1 Choosing a Base Primitive
12.4.2 Bouding Hierarchies
12.4.3 Dynamic Objects
12.4.4 Performance Improvements
12.4.5 Related Systems
12.4.6 Section Summary
12.5 Chapter Summary
13 Rigid Body Dynamics
13.1 Introduction
13.2 Linear Dynamics
13.2.1 Moving with Constant Acceleration
13.2.2 Forces
13.2.3 Linear Momentum
13.2.4 Moving with Variable Acceleration
13.3 Numerical Integration
13.3.1 Definition
13.3.2 Euler's Method
13.3.3 Runge-Kutta Methods
13.3.4 Verlet Integration
13.3.5 Implicit Methods
13.3.6 Semi-Implicit Methods
13.4 Rotational Dynamics
13.4.1 Definition
13.4.2 Orientation and Angular Velocity
13.4.3 Torque
13.4.4 Angular Momentum and Interia Tensor
13.4.5 Integrating Rotational Quantities
13.5 Collision Response
13.5.1 Contact Generation
13.5.2 Linear Collision Response
13.5.3 Rotational Collision Response
13.5.4 Extending the System
13.6 Efficency
13.7 Chapter Summary
Bibliography
Index
Trademarks
About the CD-ROM
This excellent volume is unique in that it covers not only the basic techniques of computer graphics and game development, but also provides a thorough and rigorous—yet very readable— treatment of the underlying mathematics. Fledgling graphics and games developers will find it a valuable introduction; experienced developers will find it an invaluable reference. Everything is here, from the detailed numeric issues of IEEE floating point notation, to the correct way to use quaternions and spherical linear interpolation to represent orientation, to the mathematics of collision detection and rigid-body dynamics. —David Luebke, University of Virginia, co-author of Level of Detail for 3D Graphics When it comes to software development for games or virtual reality, you cannot escape the math- ematics. The best performance comes not from superfast processors and terabytes of memory, but from well-chosen algorithms. With this in mind, the techniques most useful for developing production-quality computer graphics for Hollywood blockbusters are not the best choice for interactive applications. When rendering times are measured in milliseconds rather than hours, you need an entirely different perspective. Essential Mathematics for Games and Interactive Applications provides this perspective. While the mathematics are rigorous and perhaps challenging at times, Van Verth and Bishop provide the context for understanding the algorithms and data structures needed to bring games and VR applications to life. This may not be the only book you will ever need for games and VR software development, but it will certainly provide an excellent framework for developing robust and fast applications. —Ian Ashdown, President, ByHeart Consultants Limited With Essential Mathematics for Games and Interactive Applications, Van Verth and Bishop have provided invaluable assistance for professional game developers looking to shore up weaknesses in their mathematical training. Even if you never intend to write a renderer or tune a physics engine, this book provides the mathematical and conceptual grounding needed to understand many of the key concepts in rendering, simulation, and animation. —Dave Weinstein, Microsoft, Red Storm Entertainment Geometry, trigonometry, linear algebra, and calculus are all essential tools for 3D graphics. Math- ematics courses in these subjects cover too much ground, while at the same time glossing over the bread-and-butter essentials for 3D graphics programmers. In Essential Mathematics for Games and Interactive Applications, Van Verth and Bishop bring just the right level of mathematics out of the trenches of professional game development. This book provides an accessible and solid mathematical foundation for interactive graphics programmers. If you are working in the area of 3D games, this book is a “must have.” —Jonathan Cohen, Department of Computer Science, Johns Hopkins University, co-author of Level of Detail for 3D Graphics It’s the book with all the math you need for games. —Neil Kirby, Bell Labs As games become ever more sophisticated, mathematics and technical programming skills become increasingly important to have in your toolbox. Essential Math provides a solid foun- dation in many critical areas. You will find many topics covered in detail: from linear algebra to calculus, from physics to rasterization. Some of this will be review material, but you will undoubtedly learn something new and, most importantly, something useful. —Erin Catto, Blizzard Entertainment
This page intentionally left blank
Essential Mathematics Interactive Applications for Games and A Programmer’s Guide Second Edition
This page intentionally left blank
Essential Mathematics Interactive Applications for Games and A Programmer’s Guide Second Edition James M. Van Verth Lars M. Bishop AMSTERDAM • BOSTON • HEIDELBERG • LONDON SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO NEW YORK • OXFORD • PARIS • SAN DIEGO Morgan Kaufmann Publishers is an imprint of Elsevier
Laura Lewin Chris Simpson Acquisitions Editor Assistant Editor Publishing Services Manager George Morrison Senior Production Manager Cover Designer Composition Interior printer Cover printer Paul Gottehrer Joanne Blank diacriTech RR Donnelley Phoenix Color Morgan Kaufmann Publishers is an imprint of Elsevier. 30 Corporate Drive, Suite 400, Burlington, MA 01803, USA This book is printed on acid-free paper. ∞ Copyright © 2008 by Elsevier Inc. All rights reserved. Designations used by companies to distinguish their products are often claimed as trademarks or registered trademarks. In all instances in which Morgan Kaufmann Publishers is aware of a claim, the product names appear in initial capital or all capital letters. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means—electronic, mechanical, photocopying, scanning, or otherwise—without prior written permission of the publisher. Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, E-mail: permissions@elsevier.com. You may also complete your request online via the Elsevier homepage (http://elsevier.com), by selecting “Support & Contact” then “Copyright and Permission” and then “Obtaining Permissions.” Library of Congress Cataloging-in-Publication Data APPLICATIONS SUBMITTED ISBN: 978-0-12-374297-1 ISBN: 978-0-12-374298-8 (CD-ROM) For information on all Morgan Kaufmann publications, visit our Web site at www.mkp.com or www.books.elsevier.com Printed in The United States of America 08 09 10 11 12 5 4 3 2 1
Dedications To Mur and Fiona, for allowing me to slay the monster one more time. —Jim To Jen, who constantly helps me get everything done; and to Nadia and Tasha, who constantly help me avoid getting any of it done on time. —Lars
分享到:
收藏