点绕坐标系旋转旋转矩阵推导、理解

开会过程中,翻笔记本时突然发现了之前推导的点绕坐标系旋转的旋转矩阵求解过程。在直觉上,一个点绕3个坐标轴旋转的旋转矩阵在形式上看起来是一致的,观感上比较优雅、整齐,但是一直没有仔细观察背后的原理。因此又对这个过程进行了一次推导,对这种整齐有了更深的理解,同时对记忆也有所帮助。特此记录。

由于我们提到三维坐标系时,常用XYZ三个字母代替3个轴,为了不失一般性,避免字母先入为主产生的印象,在这里用UVW来指代右手三维坐标系。

大拇指指向轴线方向,四指方向为旋转的正方向

如下图所示。 坐标系UVW为右手坐标系,一个点绕W轴旋转θ\thetaθ角度前后的坐标为(U′,V′)−−−>(U,V)(U^{'},V^{'})--->(U,V)(U,V)>(U,V) 求解旋转后的坐标(旋转矩阵)。
坐标系及旋转方向定义

为了方便求解,定义2个中间变量R,δR,\deltaR,δR表示点到原点的距离,在旋转前后,点到原点的距离不变。
则有下列公式成立:

{U′=R∗cosδV′=R∗sinδ(1) \left\{ \begin{aligned} U^{'} = R*cos\delta \\ V^{'} = R*sin\delta \\ \tag{1} \end{aligned} \right. {U=RcosδV=Rsinδ(1)
{U=R∗cos(δ+θ)=R∗(cosδcosθ−sinδsinθ)V=R∗sin(δ+θ)=R∗(sinδcosθ+cosδsinθ)(2) \left\{ \begin{aligned} U = R*cos(\delta+\theta) =R*(cos{\delta}cos{\theta}-sin{\delta}sin{\theta})\\ V = R*sin(\delta+\theta) =R*(sin{\delta}cos{\theta}+cos{\delta}sin{\theta}) \\ \tag{2} \end{aligned} \right. {U=Rcos(δ+θ)=R(cosδcosθsinδsinθ)V=Rsin(δ+θ)=R(sinδcosθ+cosδsinθ)(2)
式(1)式(2)结合:
{U=R∗(cosδcosθ−sinδsinθ)=U′cosθ−V′sinθV=R∗(sinδcosθ+cosδsinθ)=U′sinθ+V′cosθ(3) \left\{ \begin{aligned} U = R*(cos{\delta}cos{\theta}-sin{\delta}sin{\theta})=U^{'}cos{\theta}-V^{'}sin{\theta}\\ V = R*(sin{\delta}cos{\theta}+cos{\delta}sin{\theta})=U^{'}sin{\theta}+V^{'}cos{\theta} \\ \tag{3} \end{aligned} \right. {U=R(cosδcosθsinδsinθ)=UcosθVsinθV=R(sinδcosθ+cosδsinθ)=Usinθ+Vcosθ(3)
旋转前后点的W坐标不变,那么旋转后点的坐标可表示如下:
{U=U′cosθ−V′sinθV=U′sinθ+V′cosθW=W′(4) \left\{ \begin{aligned} U & =U^{'}cos{\theta}-V^{'}sin{\theta}\\ V &= U^{'}sin{\theta}+V^{'}cos{\theta} \\ W &= W^{'} \\ \tag{4} \end{aligned} \right. UVW=UcosθVsinθ=Usinθ+Vcosθ=W(4)
将上面写为矩阵的形式:
[UVW]=[cosθ−sinθ0sinθcosθ0001][U′V′W′](5) \begin{bmatrix} U \\ V \\ W \end{bmatrix} = \begin{bmatrix} cos{\theta} & -sin{\theta} & 0 \\ sin{\theta} & cos{\theta} & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} U^{'} \\ V^{'} \\ W^{'} \tag{5} \end{bmatrix} UVW=cosθsinθ0sinθcosθ0001UVW(5)
式(5)与图坐标系图放在一起进行考虑,如下图所示:
旋转说明

矩阵的第1行为旋转正方向的起点轴,第2行为旋转正方向的终点轴,第3行为旋转轴.


按照上面说明,我们在来回退到常用的XYZ代号的坐标系中.
1.点绕Z轴旋转,那么旋转正方向是由X指向Y,因此在上面图中,将UV分别替换为X,Y,W替换为Z,可得:
[XYZ]=[cosθ−sinθ0sinθcosθ0001][X′Y′Z′](6) \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^{'} \tag{6} \end{bmatrix} XYZ=cosθsinθ0sinθcosθ0001XYZ(6)
2.点绕Y轴旋转,那么旋转正方向是由Z指向X,因此在上面图中,将UV分别替换为Z,X,W替换为Y,可得:
[ZXY]=[cosθ−sinθ0sinθcosθ0001][Z′X′Y′](7) \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^{'} \tag{7} \end{bmatrix} ZXY=cosθsinθ0sinθcosθ0001ZXY(7)
将上式展开,然后调整顺序并整理,可得:

[XYZ]=[cosθ0sinθ010−sinθ0cosθ][X′Y′Z′](8) \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^{'} \tag{8} \end{bmatrix} XYZ=cosθ0sinθ010sinθ0cosθXYZ(8)
3.点绕X轴旋转,那么旋转正方向是由Y指向Z,因此在上面图中,将UV分别替换为Y,Z,W替换为X,可得:
[YZX]=[cosθ−sinθ0sinθcosθ0001][Y′Z′X′](9) \begin{bmatrix} Y \\ Z \\ X \end{bmatrix} = \begin{bmatrix} cos{\theta} & -sin{\theta} & 0 \\ sin{\theta} & cos{\theta} & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} Y^{'} \\ Z^{'} \\ X^{'} \tag{9} \end{bmatrix} YZX=cosθsinθ0sinθcosθ0001YZX(9)
将上式展开,然后调整顺序并整理,可得:
[XYZ]=[1000cosθ−sinθ0sinθcosθ][X′Y′Z′](10) \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^{'} \tag{10} \end{bmatrix} XYZ=1000cosθsinθ0sinθcosθXYZ(10)

综上,可以方便记忆坐标系中一个点绕X,Y,Z三轴的旋转矩阵.

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐