摘要

旋转矩阵更容易理解与记忆的推导,从2D到3D


声明:本文推导适用于右手坐标系。
旋转角度说明:本文说的绕x轴旋转θ\theta度指的是顺着x轴负方向看过去,逆时针旋转θ\theta度。若想获得顺时针旋转的旋转矩阵,只需要把θ\theta改为θ-\theta即可。(个人觉得3D空间中要想准确描述旋转而不造成混淆,至少要说明三点:旋转轴,朝向,在该朝向下是顺时针还是逆时针旋转。)

2D旋转矩阵

2D旋转矩阵推导公式网上都有,不再赘述。参考这里,有
旋转矩阵更容易理解与记忆的推导,从2D到3D
由上述推导可得2D空间中,从X轴向Y轴旋转θ\theta度的旋转矩阵为:
[XY]=[cosθsinθsinθcosθ][XY] \begin{bmatrix} X' \\ Y' \end{bmatrix}= \begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix} \begin{bmatrix} X \\ Y \end{bmatrix}
注意:上述公式相当于3D空间中,绕Z轴旋转θ\theta度的公式,即顺着Z轴负方向看过去逆时针旋转θ\theta度。也相当于把X轴旋转向Y轴的公式。
后面的3D旋转矩阵全都以此为基础变形,无非是移动一下元素位置。

3D旋转矩阵

绕Z轴旋转θ\theta度的公式

由2D旋转矩阵直接可得,不作推导:
[XYZ]=[cosθsinθ0sinθcosθ0001][XYZ] \begin{bmatrix} X' \\ Y' \\ Z' \end{bmatrix}= \begin{bmatrix} cos\theta & -sin\theta & 0 \\ sin\theta & cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \end{bmatrix}

绕Y轴旋转θ\theta度的公式

可根据2D旋转矩阵直接变形得到,过程如下:
根据我们的规定,绕Y轴旋转表示逆着Y轴正方向逆时针旋转,根据右手坐标系可知,相当于从Z轴旋转向X轴,根据2D旋转矩阵,可得
[ZX]=[cosθsinθsinθcosθ][ZX] \begin{bmatrix} Z' \\ X' \end{bmatrix}= \begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix} \begin{bmatrix} Z \\ X \end{bmatrix}
扩展到3D旋转矩阵,为
[ZXY]=[cosθsinθ0sinθcosθ0001][ZXY] \begin{bmatrix} Z' \\ X' \\ Y' \end{bmatrix}= \begin{bmatrix} cos\theta & -sin\theta & 0 \\ sin\theta & cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} Z \\ X \\ Y \end{bmatrix}
调整一下右边坐标顺序,公式变形为
[ZXY]=[sinθ0cosθcosθ0sinθ010][XYZ] \begin{bmatrix} Z' \\ X' \\ Y' \end{bmatrix}= \begin{bmatrix} -sin\theta & 0 & cos\theta \\ cos\theta & 0 & sin\theta \\ 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \end{bmatrix}
再调整一下左边坐标顺序,公式变形为
[XYZ]=[cosθ0sinθ010sinθ0cosθ][XYZ] \begin{bmatrix} X' \\ Y' \\ Z' \end{bmatrix}= \begin{bmatrix} cos\theta & 0 & sin\theta \\ 0 & 1 & 0 \\ -sin\theta & 0 & cos\theta \end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \end{bmatrix}

绕X轴旋转θ\theta度的公式

同理,也可从2D旋转矩阵直接变形得到
[XYZ]=[1000cosθsinθ0sinθcosθ][XYZ] \begin{bmatrix} X' \\ Y' \\ Z' \end{bmatrix}= \begin{bmatrix} 1 & 0 & 0 \\ 0 & cos\theta & -sin\theta \\ 0 & sin\theta & cos\theta \end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \end{bmatrix}

相关/参考链接

旋转矩阵公式推导
旋转矩阵推导 | 推荐读这个,首先它清楚的定义了顺时针旋转到底是怎么转,只有定义清楚了,旋转才不会混淆。

相关文章:

  • 2022-01-08
  • 2022-01-24
  • 2022-12-23
  • 2021-05-14
  • 2021-11-07
  • 2021-06-23
  • 2021-08-13
猜你喜欢
  • 2021-08-13
  • 2021-07-07
  • 2021-12-13
  • 2022-12-23
  • 2021-10-19
  • 2021-06-19
  • 2021-07-31
相关资源
相似解决方案