用费曼技巧学3D开发中的计算机图形学数学-基础概念

A. 三角学 (Trigonometry)

  • 简单解释 (Simple Explanation): 三角学就是研究三角形边和角关系的学问。它能帮助我们计算距离、角度,在图形学里,可以用来计算旋转、投影等 (Trigonometry is the study of the relationship between the sides and angles of a triangle. It can help us calculate distances, angles, and in graphics, it can be used to calculate rotation, projection, etc.)。
  • 案例 (Example): 想象你要在游戏中创建一个炮弹发射的轨迹。三角函数(比如正弦、余弦)可以帮助你计算出炮弹的初始发射角度和速度,才能准确击中目标 (Imagine you want to create a projectile trajectory in a game. Trigonometric functions (such as sine and cosine) can help you calculate the initial launch angle and velocity of the projectile so that it accurately hits the target)。

B. 二维和三维向量 (2D and 3D Vectors)

  • 简单解释 (Simple Explanation): 向量就是有大小和方向的箭头。在游戏中,它可以表示位置、速度、力等等 (A vector is an arrow with magnitude and direction. In the game, it can represent position, velocity, force, etc.)。
  • 向量表示法 (Vector Notation): 就像地图上的坐标,用数字告诉你在哪里,往哪个方向走 (Like the coordinates on a map, use numbers to tell you where you are and which direction to go)。
  • 单位向量 (Unit Vectors): 长度为 1 的向量。就像标准尺,方便比较和计算方向 (A vector with a length of 1. Like a standard ruler, it is convenient to compare and calculate the direction)。
  • 点积 (Dot Product): 计算两个向量有多“相似”,数值越大,方向越接近。可以用来判断两个物体是否朝向彼此 (Calculate how “similar” two vectors are. The larger the value, the closer the directions. It can be used to determine whether two objects are facing each other)。
  • 叉积 (Cross Product): 计算两个向量“垂直”的程度,结果是一个新的向量,方向垂直于原来的两个向量。可以用来计算法线,判断物体的朝向 (Calculate the degree to which two vectors are “perpendicular”. The result is a new vector whose direction is perpendicular to the original two vectors. It can be used to calculate the normal and determine the orientation of the object)。
  • 案例 (Example): 游戏中角色的移动方向和速度可以用向量表示。点积可以判断角色是否面向敌人,叉积可以计算出角色表面的法线方向,用于光照计算 (The direction and speed of the character’s movement in the game can be represented by vectors. The dot product can determine whether the character is facing the enemy, and the cross product can calculate the normal direction of the character’s surface for lighting calculation)。

C. 线性代数复习 (Review of Linear Algebra)

  • 简单解释 (Simple Explanation): 线性代数就是用矩阵和向量来解决线性方程组的问题。在图形学里,它可以用来表示和组合各种变换 (Linear algebra is about using matrices and vectors to solve linear equations. In graphics, it can be used to represent and combine various transformations)。
  • 变换 (Transformation): 改变物体的位置、方向、大小 (Change the position, orientation, and size of an object)。
  • 线性变换 (Linear Transformation): 保持直线和平行线的变换,包括旋转、缩放、错切 (Transformations that preserve straight lines and parallel lines, including rotation, scaling, and shearing)。
    • 平移 (translation): 物体沿着某个方向移动一段距离 (Moving an object a certain distance along a certain direction)。
    • 旋转 (rotation): 物体绕着某个点或轴旋转 (Rotating an object around a point or axis)。
    • 缩放 (scale): 物体放大或缩小 (Enlarging or reducing an object)。
  • 正交矩阵 (Orthogonal Matrices): 旋转矩阵就是一种正交矩阵。它的特点是逆矩阵等于转置矩阵,方便计算 (A rotation matrix is an orthogonal matrix. Its characteristic is that the inverse matrix is equal to the transposed matrix, which is convenient for calculation)。
  • 案例 (Example): 在 3D 游戏中,一个角色的模型由很多个顶点组成。要让角色移动、跳跃、转身,就需要对所有顶点进行平移、旋转等变换。这些变换都可以用矩阵来表示,然后一次性应用到所有顶点上 (In a 3D game, a character model consists of many vertices. To make the character move, jump, and turn around, you need to translate, rotate, and other transform all the vertices. These transformations can be represented by matrices and then applied to all vertices at once)

D. 四元数 (Quaternions)

  • 简单解释 (Simple Explanation): 四元数是一种扩展的复数,可以用来表示 3D 旋转,并且没有万向锁的问题 (Quaternions are an extension of complex numbers that can be used to represent 3D rotations without the problem of gimbal lock)。
  • 万向锁 (Gimbal Lock): 使用欧拉角表示旋转时,可能会出现 Gimbal Lock,导致旋转自由度丢失 (When using Euler angles to represent rotations, Gimbal Lock may occur, resulting in the loss of degrees of freedom of rotation)。
  • 线性插值和球面插值 (Linear Interpolation and Spherical Interpolation): 在两个旋转之间平滑过渡。球面插值更适合旋转,因为它能保证旋转的速度恒定 (Smooth transition between two rotations. Spherical interpolation is more suitable for rotation because it can guarantee a constant rotation speed)。
  • 案例 (Example): 游戏中,如果使用欧拉角表示飞机的姿态,可能会出现万向锁,导致飞机无法正常旋转。使用四元数可以避免这个问题,保证飞机的旋转平滑自然 (In the game, if Euler angles are used to represent the attitude of the aircraft, gimbal lock may occur, causing the aircraft to fail to rotate normally. Using quaternions can avoid this problem and ensure that the rotation of the aircraft is smooth and natural)。

E. 坐标系 (Coordinate Systems)

  • 简单解释 (Simple Explanation): 坐标系就是用来确定物体位置的参考系 (A coordinate system is a frame of reference used to determine the position of an object)。
  • 线和面 (Lines and Planes): 3D 空间中的基本几何元素 (Basic geometric elements in 3D space)。
  • 案例 (Example): 在 3D 建模软件中,你需要定义物体在空间中的位置和形状。这需要使用不同的坐标系,例如世界坐标系、局部坐标系等 (In 3D modeling software, you need to define the position and shape of objects in space. This requires the use of different coordinate systems, such as world coordinate systems, local coordinate systems, etc.)。

F. 离散数学 (Discrete Mathematics)

  • 简单解释 (Simple Explanation): 离散数学是研究离散结构(而不是连续的)的数学分支 (Discrete mathematics is a branch of mathematics that studies discrete structures (rather than continuous ones))。
  • 集合论 (Set Theory): 研究集合的性质和关系的学问 (The study of the properties and relationships of sets)。
  • 图、树和有向图 (Graphs, Trees, and Directed Graphs): 描述事物之间关系的模型 (Models describing the relationships between things)。
  • 优化问题 (Optimization Problems): 寻找最佳解决方案的问题 (The problem of finding the best solution)。
  • 案例 (Example): 游戏中的寻路算法,例如 A* 算法,就用到了图论的知识 (Pathfinding algorithms in games, such as the A* algorithm, use the knowledge of graph theory)。

参考书籍

  • Verth, J. M. V., & Bishop, L. M. (2008). Essential Mathematics for Games and Interactive Applications: A Programmer’s Guide (2nd ed.). CRC Press. ISBN: 978-0-12-374297-1
  • Hughes, J. F., et al. (2013). Computer Graphics: ISBN: 978-0-321-39952-6
  • Lengyel, E. (2016). Foundations of Game Engine Development. Volume 1: Mathematics. ISBN-13:978-0-9858117-4-7
  • Lengyel, E. (2019). Foundations of Game Engine Development. Volume 12: Rendering. ISBN-13:978-0-9858117-5-4

微信公众号

在哪裡買軟件?全網最低價買軟件商城:

我自己覺得好用的軟件和服務

免費電子書、PDF