欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

GAMES101 - 现代计算机图形学入门:Lec02 向量和线性代数

最编程 2024-06-24 18:42:26
...

大家好,我是曹骏。因为本人对计算机图形学、webGPU等非常感兴趣,将会推出闫令琪博士的《GAMES101:现代计算机图形学入门》课程译文,希望能帮助到更多的同学理解课程,爱上图形学这一浪漫的学科。

课程链接如下

www.bilibili.com/video/BV1X7…

0 图形学依赖于... Graphics’ Dependencies

  • 基础数学
    • 线性代数 linear algebra
    • 微积分 calculus
    • 统计学 statistics
  • 基础物理
    • 光学 Optics
    • 力学 Mechanics
  • 其他
    • 信号处理 signal processing

    • 数值分析 numerical analysis

    • 一点点的美学 A bit of aesthetics

1 向量 Vectors

1.1 向量的归一化 Vector Normalization

1.2 向量的加法 Vector Addition

  • 几何理解 Geometrically
    • 平行四边形法则合三角形法则 Parallelogram law & Triangle law
  • 代数 algebraically
    • 各坐标相加 Simply add coordinates

1.3 向量的点乘 Dot(scalar) Product

1.3.1 定义与用法

1.3.2性质 Properties

1.3.3笛卡尔坐标系下的点积 Dot Product in Cartesian Coordinates

  • In 2D

  • In 3D

1.3.4 图形学中的点积 Dot Product for Graphics

  • 求两个向量之间的角度(例如光源在表面之间角度的余弦)Find angle between two vectors (e.g. cosine of angle between light source and surface)
  • 计算一个向量在另一个向量上的投影 Finding projection of one vector on another

  • 测量两个方向有多接近 Measure how close two directions are
  • 分解向量 Decompose a vector

  • 判断朝向 Determine forward / backward
    • 基于右手螺旋定则,四指从a向量选择到c向量拇指朝外,可以判c向量在a向量的左边
    • 基于右手螺旋定则,四指从a向量选择到b向量拇指朝内,可以判c向量在a向量的右边

1.4 向量的叉乘 Cross(vector) Product

1.4.1 定义与用法

  • 叉乘结果是一个向量,与两个初始向量垂直 Cross product is orthogonal to two initial vectors

  • 叉乘的结果由右手定则确定 Direction determined by right-hand rule

  • 用于构建坐标系 Useful in constructing coordinate systems

  • 叉乘结果的模在大小上与组成两个向量组成三角形面积相等

1.4.2 性质 Properties

  • 没有交换律和结合率

  • 向量与自身的叉乘为0向量(注意不是数值0)

  • 有结合律

没有结合率的原因可以参考:zhidao.baidu.com/question/15…

1.4.3 笛卡尔坐标系下的叉乘 Cross Product: Cartesian Formula

  • 判断点在三角形内部外部时看正负即看z坐标的正负

1.4.4 图形学中的叉乘 Cross Product in Graphics

  • 判定左和右
    • 如下图,在右手坐标系中,a向量叉乘b向量结果为正,则b在a的左侧

  • 判断内和外
    • 如下图,按顺序叉乘三次结果正负相同则在内部,否则在外部

1.5 正交坐标系 Orthonormal Bases / Coordinate Frames

如果有三个向量满足

  • 当三个向量互相垂直时,符合
  • 公式中的= ,而v向量的模为 1,因此可以得到p向量在v向量方向上为

更易于用坐标系表达一个向量

2 矩阵 Matrix

在图形学中,普遍用于表示变换
In Graphics, pervasively used to represent transformations

2.1 什么是矩阵 What is a matrix

  • 一个数字阵列 Array of numbers (m × n = m rows, n columns)

  • 与标量的加法和乘法运算为每个元素单独运算 Addition and multiplication by a scalar are trivial:
    element by element

2.2 矩阵与矩阵的乘积 Matrix-Matrix Multiplication

  • A的列数必须等于B的行数才能进行乘法运算 The number of columns in A must equal to the number of rows in B

  • 乘积中元素(i,j)是A中第i行和B中第j列的点积结果

2.3 矩阵的性质 Properties

  • 没有交换律  Non-commutative(AB and BA are different in general)

  • 有结合律和分配律 Associative and distributive

2.4 矩阵与向量的乘积 Matrix-Vector Multiplication

  • 向量视为列矩阵 Treat vector as a column matrix (m×1)

  • 是变换的核心 Key for transforming points

2.5 矩阵的转置 Transpose of a Matrix

  • 将矩阵的行和列互换 Switch rows and columns (ij -> ji)

  • 转置的性质 Property

2.6 单位矩阵和逆矩阵 Identity Matrix and Inverses

  • 单位矩阵 Identity Matrix
    • 单位矩阵的对角线都为1

  • 逆矩阵 Inverses
    • 两个矩阵乘积单位矩阵,则两个矩阵互逆

    • 逆矩阵的性质

3 矩阵形式的向量乘积 Vector multiplication in Matrix form

3.1 点乘 Dot product

3.2 叉乘 Cross product