基础线代公式汇总

相关专业大学时都学过线代, 然而等到真正需要用的时候,已经过去好久了导致很多东西都忘了,所以需要专门开一贴记录一下,这里就当是个汇总吧

1):向量点乘与其向量夹角之间的关系

\mathrm{a} \bullet b=\|a\| b \| \cos \theta

2):向量b在向量a上的投影(其中\theta为向量ab之间的夹角)

b_{1} = {|b|}\frac a{|a|}\cos\theta
3):向量a和b的叉乘(积):

{\mathbf{a}} \times {\mathbf{b}} = \left| \begin{array}{ccc} {\mathbf{i}} & {\mathbf{j}} & {\mathbf{k}} \\ {a_{1}} & {a_{2}} & {a_{3}} \\ {b_{1}} & {b_{2}} & {b_{3}} \end{array} \right|,其中i, j, k为基向量

  • a和b的向量积同时垂直于这两个向量
  • n(n>3) 维向量不存在向量积
  • 计算二维向量的向量积时, 第三维补0,同上公式

4):转置矩阵、 标准伴随矩阵、代数余子式、逆矩阵与正交矩阵

设矩阵M = \left[ \begin{array}{lll} {4} & {5} & {8} \\ {6} & {5} & {9} \\ {7} & {3} & {1} \end{array} \right],这个M必须为方阵,不然就是换维操作,没有下面的东西

  • 转置矩阵:行列翻转,M^{T} = \left[ \begin{array}{lll} {4} & {6} & {7} \\ {5} & {5} & {3} \\ {8} & {9} & {1} \end{array} \right](A B)^T=B^T A^T
  • 余子式:矩阵对应行列式去掉某一行某一列后的新行列式:M_{23} = \left[ \begin{array}{ll} {4} & {6} \\ {8} & {9} \end{array} \right]
  • 代数余子式矩阵:显然一个n*n的行列式共有n*n个余子式,这n*n个余子式的值(代数余子式)构成的矩阵即代数余子式矩阵,代数余子式与余子式之间的关系:A_{i j}=(-1)^{i+j} M_{i j}
  • 标准伴随矩阵:接上,即代数余子式构成的方阵进行转置后得到: M^* = \left[ \begin{array}{lll} {A_{11}} & {A_{21}} & {A_{31}} \\ {A_{12}} & {A_{22}} & {A_{32}} \\ {A_{13}} & {A_{23}} & {A_{33}} \end{array} \right]
  • 逆矩阵: 矩阵本质上就是对空间的线性变换,而逆矩阵的意义就是将进行了对应线性变换后的空间再“变回去”,即满足MM^{-1} = E,其中E为单位矩阵,标准求法:M^{-1}=\frac{1}{|M|} M^{*},其中|M|为矩阵M​​​对应行列式的值(当然了,这个行列式的值不可为0,值为0就意味着不存在可逆矩阵)​​​ 
  • 正交矩阵:满足 MM^T = E 的矩阵,矩阵中任意两个向量两两正交,且长度为1

5):4x4 齐次矩阵

  • 齐次坐标:将一个原本是 n 维的向量用一个 n+1 维向量来表示,对于 3d 图形,只有 4x4 的齐次矩阵才能满足其各种操作(平移、旋转、透视、小孔成像等), 对于这个 4x4 矩阵的第四维 w,我们一般称其为齐次坐标

6):向量缩放与位移

  • 缩放:设有向量 (x,y,z),缩放变量为 (S_1,S_2,S_3),则对应的缩放矩阵为\left[\begin{array}{cccc} S_{1} & 0 & 0 & 0 \\ 0 & S_{2} & 0 & 0 \\ 0 & 0 & S_{3} & 0 \\ 0 & 0 & 0 & 1 \end{array}\right] \cdot\left(\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right)=\left(\begin{array}{c} S_{1} \cdot x \\ S_{2} \cdot y \\ S_{3} \cdot z \\ 1 \end{array}\right)
  • 位移:非线性变换,设有向量 (x,y,z),位移向量为 (S_x,S_y,S_z),则对应的位移矩阵为\left[\begin{array}{cccc} 1 & 0 & 0 & S_{x} \\ 0 & 1 & 0 & S_{y} \\ 0 & 0 & 1 & S_{z} \\ 0 & 0 & 0 & 1 \end{array}\right] \cdot\left(\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right)=\left(\begin{array}{c} x+S_{x} \\ y+S_{y} \\ z+S_{z} \\ 1 \end{array}\right),如果向量 (x,y,z)仅表示方向,那么位移向量应该对其无效,此时需要将向量(x,y,z)w 分量设为 0

7):欧拉角旋转

注:以下的所有旋转轴(R_x,R_y,R_z)一定为单位向量,其中围绕着x, y, z轴的旋转即第一种情况的特例

  • 旋转:设有向量 (x,y,z),围绕着轴 (R_x,R_y,R_z)旋转\theta度,则对应的缩放矩阵为\left[\begin{array}{cccc} \cos \theta+R_{x}^{2}(1-\cos \theta) & R_{x} R_{y}(1-\cos \theta)-R_{z} \sin \theta & R_{x} R_{z}(1-\cos \theta)+R_{y} \sin \theta & 0 \\ R_{y} R_{x}(1-\cos \theta)+R_{z} \sin \theta & \cos \theta+R_{y}^{2}(1-\cos \theta) & R_{y} R_{z}(1-\cos \theta)-R_{x} \sin \theta & 0 \\ R_{z} R_{x}(1-\cos \theta)-R_{y} \sin \theta & R_{z} R_{y}(1-\cos \theta)+R_{x} \sin \theta & \cos \theta+R_{z}^{2}(1-\cos \theta) & 0 \\ 0 & 0 & 0 & 1 \end{array}\right]
  • 围绕着轴x旋转:\left[\begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos \theta & -\sin \theta & 0 \\ 0 & \sin \theta & \cos \theta & 0 \\ 0 & 0 & 0 & 1 \end{array}\right] \cdot\left(\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right)=\left(\begin{array}{c} x \\ \cos \theta \cdot y-\sin \theta \cdot z \\ \sin \theta \cdot y+\cos \theta \cdot z \\ 1 \end{array}\right)
  • 围绕着轴y旋转:\left[\begin{array}{cccc} \cos \theta & 0 & \sin \theta & 0 \\ 0 & 1 & 0 & 0 \\ -\sin \theta & 0 & \cos \theta & 0 \\ 0 & 0 & 0 & 1 \end{array}\right] \cdot\left(\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right)=\left(\begin{array}{c} \cos \theta \cdot x+\sin \theta \cdot z \\ y \\ -\sin \theta \cdot x+\cos \theta \cdot z \\ 1 \end{array}\right)
  • 围绕着轴z旋转:\left[\begin{array}{cccc} \cos \theta & -\sin \theta & 0 & 0 \\ \sin \theta & \cos \theta & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right] \cdot\left(\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right)=\left(\begin{array}{c} \cos \theta \cdot x-\sin \theta \cdot y \\ \sin \theta \cdot x+\cos \theta \cdot y \\ z \\ 1 \end{array}\right)

欧拉角旋转远比上述计算要复杂,更多关于欧拉角旋转的知识可以参考:OpenGL基础16:视角_Jaihk662的博客-CSDN博客_opengl视角

  • 8
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值