Games101 - 现代计算机图形学入门
Games101 - 现代计算机图形学入门
[WIP]
光栅化(Rasterization)
将三维空间的几何形体显示在屏幕上(转成对应的像素)就是光栅化
线性代数
1. 向量
1
> 图形学里在不说明向量横竖方向时,都默认书写为竖向量(转置为横向量), 矩阵类似
1.0 相加
1.1 点乘(Dot) 快速获取两个向量的夹角
1
> 点乘(点积,Dot Product)通常用于表示两个向量的内积。
1.1.1 点乘示例
\[\mathbf{a} \cdot \mathbf{b} = a_1 b_1 + a_2 b_2 + \cdots + a_n b_n\] \[\begin{pmatrix} a_1 \\ a_2 \\ a_3 \\ a_4 \end{pmatrix} \cdot \begin{pmatrix} b_1 \\ b_2 \\ b_3 \\ b_4 \end{pmatrix} = a_1 b_1 + a_2 b_2 + a_3 b_3 + a_4 b_4\]1.1.2 具体数值的点乘
\[\begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix} \cdot \begin{pmatrix} 4 \\ 5 \\ 6 \end{pmatrix} = 1 \cdot 4 + 2 \cdot 5 + 3 \cdot 6 = 32\]1.2.3 点乘的几何意义是两个向量的模长乘以它们夹角的余弦。
\[\mathbf{a} \cdot \mathbf{b} = \|\mathbf{a}\| \|\mathbf{b}\| \cos \theta\]1.2 叉乘
叉乘(叉积,Cross Product)通常用于表示两个向量的外积。
1.2.1 示例
\[\mathbf{a} \times \mathbf{b} = \begin{pmatrix} a_2 b_3 - a_3 b_2 \\ a_3 b_1 - a_1 b_3 \\ a_1 b_2 - a_2 b_1 \end{pmatrix}\]1.2.2 具体数值的叉乘
\[\begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix} \times \begin{pmatrix} 4 \\ 5 \\ 6 \end{pmatrix} = \begin{pmatrix} 2 \cdot 6 - 3 \cdot 5 \\ 3 \cdot 4 - 1 \cdot 6 \\ 1 \cdot 5 - 2 \cdot 4 \end{pmatrix} = \begin{pmatrix} -3 \\ 6 \\ -3 \end{pmatrix}\]1.2.3 叉乘的几何意义是生成一个垂直于两个向量的新向量,其模长等于两个向量的模长乘以它们夹角的正弦。
\[\|\mathbf{a} \times \mathbf{b}\| = \|\mathbf{a}\| \|\mathbf{b}\| \sin \theta\]1.2.4 叉乘的行列式表示
\[\mathbf{a} \times \mathbf{b} = \begin{vmatrix} \mathbf{i} & \mathbf{j} & \mathbf{k} \\ a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \end{vmatrix}\]2. 矩阵
2.1 矩阵相乘
(M x N)(N x P)=(M x P) 矩阵相乘,第一个矩阵的列(N)一定要跟第二个矩阵的行(N)相同,最后会得到一个(M x P)的矩阵
示例1:
\[\begin{pmatrix} a & b \\ c & d \end{pmatrix} \times \begin{pmatrix} e & f \\ g & h \end{pmatrix} = \begin{pmatrix} ae + bg & af + bh \\ ce + dg & cf + dh \end{pmatrix}\]示例2:
\[\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \\ a_{31} & a_{32} \end{pmatrix} \begin{pmatrix} b_{11} & b_{12} & b_{13} & b_{14} \\ b_{21} & b_{22} & b_{23} & b_{24} \end{pmatrix} = \begin{pmatrix} a_{11}b_{11} + a_{12}b_{21} & a_{11}b_{12} + a_{12}b_{22} & a_{11}b_{13} + a_{12}b_{23} & a_{11}b_{14} + a_{12}b_{24} \\ a_{21}b_{11} + a_{22}b_{21} & a_{21}b_{12} + a_{22}b_{22} & a_{21}b_{13} + a_{22}b_{23} & a_{21}b_{14} + a_{22}b_{24} \\ a_{31}b_{11} + a_{32}b_{21} & a_{31}b_{12} + a_{32}b_{22} & a_{31}b_{13} + a_{32}b_{23} & a_{31}b_{14} + a_{32}b_{24} \end{pmatrix}\]2.2 矩阵不满足交换律(大部分情况下),AxB != BxA
相关资料
- 计算机图形学 虎书 Fundamentals-Of-Computer-Graphics 第5版学习笔记(中文翻译)
- https://learnopengl.com/
- https://learnopengl-cn.github.io/
- https://vulkan-tutorial.com/
- https://www.khanacademy.org/math/linear-algebra/matrix_transformations
Video
{% include embed/bilibili.html id=’BV1X7411F744’ %}
{% include embed/youtube.html id=’yn7eOiWaf40’ %}
{% include embed/video.html src=’https://www.bilibili.com/video/av90798049/’ %}
This post is licensed under CC BY 4.0 by the author.