旋转变换矩阵推导

介绍

  先介绍二维旋转变换,然后得到三维绕坐标轴旋转,再推广得到绕三维任意轴旋转的罗德里格斯旋转公式。

1.二维旋转变换

  如果要求PP逆时针旋转θ\theta得到的PP^{'},记QQPP逆时针旋转90°后的向量,即(Py,Px)(-P_y,P_x),则PPQQ正好组成了该平面内的一组正交向量,任何向量都可由其线性表出,由基本几何和三角学可得到:
P=Pcosθ+Qsinθ P^{'}=Pcos\theta+Qsin\theta


Px=PxcosθPysinθPy=PysinθPxcosθ \begin{aligned}P_x^{'}&=P_xcos\theta-P_ysin\theta\\ P_{y}^{'}&=P_ysin\theta-P_xcos\theta\\ \end{aligned}
写成矩阵为
P=[cosθsinθsinθcosθ]P P^{'}=\begin{bmatrix}cos\theta&-sin\theta\\sin\theta&cos\theta\end{bmatrix}P

2.三维旋转变换

旋转变换矩阵推导
  注意Ry(θ)R_y(\theta)与其他不同是因为如果按照逆时针旋转,由x×z=yx\times z=-y,则得到yy轴负方向,因此需改为顺时针,即θ-\theta,这无论是在左手坐标系还是右手系都是相同的。

3.向量PP绕任意轴AA旋转θ\theta角度证明:

  不妨设AA为单位向量,同时PP可分解为与AA平行和垂直的两个分量,分别为:
PprojA=(AP)A=AATPPperpA=P(AP)A=PAATP \begin{aligned}P_{projA}&=(A\cdot P)A=AA^TP\\P_{perpA}&=P-(A\cdot P)A=P-AA^TP\end{aligned}
如图所示
旋转变换矩阵推导

故最终结果
P=PperpA+PProjA P^{'}=P_{perpA}^{'}+P_{ProjA}
其中PPerpAP_{PerpA}^{'}PperpAP_{perpA}旋转θ\theta后得到的向量,如图
旋转变换矩阵推导

为求得其值,需找到一组线性组合来表示它,可选PperpAP_{perpA}与其旋转90°后的向量这两个向量作为组合,可以得知A×PA\times P即为该向量,同时它的长度是与PperpAP_{perpA}相等的,这是因为
A×P=Psinα=P(AP)A |A\times P|=|P|sin\alpha=|P-(A\cdot P)A|
所以
PperpA=[P(AP)A]cosθ+(A×P)sinθ P_{perpA}^{'}=[P-(A\cdot P)A]cos\theta+(A \times P)sin \theta
所以
P=[P(AP)A]cosθ+(A×P)sinθ+(AP)A=Pcosθ+A×Psinθ+(AP)A(1cosθ) \begin{aligned}P^{'}&=[P-(A\cdot P)A]cos\theta+(A \times P)sin \theta+(A\cdot P)A\\&=Pcos\theta+A\times P sin\theta+(A\cdot P)A(1-cos\theta)\end{aligned}
II为单位阵,则矩阵形式为
P={Icosθ+[0AzAyAz0AxAyAx0]sinθ+AAT(1cosθ)}P P^{'}=\{Icos\theta+\begin{bmatrix} 0&-A_z&A_y\\A_z&0&-A_x\\-A_y&A_x&0\end{bmatrix}sin\theta+AA^T(1-cos\theta)\}P
其中记
R=Icosθ+[0AzAyAz0AxAyAx0]sinθ+AAT(1cosθ) R=Icos\theta+\begin{bmatrix} 0&-A_z&A_y\\A_z&0&-A_x\\-A_y&A_x&0\end{bmatrix}sin\theta+AA^T(1-cos\theta)
为罗德里格斯旋转公式,而将其展开写成一个矩阵就可得到旋转矩阵。