3D Math Primer for Graphics and Game Development.pdf

(22680 KB) Pobierz
243426692 UNPDF
243426692.001.png
Graphics and Game
Development
Fletcher Dunn
and Ian Parberry
Wordware Publishing, Inc.
3D Math Primer for
243426692.002.png
Library of Congress Cataloging-in-Publication Data
Dunn, Fletcher.
3D math primer for graphics and game development / by Fletcher Dunn and Ian Parberry.
p. cm.
ISBN 1-55622-911-9
1. Computer graphics. 2. Computer games--Programming. 3. Computer science--Mathematics.
I. Parberry, Ian. II. Title.
T385 .D875 2002
006.6--dc21
2002004615
CIP
© 2002, Wordware Publishing, Inc.
All Rights Reserved
2320 Los Rios Boulevard
Plano, Texas 75074
No part of this book may be reproduced in any form or by
any means without permission in writing from
Wordware Publishing, Inc.
Printed in the United States of America
ISBN 1-55622-911-9
10987654321
0205
Product names mentioned are used for identification purposes only and may be trademarks of their respective companies.
All inquiries for volume purchases of this book should be addressed to Wordware Publishing, Inc., at the above
address. Telephone inquiries may be made by calling:
(972) 423-0090
Contents
Acknowledgments ...................................xi
Chapter 1 Introduction .......................1
1.1 What is 3D Math? ................................1
1.2 Why You Should Read This Book ........................1
1.3 What You Should Know Before Reading This Book ..............3
1.4 Overview .....................................3
Chapter 2 The Cartesian Coordinate System ............5
2.1 1D Mathematics .................................6
2.2 2D Cartesian Mathematics ............................9
2.2.1 An Example: The Hypothetical City of Cartesia ..............9
2.2.2 Arbitrary 2D Coordinate Spaces ......................10
2.2.3 Specifying Locations in 2D Using Cartesian Coordinates ........13
2.3 From 2D to 3D .................................14
2.3.1 Extra Dimension, Extra Axis .......................15
2.3.2 Specifying Locations in 3D ........................15
2.3.3 Left-handed vs. Right-handed Coordinate Spaces ............16
2.3.4 Some Important Conventions Used in This Book .............19
2.4 Exercises.....................................20
Chapter 3 Multiple Coordinate Spaces ..............23
3.1 Why Multiple Coordinate Spaces? .......................24
3.2 Some Useful Coordinate Spaces ........................25
3.2.1 World Space ................................25
3.2.2 Object Space ................................26
3.2.3 Camera Space ...............................27
3.2.4 Inertial Space ................................28
3.3 Nested Coordinate Spaces............................30
3.4 Specifying Coordinate Spaces .........................31
3.5 Coordinate Space Transformations .......................31
3.6 Exercises.....................................34
Chapter 4 Vectors .........................35
4.1 Vector — A Mathematical Definition .....................36
4.1.1 Vectors vs. Scalars .............................36
4.1.2 Vector Dimension .............................36
4.1.3 Notation ..................................36
4.2 Vector — A Geometric Definition .......................37
iii
Contents
4.2.1 What Does a Vector Look Like? ......................37
4.2.2 Position vs. Displacement .........................38
4.2.3 Specifying Vectors .............................38
4.2.4 Vectors as a Sequence of Displacements .................39
4.3 Vectors vs. Points ................................40
4.3.1 Relative Position ..............................41
4.3.2 The Relationship Between Points and Vectors ..............41
4.4 Exercises.....................................42
Chapter 5 Operations on Vectors .................45
5.1 Linear Algebra vs. What We Need .......................46
5.2 Typeface Conventions ..............................46
5.3 The Zero Vector .................................47
5.4 Negating a Vector ................................48
5.4.1 Official Linear Algebra Rules .......................48
5.4.2 Geometric Interpretation ..........................48
5.5 Vector Magnitude (Length) ...........................49
5.5.1 Official Linear Algebra Rules .......................49
5.5.2 Geometric Interpretation ..........................50
5.6 Vector Multiplication by a Scalar ........................51
5.6.1 Official Linear Algebra Rules .......................51
5.6.2 Geometric Interpretation ..........................52
5.7 Normalized Vectors ...............................53
5.7.1 Official Linear Algebra Rules .......................53
5.7.2 Geometric Interpretation ..........................53
5.8 Vector Addition and Subtraction ........................54
5.8.1 Official Linear Algebra Rules .......................54
5.8.2 Geometric Interpretation ..........................55
5.8.3 Vector from One Point to Another .....................57
5.9 The Distance Formula ..............................57
5.10 Vector Dot Product ...............................58
5.10.1 Official Linear Algebra Rules ......................58
5.10.2 Geometric Interpretation .........................59
5.10.3 Projecting One Vector onto Another ...................61
5.11 Vector Cross Product..............................62
5.11.1 Official Linear Algebra Rules ......................62
5.11.2 Geometric Interpretation .........................62
5.12 Linear Algebra Identities ...........................65
5.13 Exercises ....................................67
Chapter 6 A Simple 3D Vector Class ................69
6.1 Class Interface ..................................69
6.2 Class Vector3 Definition ............................70
6.3 Design Decisions ................................73
6.3.1 Floats vs. Doubles .............................73
6.3.2 Operator Overloading ...........................73
iv
Zgłoś jeśli naruszono regulamin