线性代数之矩阵

一、矩阵乘法运算

只有满足 (M X N)(N X P) = (M X P) 的矩阵才能相乘,即第一个矩阵的列数等于第二个矩阵的行数。最后得到的新矩阵,行数等于第一个矩阵的行数,列数等于第二个矩阵的列数。

\begin{pmatrix} 1 &3 \\ 5& 2\\ 0& 4 \end{pmatrix}\begin{pmatrix} 3& 6& 9&4 \\ 2 & 7& 8& 3 \end{pmatrix}\begin{pmatrix} 1*3+3*2 = 9 & 1*6+3*7=27 &1*9+3*8=33 & 1*4+3*3=13\\ 5*3+2*2=19&5*6+2*7=44 &5*9+2*8=61 & 5*4+2*3=26\\ 0*3+4*2=8& 0*6+4*7 = 28 &0*9+4*8=32 & 0*4+4*3=12 \end{pmatrix} = \begin{pmatrix} 9 & 27& 33&13 \\ 19 & 44& 61&26 \\ 8 & 28& 32 & 12 \end{pmatrix}

 比如得到新矩阵左上角的值9,9位于第一行第一列,就可以对应找第一个矩阵的第一行第二个矩阵的第一列去乘

二、矩阵的属性

1、不满足交换律:AB \neq BA

2、满足结合律和分配律

     (AB)C = A(BC)

       (A+B)C = AB+BC

三、2D矩阵的变换

 {x}' = s_{x}x{y}' = s_{y}y

矩阵表示:

\binom{​{x}'}{​{y}'} = \begin{pmatrix} s_{x} & 0\\ 0 & s_{y} \end{pmatrix} \binom{x}{y} = \binom{s_{x}*x+0*y = s_{x}x}{0*x+s_{y}*y=s_{y}y}

 其中s_{x}s_{y}分别为x、y轴上的缩放值,

1、缩放,当s_{x}s_{y}相等时,就是等比缩放,如图:

\begin{pmatrix} {x}'\\ {y}' \end{pmatrix} = \begin{pmatrix} 0.5 & 0\\ 0 & 0.5 \end{pmatrix} \begin{pmatrix} x\\ y \end{pmatrix} = \begin{pmatrix} 0.5*x+0*y=0.5x\\ 0*x+0.5*y=0.5y \end{pmatrix}

2、翻转,当​s_{x}s_{y}为负数时,就是左右或者上下翻转,如图:

\begin{pmatrix} {x}'\\ {y}' \end{pmatrix} =  \begin{pmatrix} -1 &0 \\ 0& 1 \end{pmatrix}\begin{pmatrix} x\\ y \end{pmatrix} = \begin{pmatrix} -1*x+0*y = -x\\ 0*x+1*y =y \end{pmatrix} 

3、变形,如图,y的值没有变化,y对应的x都是加上ay,即{x}' = x + ay 

\begin{pmatrix} {x}'\\ {y}' \end{pmatrix} = \begin{pmatrix} 1 & a\\ 0& 1 \end{pmatrix}\begin{pmatrix} x\\ y \end{pmatrix} = \begin{pmatrix} x+ay\\ y \end{pmatrix}

 4、旋转,如图

 由框住的四个坐标进行推导,旋转用矩阵可表示为:

\begin{pmatrix} {x}'\\ {y}' \end{pmatrix} = \begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}\begin{pmatrix} x\\ y \end{pmatrix}

上面四种变换可归纳成矩阵:

\begin{pmatrix} {x}'\\ {y}' \end{pmatrix} = \begin{pmatrix} a &b \\ c& d \end{pmatrix} \begin{pmatrix} x\\ y \end{pmatrix}

5、平移,如图

{x}' = x +t _{x} , {y}' = y +t _{y},无法用上述的矩阵表示,便引入了齐次坐标,任意的坐标\begin{pmatrix} x\\ y \end{pmatrix} 用齐次坐标表示为\begin{pmatrix} x\\ y\\ 1 \end{pmatrix}

总结,用齐次坐标表示上述的缩放、旋转、平移为:

 四、3D的变换

1、3D矩阵各部分的含义表示为如下图:

2、3D矩阵绕轴旋转用矩阵表示

坐标轴之间的正交关系为:

  未旋转之前的点为(x,y,z) 

(1)绕x轴旋转\ddot{y} x \ddot{z} = +\ddot{x} ,需要从x轴的负方向上看过去,如2D矩阵变换之旋转的图二左侧的红色框的点。     

     新点的x不变,将y和z代入公式

     新点的y = \cos \theta * y - \sin \theta * z

     新点的z = \sin \theta * y + \cos \theta * z;

     为了得到新点的x、y、z,写成矩阵:

    \begin{pmatrix} 1 & 0 & 0 &0 \\ 0& \cos \theta & -\sin \theta &0 \\ 0 & \sin \theta & \cos \theta &0 \\ 0& 0& 0 & 1 \end{pmatrix}

(2)绕y轴旋转\ddot{z} x \ddot{x} = +\ddot{y}

        新点的y不变,将z和x代入公式

        新点的z = \cos \theta * z - \sin \theta * x

        新点的x = \sin \theta * z + \cos \theta * x       

       为了得到新点的x、y、z,写成矩阵:

       \begin{pmatrix} \cos \theta & 0 & \sin \theta &0 \\ 0& 1& 0& 0\\ -\sin \theta & 0& \cos \theta &0 \\ 0& 0& 0& 1 \end{pmatrix}

 (3)绕z轴旋转\ddot{x} x \ddot{y} = +\ddot{z}

         新点的z不变,将x和y代入公式

         新点的x = \cos \theta * x - \sin \vartheta * y

         新点的y = \sin \theta * x + \cos \theta * y

         为了得到新点的x、y、z,写成矩阵:

       \begin{pmatrix} \cos \theta & -\sin \theta & 0&0 \\ \sin \theta & \cos \vartheta & 0&0 \\ 0& 0& 1& 0\\ 0& 0& 0& 1 \end{pmatrix}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值