Morgan Kaufmann Essential Mathematics for Games and Interactive Applications 2nd, Rozmaitosci
[ Pobierz całość w formacie PDF ]
Essential Mathematics
Interactive Applications
A Programmer’s Guide
Second Edition
James M. Van Verth
Lars M. Bishop
LONDON
NEW YORK
•
OXFORD
•
PARIS
•
SAN DIEGO
SAN FRANCISCO
•
SINGAPORE
•
SYDNEY
•
TOKYO
•
BOSTON
•
HEIDELBERG
•
Morgan Kaufmann Publishers is an imprint of Elsevier
for Games and
AMSTERDAM
Acquisitions Editor
Laura Lewin
Assistant Editor
Chris Simpson
Publishing Services Manager
George Morrison
Senior Production Manager
Paul Gottehrer
Cover Designer
Joanne Blank
Composition
diacriTech
Interior printer
RR Donnelley
Cover printer
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
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
0809101112 54321
About the Authors
James M. Van Verth
is an OpenGL Software Engineer at NVIDIA, where
he works on device drivers for NVIDIA GPUs. Prior to that, he was a found-
ing member of Red Storm Entertainment, where he was a lead engineer for
eight years. For the past nine years he also has been a regular speaker at the
Game Developers Conference, teaching the all-day tutorials “Math for Game
Programmers” and “Physics for Game Programmers,” on which this book
is based. His background includes a B.A. in Math/Computer Science from
Dartmouth College, an M.S. in Computer Science from the State University
of New York at Buffalo, and an M.S. in Computer Science from the University
of North Carolina at Chapel Hill.
Lars M. Bishop
is an engineer in the Handheld Developer Technologies group
at NVIDIA. Prior to joining NVIDIA, Lars was the Chief Technology Officer
at Numerical Design Limited, leading the development of the Gamebryo3D
cross-platform game engine. He received a BS in Math/Computer Science
from Brown University and an MS in Computer Science from the University
of North Carolina at Chapel Hill. His outside interests include photography,
drumming, and playing bass guitar.
Contents
Preface
xix
Introduction
xxiii
Chapter
1
Real-World Computer Number Representation
1
1.1
Introduction 1
1.2
Representing Real Numbers 2
1.2.1
Approximations 2
1.2.2
Precision and Error 3
1.3
Floating-Point Numbers 4
1.3.1
Review: Scientific Notation 4
1.3.2
A Restricted Scientific Notation 5
1.4
Binary “Scientific Notation” 6
1.5
IEEE 754 Floating-Point Standard 9
1.5.1
Basic Representation 9
1.5.2
Range and Precision 11
1.5.3
Arithmetic Operations 13
1.5.4
Special Values 16
1.5.5
Very Small Values 19
1.5.6
Catastrophic Cancelation 22
1.5.7
Double Precision 24
1.6
Real-World Floating-Point 25
1.6.1
Internal FPU Precision 25
1.6.2
Performance 26
1.6.3
IEEE Specification Compliance 29
1.6.4
Graphics Processing Units and Half-Precision
Floating-Point Formats 31
1.7
Code 32
1.8
Chapter Summary 33
ix
x
Contents
Chapter
2
Vectors and Points
35
2.1
Introduction 35
2.2
Vectors 36
2.2.1
Geometric Vectors 36
2.2.2
Linear Combinations 39
2.2.3
Vector Representation 40
2.2.4
Basic Vector Class Implementation 42
2.2.5
Vector Length 44
2.2.6
Dot Product 47
2.2.7
Gram-Schmidt Orthogonalization 51
2.2.8
Cross Product 53
2.2.9
Triple Products 56
2.2.10
Real Vector Spaces 59
2.2.11
Basis Vectors 62
2.3
Points 63
2.3.1
Points as Geometry 64
2.3.2
Affine Spaces 66
2.3.3
Affine Combinations 68
2.3.4
Point Implementation 70
2.3.5
Polar and Spherical Coordinates 72
2.4
Lines 75
2.4.1
Definition 75
2.4.2
Parameterized Lines 76
2.4.3
Generalized Line Equation 77
2.4.4
Collinear Points 79
2.5
Planes 80
2.5.1
Parameterized Planes 80
2.5.2
Generalized Plane Equation 80
2.5.3
Coplanar Points 82
2.6
Polygons and Triangles 82
2.7
Chapter Summary 86
Chapter
3
Matrices and Linear Transformations
87
3.1
Introduction 87
3.2
Matrices 88
3.2.1
Introduction to Matrices 88
3.2.2
Simple Operations 90
3.2.3
Vector Representation 92
3.2.4
Block Matrices 92
3.2.5
Matrix Product 94
3.2.6
Identity Matrix 96
[ Pobierz całość w formacie PDF ]