您还没有登陆到CGPAD.COM   现在登录   注册新用户
搜索 CGPAD.COM
 
 
 
 浏览资源    软件下载    源文件    论文和文档    教程和指南    设计素材    三维模型    网站收藏    其他    添加资源  
 
游戏和图形学的3D数学入门教程
查看:1225  |  下载:1053  |  评论:3  |  创建:2008-05-02 13:42:48
 
 
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
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
Contents
6.3.3 Provide Only the Most Important Operations . . . . . . . . . . . . . . . 74
6.3.4 Don’t Overload Too Many Operators . . . . . . . . . . . . . . . . . . . 74
6.3.5 Use Const Member Functions . . . . . . . . . . . . . . . . . . . . . . . 75
6.3.6 Use Const & Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.3.7 Member vs. Nonmember Functions . . . . . . . . . . . . . . . . . . . . 75
6.3.8 No Default Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.3.9 Don’t Use Virtual Functions . . . . . . . . . . . . . . . . . . . . . . . . 77
6.3.10 Don’t Use Information Hiding . . . . . . . . . . . . . . . . . . . . . . 77
6.3.11 Global Zero Vector Constant . . . . . . . . . . . . . . . . . . . . . . . 78
6.3.12 No “point3” Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.3.13 A Word on Optimization . . . . . . . . . . . . . . . . . . . . . . . . . 78
Chapter 7 Introduction to Matrices . . . . . . . . . . . . . . . . 83
7.1 Matrix — A Mathematical Definition . . . . . . . . . . . . . . . . . . . . . 83
7.1.1 Matrix Dimensions and Notation . . . . . . . . . . . . . . . . . . . . . 83
7.1.2 Square Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.1.3 Vectors as Matrices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1.4 Transposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1.5 Multiplying a Matrix with a Scalar . . . . . . . . . . . . . . . . . . . . 86
7.1.6 Multiplying Two Matrices . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.1.7 Multiplying a Vector and a Matrix. . . . . . . . . . . . . . . . . . . . . 89
7.1.8 Row vs. Column Vectors. . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.2 Matrix — A Geometric Interpretation . . . . . . . . . . . . . . . . . . . . . 91
7.2.1 How Does a Matrix Transform Vectors? . . . . . . . . . . . . . . . . . 92
7.2.2 What Does a Matrix Look Like?. . . . . . . . . . . . . . . . . . . . . . 93
7.2.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.3 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Chapter 8 Matrices and Linear Transformations . . . . . . . . 101
8.1 Transforming an Object vs. Transforming the Coordinate Space . . . . . . 102
8.2 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
8.2.1 Rotation in 2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
8.2.2 3D Rotation about Cardinal Axes . . . . . . . . . . . . . . . . . . . . 106
8.2.3 3D Rotation about an Arbitrary Axis. . . . . . . . . . . . . . . . . . . 109
8.3 Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
8.3.1 Scaling along Cardinal Axes . . . . . . . . . . . . . . . . . . . . . . . 112
8.3.2 Scale in an Arbitrary Direction. . . . . . . . . . . . . . . . . . . . . . 113
8.4 Orthographic Projection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
8.4.1 Projecting onto a Cardinal Axis or Plane. . . . . . . . . . . . . . . . . 116
8.4.2 Projecting onto an Arbitrary Line or Plane. . . . . . . . . . . . . . . . 117
8.5 Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
8.6 Shearing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
8.7 Combining Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . 119
8.8 Classes of Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . 120
8.8.1 Linear Transformations. . . . . . . . . . . . . . . . . . . . . . . . . . 121
8.8.2 Affine Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . 122
v
Contents
8.8.3 Invertible Transformations . . . . . . . . . . . . . . . . . . . . . . . . 122
8.8.4 Angle-preserving Transformations . . . . . . . . . . . . . . . . . . . . 122
8.8.5 Orthogonal Transformations . . . . . . . . . . . . . . . . . . . . . . . 122
8.8.6 Rigid Body Transformations . . . . . . . . . . . . . . . . . . . . . . . 123
8.8.7 Summary of Types of Transformations . . . . . . . . . . . . . . . . . 123
8.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Chapter 9 More on Matrices . . . . . . . . . . . . . . . . . . . 125
9.1 Determinant of a Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
9.1.1 Official Linear Algebra Rules . . . . . . . . . . . . . . . . . . . . . . 125
9.1.2 Geometric Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . 129
9.2 Inverse of a Matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
9.2.1 Official Linear Algebra Rules . . . . . . . . . . . . . . . . . . . . . . 130
9.2.2 Geometric Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . 132
9.3 Orthogonal Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
9.3.1 Official Linear Algebra Rules . . . . . . . . . . . . . . . . . . . . . . 132
9.3.2 Geometric Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . 133
9.3.3 Orthogonalizing a Matrix. . . . . . . . . . . . . . . . . . . . . . . . . 134
9.4 4×4 Homogenous Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . 135
9.4.1 4D Homogenous Space . . . . . . . . . . . . . . . . . . . . . . . . . . 136
9.4.2 4×4 Translation Matrices . . . . . . . . . . . . . . . . . . . . . . . . . 137
9.4.3 General Affine Transformations . . . . . . . . . . . . . . . . . . . . . 140
9.4.4 Perspective Projection . . . . . . . . . . . . . . . . . . . . . . . . . . 141
9.4.5 A Pinhole Camera. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
9.4.6 Perspective Projection Using 4×4 Matrices . . . . . . . . . . . . . . . 145
9.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Chapter 10 Orientation and Angular Displacement in 3D . . . . 147
10.1 What is Orientation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
10.2 Matrix Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
10.2.1 Which Matrix?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
10.2.2 Advantages of Matrix Form. . . . . . . . . . . . . . . . . . . . . . . 150
10.2.3 Disadvantages of Matrix Form . . . . . . . . . . . . . . . . . . . . . 151
10.2.4 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
10.3 Euler Angles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
10.3.1 What are Euler Angles? . . . . . . . . . . . . . . . . . . . . . . . . . 153
10.3.2 Other Euler Angle Conventions. . . . . . . . . . . . . . . . . . . . . 155
10.3.3 Advantages of Euler Angles. . . . . . . . . . . . . . . . . . . . . . . 156
10.3.4 Disadvantages of Euler Angles . . . . . . . . . . . . . . . . . . . . . 156
10.3.5 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.4 Quaternions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.4.1 Quaternion Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . 160
10.4.2 Quaternions as Complex Numbers . . . . . . . . . . . . . . . . . . . 160
10.4.3 Quaternions as an Axis-Angle Pair . . . . . . . . . . . . . . . . . . . 162
10.4.4 Quaternion Negation . . . . . . . . . . . . . . . . . . . . . . . . . . 163
10.4.5 Identity Quaternion(s) . . . . . . . . . . . . . . . . . . . . . . . . . . 163
vi
Contents
10.4.6 Quaternion Magnitude. . . . . . . . . . . . . . . . . . . . . . . . . . 163
10.4.7 Quaternion Conjugate and Inverse . . . . . . . . . . . . . . . . . . . 164
10.4.8 Quaternion Multiplication (Cross Product). . . . . . . . . . . . . . . 165
10.4.9 Quaternion “Difference” . . . . . . . . . . . . . . . . . . . . . . . . 168
10.4.10 Quaternion Dot Product . . . . . . . . . . . . . . . . . . . . . . . . 169
10.4.11 Quaternion Log, Exp, and Multiplication by a Scalar. . . . . . . . . 169
10.4.12 Quaternion Exponentiation . . . . . . . . . . . . . . . . . . . . . . 171
10.4.13 Quaternion Interpolation — aka “Slerp” . . . . . . . . . . . . . . . 173
10.4.14 Quaternion Splines — aka “Squad” . . . . . . . . . . . . . . . . . . 177
10.4.15 Advantages/Disadvantages of Quaternions . . . . . . . . . . . . . . 178
10.5 Comparison of Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
10.6 Converting between Representations . . . . . . . . . . . . . . . . . . . . 180
10.6.1 Converting Euler Angles to a Matrix . . . . . . . . . . . . . . . . . . 180
10.6.2 Converting a Matrix to Euler Angles . . . . . . . . . . . . . . . . . . 182
10.6.3 Converting a Quaternion to a Matrix . . . . . . . . . . . . . . . . . . 185
10.6.4 Converting a Matrix to a Quaternion . . . . . . . . . . . . . . . . . . 187
10.6.5 Converting Euler Angles to a Quaternion . . . . . . . . . . . . . . . 190
10.6.6 Converting a Quaternion to Euler Angles . . . . . . . . . . . . . . . 191
10.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Chapter 11 Transformations in C++ . . . . . . . . . . . . . . . 195
11.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
11.2 Class EulerAngles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
11.3 Class Quaternion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
11.4 Class RotationMatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
11.5 Class Matrix4×3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Chapter 12 Geometric Primitives . . . . . . . . . . . . . . . . . 239
12.1 Representation Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . 239
12.1.1 Implicit Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
12.1.2 Parametric Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
12.1.3 “Straightforward” Forms . . . . . . . . . . . . . . . . . . . . . . . . 240
12.1.4 Degrees of Freedom . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
12.2 Lines and Rays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
12.2.1 Two Points Representation . . . . . . . . . . . . . . . . . . . . . . . 242
12.2.2 Parametric Representation of Rays . . . . . . . . . . . . . . . . . . . 242
12.2.3 Special 2D Representations of Lines . . . . . . . . . . . . . . . . . . 243
12.2.4 Converting between Representations . . . . . . . . . . . . . . . . . . 245
12.3 Spheres and Circles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
12.4 Bounding Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
12.4.1 Representing AABBs . . . . . . . . . . . . . . . . . . . . . . . . . . 248
12.4.2 Computing AABBs . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
12.4.3 AABBs vs. Bounding Spheres . . . . . . . . . . . . . . . . . . . . . 250
12.4.4 Transforming AABBs . . . . . . . . . . . . . . . . . . . . . . . . . . 251
12.5 Planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
12.5.1 Implicit Definition — The Plane Equation . . . . . . . . . . . . . . . 252
vii
Contents
12.5.2 Definition Using Three Points . . . . . . . . . . . . . . . . . . . . . 253
12.5.3 “Best-fit” Plane for More Than Three Points. . . . . . . . . . . . . . 254
12.5.4 Distance from Point to Plane . . . . . . . . . . . . . . . . . . . . . . 256
12.6 Triangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
12.6.1 Basic Properties of a Triangle. . . . . . . . . . . . . . . . . . . . . . 257
12.6.2 Area of a Triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
12.6.3 Barycentric Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
12.6.4 Special Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
12.7 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
12.7.1 Simple vs. Complex Polygons . . . . . . . . . . . . . . . . . . . . . 269
12.7.2 Self-intersecting Polygons . . . . . . . . . . . . . . . . . . . . . . . 270
12.7.3 Convex vs. Concave Polygons . . . . . . . . . . . . . . . . . . . . . 271
12.7.4 Triangulation and Fanning . . . . . . . . . . . . . . . . . . . . . . . 274
12.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Chapter 13 Geometric Tests . . . . . . . . . . . . . . . . . . . . 277
13.1 Closest Point on 2D Implicit Line . . . . . . . . . . . . . . . . . . . . . . 277
13.2 Closest Point on Parametric Ray . . . . . . . . . . . . . . . . . . . . . . . 278
13.3 Closest Point on Plane . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
13.4 Closest Point on Circle/Sphere. . . . . . . . . . . . . . . . . . . . . . . . 280
13.5 Closest Point in AABB. . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
13.6 Intersection Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
13.7 Intersection of Two Implicit Lines in 2D . . . . . . . . . . . . . . . . . . 282
13.8 Intersection of Two Rays in 3D . . . . . . . . . . . . . . . . . . . . . . . 283
13.9 Intersection of Ray and Plane . . . . . . . . . . . . . . . . . . . . . . . . 284
13.10 Intersection of AABB and Plane . . . . . . . . . . . . . . . . . . . . . . 285
13.11 Intersection of Three Planes . . . . . . . . . . . . . . . . . . . . . . . . 286
13.12 Intersection of Ray and Circle/Sphere . . . . . . . . . . . . . . . . . . . 286
13.13 Intersection of Two Circles/Spheres . . . . . . . . . . . . . . . . . . . . 288
13.14 Intersection of Sphere and AABB . . . . . . . . . . . . . . . . . . . . . 291
13.15 Intersection of Sphere and Plane . . . . . . . . . . . . . . . . . . . . . . 291
13.16 Intersection of Ray and Triangle . . . . . . . . . . . . . . . . . . . . . . 293
13.17 Intersection of Ray and AABB . . . . . . . . . . . . . . . . . . . . . . . 297
13.18 Intersection of Two AABBs . . . . . . . . . . . . . . . . . . . . . . . . 297
13.19 Other Tests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
13.20 Class AABB3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
13.21 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Chapter 14 Triangle Meshes. . . . . . . . . . . . . . . . . . . . 319
14.1 Representing Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
14.1.1 Indexed Triangle Mesh . . . . . . . . . . . . . . . . . . . . . . . . . 320
14.1.2 Advanced Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . 322
14.1.3 Specialized Representations for Rendering. . . . . . . . . . . . . . . 322
14.1.4 Vertex Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
14.1.5 Triangle Strips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
14.1.6 Triangle Fans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
viii
Contents
14.2 Additional Mesh Information . . . . . . . . . . . . . . . . . . . . . . . . 328
14.2.1 Texture Mapping Coordinates. . . . . . . . . . . . . . . . . . . . . . 328
14.2.2 Surface Normals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
14.2.3 Lighting Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
14.3 Topology and Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . 330
14.4 Triangle Mesh Operations . . . . . . . . . . . . . . . . . . . . . . . . . . 331
14.4.1 Piecewise Operations . . . . . . . . . . . . . . . . . . . . . . . . . . 331
14.4.2 Welding Vertices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
14.4.3 Detaching Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
14.4.4 Edge Collapse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
14.4.5 Mesh Decimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
14.5 A C++ Triangle Mesh Class . . . . . . . . . . . . . . . . . . . . . . . . . 336
Chapter 15 3D Math for Graphics . . . . . . . . . . . . . . . . . 345
15.1 Graphics Pipeline Overview . . . . . . . . . . . . . . . . . . . . . . . . . 346
15.2 Setting the View Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 349
15.2.1 Specifying the Output Window . . . . . . . . . . . . . . . . . . . . . 349
15.2.2 Pixel Aspect Ratio. . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
15.2.3 The View Frustum. . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
15.2.4 Field of View and Zoom. . . . . . . . . . . . . . . . . . . . . . . . . 351
15.3 Coordinate Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
15.3.1 Modeling and World Space . . . . . . . . . . . . . . . . . . . . . . . 354
15.3.2 Camera Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
15.3.3 Clip Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
15.3.4 Screen Space. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
15.4 Lighting and Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
15.4.1 Math on Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
15.4.2 Light Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
15.4.3 The Standard Lighting Equation — Overview . . . . . . . . . . . . . 361
15.4.4 The Specular Component . . . . . . . . . . . . . . . . . . . . . . . . 362
15.4.5 The Diffuse Component. . . . . . . . . . . . . . . . . . . . . . . . . 365
15.4.6 The Ambient Component . . . . . . . . . . . . . . . . . . . . . . . . 366
15.4.7 Light Attenuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
15.4.8 The Lighting Equation — Putting It All Together . . . . . . . . . . . 367
15.4.9 Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
15.4.10 Flat Shading and Gouraud Shading . . . . . . . . . . . . . . . . . . 370
15.5 Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
15.6 Texture Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
15.7 Geometry Generation/Delivery . . . . . . . . . . . . . . . . . . . . . . . 374
15.7.1 LOD Selection and Procedural Modeling. . . . . . . . . . . . . . . . 375
15.7.2 Delivery of Geometry to the API . . . . . . . . . . . . . . . . . . . . 375
15.8 Transformation and Lighting. . . . . . . . . . . . . . . . . . . . . . . . . 377
15.8.1 Transformation to Clip Space . . . . . . . . . . . . . . . . . . . . . . 378
15.8.2 Vertex Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
15.9 Backface Culling and Clipping. . . . . . . . . . . . . . . . . . . . . . . . 380
ix
Contents
15.9.1 Backface Culling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
15.9.2 Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
15.10 Rasterization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Chapter 16 Visibility Determination. . . . . . . . . . . . . . . . 385
16.1 Bounding Volume Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
16.1.1 Testing Against the View Frustum . . . . . . . . . . . . . . . . . . . 387
16.1.2 Testing for Occlusion . . . . . . . . . . . . . . . . . . . . . . . . . . 390
16.2 Space Partitioning Techniques . . . . . . . . . . . . . . . . . . . . . . . . 390
16.3 Grid Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
16.4 Quadtrees and Octrees . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
16.5 BSP Trees. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
16.5.1 “Old School” BSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
16.5.2 Arbitrary Dividing Planes . . . . . . . . . . . . . . . . . . . . . . . . 401
16.6 Occlusion Culling Techniques . . . . . . . . . . . . . . . . . . . . . . . . 402
16.6.1 Potentially Visible Sets . . . . . . . . . . . . . . . . . . . . . . . . . 402
16.6.2 Portal Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Chapter 17 Afterword . . . . . . . . . . . . . . . . . . . . . . . 407
Appendix A Math Review. . . . . . . . . . . . . . . . . . . . . . 409
Summation Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Angles, Degrees, and Radians . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Trig Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Trig Identities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Appendix B References. . . . . . . . . . . . . . . . . . . . . . . 415
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Contents
 
 
 下载次数 文件大小 56K下载 512K下载 1M下载
 1053次 22.14 MB 小于7分钟 小于45秒 小于23秒
所有资源只对本网注册用户开放。
 
登陆到CGPAD.COM
登陆ID: 
密码: 
验证码: 
  
     
 
注册新用户 | 找回密码
 
最近下载
lyh (新好男人) @ 2009-01-07 12:16:21
wwyycc110 (午夜茶) @ 2009-01-06 22:39:32
wwyycc110 (午夜茶) @ 2009-01-06 22:39:26
wwwz2m (wwwz2m) @ 2009-01-05 13:15:32
wqazwqaz (fdvfvdgg) @ 2009-01-03 17:20:27
wqazwqaz (fdvfvdgg) @ 2009-01-03 17:20:25
079090639 (华佗) @ 2008-11-30 09:28:07
kevgao (kevgao) @ 2008-11-29 11:08:15
kevgao (kevgao) @ 2008-11-29 11:08:14
kevgao (kevgao) @ 2008-11-29 09:26:50
 
栏目搜索
 
工具软件
  Win Rar 3.70 [官方下载]
  Adobe PDF Reader [官方下载]
热门下载
最新上传
  灶具
  钢琴
 
对本文的评论  <<上一页 1 下一页>>   

 SPAN (江南石斑)
 注册: 2008-04-24
 积分: 10115 分
 等级:
 尘世如潮人如水 只叹江湖几人回

 
2008-10-02 16:36:01





 

 68557188 (平湖秋叶)
 注册: 2008-11-25
 积分: 0 分
 等级: 等级修炼中
 您的签名信息

 
2008-11-25 21:11:08

正需要

 





 

 kflizcst (kflizcst)
 注册: 2008-12-04
 积分: 0 分
 等级: 等级修炼中
 kflizcst

 
2008-12-05 00:10:14

哈哈,不错~~~



 
 <<上一页 1 下一页>>   
 
 
版权所有 © 2005-2008 CGPAD.COM,湘ICP备07500998号,兼容浏览器:IE6IE7FireFoxOperaSafariChrome
Total Requests: 597302, Total Visits: 225002, Processing Time: 218ms,