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

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

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

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

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

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

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

{ U ′ = R ∗ c o s δ V ′ = R ∗ s i n δ (1) \left\{ \begin{aligned} U^{'} = R*cos\delta \\ V^{'} = R*sin\delta \\ \tag{1} \end{aligned} \right. {U=RcosδV=Rsinδ(1)
{ U = R ∗ c o s ( δ + θ ) = R ∗ ( c o s δ c o s θ − s i n δ s i n θ ) V = R ∗ s i n ( δ + θ ) = R ∗ ( s i n δ c o s θ + c o s δ s i n θ ) (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 ∗ ( c o s δ c o s θ − s i n δ s i n θ ) = U ′ c o s θ − V ′ s i n θ V = R ∗ ( s i n δ c o s θ + c o s δ s i n θ ) = U ′ s i n θ + V ′ c o s θ (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 ′ c o s θ − V ′ s i n θ V = U ′ s i n θ + V ′ c o s θ 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)
将上面写为矩阵的形式:
[ U V W ] = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] [ 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,可得:
[ X Y Z ] = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] [ 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,可得:
[ Z X Y ] = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] [ 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)
将上式展开,然后调整顺序并整理,可得:

[ X Y Z ] = [ c o s θ 0 s i n θ 0 1 0 − s i n θ 0 c o s θ ] [ 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,可得:
[ Y Z X ] = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] [ 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)
将上式展开,然后调整顺序并整理,可得:
[ X Y Z ] = [ 1 0 0 0 c o s θ − s i n θ 0 s i n θ c o s θ ] [ 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三轴的旋转矩阵.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值