【机器人学】绕空间任意轴的旋转矩阵推导

注意:文中推导过程基于右手定则

用单位向量 n \textbf{n} n 描述旋转轴,用 θ \theta θ 描述旋转角度。我们希望推导出满足 v R ( n , θ ) = v’ \textbf{v}R(n,\theta)=\textbf{v'} vR(n,θ)=v’ 的矩阵 R ( n , θ ) R(\textbf{n},\theta) R(n,θ)

向量 v’ \textbf{v'} v’是向量 v \textbf{v} v绕轴 n \textbf{n} n旋转后的向量。将 v \textbf{v} v分解成两个向量, v ⊥ \textbf{v}_⊥ v v ∥ \textbf{v}_∥ v,分别垂直于 n \textbf{n} n和平行于 n \textbf{n} n,并有 v = v ∥ + v ⊥ \textbf{v}=\textbf{v}_∥+\textbf{v}_⊥ v=v+v。因为 v ∥ \textbf{v}_∥ v平行于 n \textbf{n} n,所以绕 n \textbf{n} n旋转不会影响它。故只要计算出 v ⊥ \textbf{v}_⊥ v n \textbf{n} n旋转后的 v’ ⊥ \textbf{v'}_⊥ v’。就能得到 v’ = v ∥ + v’ ⊥ \textbf{v'}=\textbf{v}_∥+\textbf{v'}_⊥ v’=v+v’

视线正对 n \textbf{n} n的正方向,与向量 n \textbf{n} n垂直的平面上的向量如下图所示:

上图两幅图中包含以下向量:

  • v ∥ \textbf{v}_∥ v v \textbf{v} v平行于 n \textbf{n} n的向量,可以表示为 v ∥ = ∣ v ∣ c o s < v , v ∥ > n = ( v ⋅ n ) n \textbf{v}_∥=|\textbf{v}|cos<\textbf{v},\textbf{v}_∥>\textbf{n}=(\textbf{v}\cdot \textbf{n})\textbf{n} v=vcos<v,v>n=(vn)n
  • v ⊥ \textbf{v}_⊥ v v \textbf{v} v垂直于 n \textbf{n} n的向量。因为 v = v ∥ + v ⊥ \textbf{v}=\textbf{v}_∥+\textbf{v}_⊥ v=v+v,所以 v ⊥ = v − v ∥ \textbf{v}_⊥=\textbf{v}-\textbf{v}_∥ v=vv v ⊥ \textbf{v}_⊥ v v \textbf{v} v投影到垂直于 n \textbf{n} n的平面上的结果。
  • w \textbf{w} w是同时垂直于 v ∥ \textbf{v}_∥ v v ⊥ \textbf{v}_⊥ v的向量。它的长度和 v ⊥ \textbf{v}_⊥ v相同。 w \textbf{w} w v ⊥ \textbf{v}_⊥ v同在垂直于 n \textbf{n} n的平面中。 w \textbf{w} w v ⊥ \textbf{v}_⊥ v n \textbf{n} n旋转90°的结果,由 n × v ⊥ \textbf{n}×\textbf{v}_⊥ n×v可以得到。
  • v’ \textbf{v'} v’垂直于 n \textbf{n} n的分量 v’ ⊥ \textbf{v'}_⊥ v’可以表示为:
    v’ ⊥ = v ⊥ c o s θ + w s i n θ = ( v − v ∥ ) c o s θ + ( n × v ⊥ ) s i n θ = ( v − v ∥ ) c o s θ + ( n × ( v − v ∥ ) ) s i n θ = ( v − ( v ⋅ n ) n ) c o s θ + ( n × ( v − ( v ⋅ n ) n ) ) s i n θ = ( v − ( v ⋅ n ) n ) c o s θ + ( n × v ) s i n θ \begin{aligned} \textbf{v'}_⊥&=\textbf{v}_⊥cos\theta+\textbf{w}sin\theta\\ &=(\textbf{v}-\textbf{v}_∥)cos\theta+(\textbf{n}×\textbf{v}_⊥)sin\theta\\ &=(\textbf{v}-\textbf{v}_∥)cos\theta+(\textbf{n}×(\textbf{v}-\textbf{v}_∥))sin\theta\\ &=(\textbf{v}-(\textbf{v}\cdot \textbf{n})\textbf{n})cos\theta+(\textbf{n}×(\textbf{v}-(\textbf{v}\cdot \textbf{n})\textbf{n}))sin\theta\\ &=(\textbf{v}-(\textbf{v}\cdot \textbf{n})\textbf{n})cos\theta+(\textbf{n}×\textbf{v})sin\theta\\ \end{aligned} v’=vcosθ+wsinθ=(vv)cosθ+(n×v)sinθ=(vv)cosθ+(n×(vv))sinθ=(v(vn)n)cosθ+(n×(v(vn)n))sinθ=(v(vn)n)cosθ+(n×v)sinθ
    v’ \textbf{v'} v’ 做如下替换和推导:
    v’ = v ∥ + v’ ⊥ = ( v ⋅ n ) n + ( v − ( v ⋅ n ) n ) c o s θ + ( n × v ) s i n θ \begin{aligned} \textbf{v'}&=\textbf{v}_∥+\textbf{v'}_⊥=(\textbf{v}\cdot \textbf{n})\textbf{n}+(\textbf{v}-(\textbf{v}\cdot \textbf{n})\textbf{n})cos\theta+(\textbf{n}×\textbf{v})sin\theta\\ \end{aligned} v’=v+v’=(vn)n+(v(vn)n)cosθ+(n×v)sinθ
    ① 令 v = [ 1 0 0 ] \textbf{v}=\begin{bmatrix} 1 \\ 0\\0\end{bmatrix} v=100,带入上式:
    v’ = ( [ 1 0 0 ] ⋅ [ n x n y n z ] ) [ n x n y n z ] + ( [ 1 0 0 ] − ( [ 1 0 0 ] ⋅ [ n x n y n z ] ) [ n x n y n z ] ) c o s θ + ( [ n x n y n z ] × [ 1 0 0 ] ) s i n θ = [ n x 2 n x n y n x n z ] + [ 1 − n x 2 − n x n y − n x n z ] c o s θ + [ 0 n z − n y ] s i n θ = [ ( 1 − n x 2 ) c o s θ + n x 2 − n x n y c o s θ + n z s i n θ + n x n y − n x n z c o s θ − n y s i n θ + n x n z ] = [ ( 1 − c o s θ ) n x 2 + c o s θ ( 1 − c o s θ ) n x n y + n z s i n θ ( 1 − c o s θ ) n x n z − n y s i n θ ] \begin{aligned} \textbf{v'}&=\left( \begin{bmatrix} 1 \\ 0\\0\end{bmatrix} \cdot \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} \right)\begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix}+\left( \begin{bmatrix} 1 \\ 0\\0\end{bmatrix} - \left( \begin{bmatrix} 1 \\ 0\\0\end{bmatrix} \cdot \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix}\right) \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} \right)cos\theta + \left( \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} × \begin{bmatrix} 1 \\ 0\\0\end{bmatrix} \right)sin\theta\\ &= \begin{bmatrix} n_x^2 \\n_xn_y\\n_xn_z\end{bmatrix} + \begin{bmatrix} 1-n_x^2 \\-n_xn_y\\-n_xn_z\end{bmatrix}cos\theta + \begin{bmatrix}0\\ n_z \\-n_y\end{bmatrix}sin\theta\\ &= \begin{bmatrix} (1-n_x^2)cos\theta+n_x^2\\-n_xn_ycos\theta+n_zsin\theta+n_xn_y\\-n_xn_zcos\theta-n_ysin\theta+n_xn_z\end{bmatrix}\\ &= \begin{bmatrix} (1-cos\theta)n_x^2+cos\theta\\(1-cos\theta)n_xn_y+n_zsin\theta\\(1-cos\theta)n_xn_z-n_ysin\theta\end{bmatrix} \end{aligned} v’=100nxnynznxnynz+100100nxnynznxnynzcosθ+nxnynz×100sinθ=nx2nxnynxnz+1nx2nxnynxnzcosθ+0nznysinθ=(1nx2)cosθ+nx2nxnycosθ+nzsinθ+nxnynxnzcosθnysinθ+nxnz=(1cosθ)nx2+cosθ(1cosθ)nxny+nzsinθ(1cosθ)nxnznysinθ

② 令 v = [ 0 1 0 ] \textbf{v}=\begin{bmatrix} 0 \\ 1\\0\end{bmatrix} v=010,带入上式:
v’ = ( [ 0 1 0 ] ⋅ [ n x n y n z ] ) [ n x n y n z ] + ( [ 0 1 0 ] − ( [ 0 1 0 ] ⋅ [ n x n y n z ] ) [ n x n y n z ] ) c o s θ + ( [ n x n y n z ] × [ 0 1 0 ] ) s i n θ = [ n x n y n y 2 n y n z ] + [ − n x n y 1 − n y 2 − n y n z ] c o s θ + [ − n z 0 n x ] s i n θ = [ − n x n y c o s θ − n z s i n θ + n x n y ( 1 − n y 2 ) c o s θ + n y 2 − n y n z c o s θ + n x s i n θ + n y n z ] = [ ( 1 − c o s θ ) n x n y − n z s i n θ ( 1 − c o s θ ) n y 2 + c o s θ ( 1 − c o s θ ) n y n z + n x s i n θ ] \begin{aligned} \textbf{v'}&=\left( \begin{bmatrix} 0 \\ 1\\0\end{bmatrix} \cdot \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} \right)\begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix}+\left( \begin{bmatrix} 0 \\ 1\\0\end{bmatrix} - \left( \begin{bmatrix} 0 \\ 1\\0\end{bmatrix} \cdot \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix}\right) \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} \right)cos\theta + \left( \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} × \begin{bmatrix} 0 \\ 1\\0\end{bmatrix} \right)sin\theta\\ &= \begin{bmatrix} n_xn_y \\n_y^2\\n_yn_z\end{bmatrix} + \begin{bmatrix} -n_xn_y \\1-n_y^2\\-n_yn_z\end{bmatrix}cos\theta + \begin{bmatrix} -n_z \\0\\n_x\end{bmatrix}sin\theta\\ &= \begin{bmatrix} -n_xn_ycos\theta-n_zsin\theta+n_xn_y\\(1-n_y^2)cos\theta+n_y^2\\-n_yn_zcos\theta+n_xsin\theta+n_yn_z\\\end{bmatrix}\\ &= \begin{bmatrix} (1-cos\theta)n_xn_y-n_zsin\theta\\(1-cos\theta)n_y^2+cos\theta\\(1-cos\theta)n_yn_z+n_xsin\theta\end{bmatrix} \end{aligned} v’=010nxnynznxnynz+010010nxnynznxnynzcosθ+nxnynz×010sinθ=nxnyny2nynz+nxny1ny2nynzcosθ+nz0nxsinθ=nxnycosθnzsinθ+nxny(1ny2)cosθ+ny2nynzcosθ+nxsinθ+nynz=(1cosθ)nxnynzsinθ(1cosθ)ny2+cosθ(1cosθ)nynz+nxsinθ

③ 令 v = [ 0 0 1 ] \textbf{v}=\begin{bmatrix} 0 \\ 0\\1\end{bmatrix} v=001,带入上式:
v’ = ( [ 0 0 1 ] ⋅ [ n x n y n z ] ) [ n x n y n z ] + ( [ 0 0 1 ] − ( [ 0 0 1 ] ⋅ [ n x n y n z ] ) [ n x n y n z ] ) c o s θ + ( [ n x n y n z ] × [ 0 0 1 ] ) s i n θ = [ n x n z n y n z n z 2 ] + [ − n x n z − n y n z 1 − n z 2 ] c o s θ + [ n y − n x 0 ] s i n θ = [ − n x n z c o s θ + n y s i n θ + n x n z − n y n z c o s θ − n x s i n θ + n y n z ( 1 − n z 2 ) c o s θ + n z 2 ] = [ ( 1 − c o s θ ) n x n z + n y s i n θ ( 1 − c o s θ ) n y n z − n x s i n θ ( 1 − c o s θ ) n z 2 + c o s θ ] \begin{aligned} \textbf{v'}&=\left( \begin{bmatrix} 0 \\ 0\\1\end{bmatrix} \cdot \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} \right)\begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix}+\left( \begin{bmatrix} 0 \\ 0\\1\end{bmatrix} - \left( \begin{bmatrix} 0 \\ 0\\1\end{bmatrix} \cdot \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix}\right) \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} \right)cos\theta + \left( \begin{bmatrix} n_x \\n_y\\n_z\end{bmatrix} × \begin{bmatrix} 0 \\ 0\\1\end{bmatrix} \right)sin\theta\\ &= \begin{bmatrix} n_xn_z \\n_yn_z\\n_z^2\end{bmatrix} + \begin{bmatrix} -n_xn_z \\-n_yn_z\\1-n_z^2\end{bmatrix}cos\theta + \begin{bmatrix} n_y \\-n_x\\0\end{bmatrix}sin\theta\\ &= \begin{bmatrix} -n_xn_zcos\theta+n_ysin\theta+n_xn_z\\-n_yn_zcos\theta-n_xsin\theta+n_yn_z\\(1-n_z^2)cos\theta+n_z^2\end{bmatrix}\\ &= \begin{bmatrix} (1-cos\theta)n_xn_z+n_ysin\theta\\(1-cos\theta)n_yn_z-n_xsin\theta\\(1-cos\theta)n_z^2+cos\theta\end{bmatrix} \end{aligned} v’=001nxnynznxnynz+001001nxnynznxnynzcosθ+nxnynz×001sinθ=nxnznynznz2+nxnznynz1nz2cosθ+nynx0sinθ=nxnzcosθ+nysinθ+nxnznynzcosθnxsinθ+nynz(1nz2)cosθ+nz2=(1cosθ)nxnz+nysinθ(1cosθ)nynznxsinθ(1cosθ)nz2+cosθ

综上可得到绕空间任意轴旋转的转换矩阵为:
R ( n , θ ) = [ ( 1 − c o s θ ) n x 2 + c o s θ ( 1 − c o s θ ) n x n y − n z s i n θ ( 1 − c o s θ ) n x n z + n y s i n θ ( 1 − c o s θ ) n x n y + n z s i n θ ( 1 − c o s θ ) n y 2 + c o s θ ( 1 − c o s θ ) n y n z − n x s i n θ ( 1 − c o s θ ) n x n z − n y s i n θ ( 1 − c o s θ ) n y n z + n x s i n θ ( 1 − c o s θ ) n z 2 + c o s θ ] \textbf{R}(\textbf{n},\theta)=\begin{bmatrix} (1-cos\theta)n_x^2+cos\theta & (1-cos\theta)n_xn_y-n_zsin\theta & (1-cos\theta)n_xn_z+n_ysin\theta\\ (1-cos\theta)n_xn_y+n_zsin\theta & (1-cos\theta)n_y^2+cos\theta & (1-cos\theta)n_yn_z-n_xsin\theta\\ (1-cos\theta)n_xn_z-n_ysin\theta & (1-cos\theta)n_yn_z+n_xsin\theta & (1-cos\theta)n_z^2+cos\theta\\ \end{bmatrix} R(n,θ)=(1cosθ)nx2+cosθ(1cosθ)nxny+nzsinθ(1cosθ)nxnznysinθ(1cosθ)nxnynzsinθ(1cosθ)ny2+cosθ(1cosθ)nynz+nxsinθ(1cosθ)nxnz+nysinθ(1cosθ)nynznxsinθ(1cosθ)nz2+cosθ

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值