02 Review of Linear Algebra
概述
- 线性代数回顾
- A Swift and Brutal Introduction to Linear Algebra!
向量
- 图形学中均为列向量
- 表示方向和长度
- 没有绝对的起点(任意两个方向和长度相等的向量可认为是同一个向量)
- A B → = B − A \overrightarrow{AB} = B - A AB=B−A
单位向量
- 大小为1的向量
- 被用来表示方向
点乘(Dot)
- 结果为一个数
a ⃗ ⋅ b ⃗ = ∥ a ⃗ ∥ ∥ b ⃗ ∥ cos θ \vec{a}\cdot\vec{b}=\lVert\vec{a}\rVert\lVert\vec{b}\rVert \cos\theta a⋅b=∥a∥∥b∥cosθ
=>
cos θ = a ⃗ ⋅ b ⃗ ∥ a ⃗ ∥ ∥ b ⃗ ∥ \cos \theta = \frac{\vec{a} \cdot \vec{b}}{\lVert \vec{a} \rVert \lVert \vec{b} \rVert} cosθ=∥a∥∥b∥a⋅b
cos θ = a ^ ⋅ b ^ , a ^ is unit vector, a ^ = a ⃗ ∥ a ⃗ ∥ \cos \theta = \hat{a} \cdot \hat{b} ,\text { $\hat{a}$ is unit vector, $\hat{a}=\frac{\vec{a}}{\lVert \vec{a} \rVert}$} cosθ=a^⋅b^, a^ is unit vector, a^=∥a∥a
属性
a
⃗
⋅
b
⃗
=
b
⃗
⋅
a
⃗
\vec{a} \cdot \vec{b} = \vec{b} \cdot \vec{a}
a⋅b=b⋅a
a
⃗
(
b
⃗
+
c
⃗
)
=
a
⃗
⋅
b
⃗
+
a
⃗
⋅
c
⃗
\vec{a}(\vec{b} + \vec{c}) = \vec{a} \cdot \vec{b} + \vec{a} \cdot \vec{c}
a(b+c)=a⋅b+a⋅c
(
k
a
⃗
)
⋅
b
⃗
=
a
⃗
⋅
(
k
b
⃗
)
=
k
a
⃗
⋅
b
⃗
(k\vec{a})\cdot \vec{b}= \vec{a} \cdot (k\vec{b}) = k{\vec{a} \cdot \vec{b}}
(ka)⋅b=a⋅(kb)=ka⋅b
点乘-笛卡尔坐标系
二维
a
⃗
⋅
b
⃗
=
(
x
a
y
a
)
⋅
(
x
b
y
b
)
=
x
a
x
b
+
y
a
y
b
\vec{a} \cdot \vec{b}=\begin{pmatrix} x_a \\ y_a \\ \end{pmatrix} \cdot \begin{pmatrix} x_b \\ y_b \\\end{pmatrix} = x_ax_b + y_ay_b
a⋅b=(xaya)⋅(xbyb)=xaxb+yayb
三维
a
⃗
⋅
b
⃗
=
(
x
a
y
a
z
a
)
⋅
(
x
b
y
b
z
b
)
=
x
a
x
b
+
y
a
y
b
+
z
a
z
b
\vec{a} \cdot \vec{b}=\begin{pmatrix} x_a \\ y_a \\ z_a \end{pmatrix} \cdot \begin{pmatrix} x_b \\ y_b \\ z_b \end{pmatrix} = x_ax_b + y_ay_b + z_az_b
a⋅b=
xayaza
⋅
xbybzb
=xaxb+yayb+zazb
点乘在图形学中应用
- 向量投影
- 分解向量(计算投影后可根据平行四边形法则得到垂直向量)
- 计算两个向量是同向还是反向
叉乘(Cross)
- 结果为一个向量
- 叉积向量与初始向量正交
- 方向符合右手螺旋法则
- 可以用来构建坐标系
a
⃗
×
b
⃗
=
−
b
⃗
×
a
⃗
\vec{a} \times \vec{b} = -\vec{b} \times \vec{a}
a×b=−b×a
∥
a
⃗
×
b
⃗
∥
=
∥
a
⃗
∥
∥
b
⃗
∥
sin
θ
\lVert \vec{a} \times \vec{b} \rVert = \lVert \vec{a} \rVert \lVert \vec{b} \rVert \sin \theta
∥a×b∥=∥a∥∥b∥sinθ
属性
x
⃗
×
y
⃗
=
+
z
⃗
\vec{x} \times \vec{y} = +\vec{z}
x×y=+z
y
⃗
×
x
⃗
=
−
z
⃗
\vec{y} \times \vec{x} = -\vec{z}
y×x=−z
a
⃗
×
b
⃗
=
−
b
⃗
×
a
⃗
\vec{a} \times \vec{b} = -\vec{b} \times \vec{a}
a×b=−b×a
a
⃗
×
(
b
⃗
+
c
⃗
)
=
a
⃗
×
b
⃗
+
a
⃗
×
c
⃗
\vec{a} \times (\vec{b} + \vec{c}) = \vec{a} \times \vec{b} + \vec{a} \times \vec{c}
a×(b+c)=a×b+a×c
a
⃗
×
(
k
b
⃗
)
=
k
(
a
⃗
×
b
⃗
)
\vec{a} \times (k\vec{b}) = k(\vec{a} \times \vec{b})
a×(kb)=k(a×b)
叉乘-笛卡尔坐标系
a
⃗
×
b
⃗
=
(
y
a
z
b
−
y
b
z
a
z
a
x
b
−
x
a
z
b
x
a
y
b
−
y
a
x
b
)
\vec{a} \times \vec{b} = \begin{pmatrix} y_az_b-y_bz_a \\ z_ax_b-x_az_b \\ x_ay_b-y_ax_b \\ \end{pmatrix}
a×b=
yazb−ybzazaxb−xazbxayb−yaxb
a
⃗
×
b
⃗
=
A
∗
b
(
0
−
z
a
y
a
z
a
0
−
x
a
−
y
a
x
a
0
)
(
x
b
y
b
z
b
)
\vec{a} \times \vec{b} = A^*b \begin{pmatrix} 0 & -z_a & y_a \\ z_a & 0 & -x_a \\ -y_a & x_a & 0 \\ \end{pmatrix} \begin{pmatrix} x_b \\ y_b \\ z_b \\ \end{pmatrix}
a×b=A∗b
0za−ya−za0xaya−xa0
xbybzb
叉乘在图形学中应用
- 判断向量在左还是右(相对而言)
- 判断向量在内还是外,判断p点在三角形内
矩阵
属性
- 矩阵往往没有交换律
- 具有分配律
矩阵转置
( A B ) T = B T A T (AB)^T=B^TA^T (AB)T=BTAT