介绍
先介绍二维旋转变换,然后得到三维绕坐标轴旋转,再推广得到绕三维任意轴旋转的罗德里格斯旋转公式。
1.二维旋转变换
如果要求PPP逆时针旋转θ\thetaθ得到的P′P^{'}P′,记QQQ为PPP逆时针旋转90°后的向量,即(−Py,Px)(-P_y,P_x)(−Py,Px),则PPP与QQQ正好组成了该平面内的一组正交向量,任何向量都可由其线性表出,由基本几何和三角学可得到:
P′=Pcosθ+Qsinθ
P^{'}=Pcos\theta+Qsin\theta
P′=Pcosθ+Qsinθ
则
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}
Px′Py′=Pxcosθ−Pysinθ=Pysinθ−Pxcosθ
写成矩阵为
P′=[cosθ−sinθsinθcosθ]P
P^{'}=\begin{bmatrix}cos\theta&-sin\theta\\sin\theta&cos\theta\end{bmatrix}P
P′=[cosθsinθ−sinθcosθ]P
2.三维旋转变换
注意Ry(θ)R_y(\theta)Ry(θ)与其他不同是因为如果按照逆时针旋转,由x×z=−yx\times z=-yx×z=−y,则得到yyy轴负方向,因此需改为顺时针,即−θ-\theta−θ,这无论是在左手坐标系还是右手系都是相同的。
3.向量PPP绕任意轴AAA旋转θ\thetaθ角度证明:
不妨设AAA为单位向量,同时PPP可分解为与AAA平行和垂直的两个分量,分别为:
PprojA=(A⋅P)A=AATPPperpA=P−(A⋅P)A=P−AATP
\begin{aligned}P_{projA}&=(A\cdot P)A=AA^TP\\P_{perpA}&=P-(A\cdot P)A=P-AA^TP\end{aligned}
PprojAPperpA=(A⋅P)A=AATP=P−(A⋅P)A=P−AATP
如图所示
故最终结果
P′=PperpA′+PProjA
P^{'}=P_{perpA}^{'}+P_{ProjA}
P′=PperpA′+PProjA
其中PPerpA′P_{PerpA}^{'}PPerpA′为PperpAP_{perpA}PperpA旋转θ\thetaθ后得到的向量,如图
为求得其值,需找到一组线性组合来表示它,可选PperpAP_{perpA}PperpA与其旋转90°后的向量这两个向量作为组合,可以得知A×PA\times PA×P即为该向量,同时它的长度是与PperpAP_{perpA}PperpA相等的,这是因为
∣A×P∣=∣P∣sinα=∣P−(A⋅P)A∣
|A\times P|=|P|sin\alpha=|P-(A\cdot P)A|
∣A×P∣=∣P∣sinα=∣P−(A⋅P)A∣
所以
PperpA′=[P−(A⋅P)A]cosθ+(A×P)sinθ
P_{perpA}^{'}=[P-(A\cdot P)A]cos\theta+(A \times P)sin \theta
PperpA′=[P−(A⋅P)A]cosθ+(A×P)sinθ
所以
P′=[P−(A⋅P)A]cosθ+(A×P)sinθ+(A⋅P)A=Pcosθ+A×Psinθ+(A⋅P)A(1−cosθ)
\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}
P′=[P−(A⋅P)A]cosθ+(A×P)sinθ+(A⋅P)A=Pcosθ+A×Psinθ+(A⋅P)A(1−cosθ)
记III为单位阵,则矩阵形式为
P′={Icosθ+[0−AzAyAz0−Ax−AyAx0]sinθ+AAT(1−cosθ)}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
P′={Icosθ+⎣⎡0Az−Ay−Az0AxAy−Ax0⎦⎤sinθ+AAT(1−cosθ)}P
其中记
R=Icosθ+[0−AzAyAz0−Ax−AyAx0]sinθ+AAT(1−cosθ)
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)
R=Icosθ+⎣⎡0Az−Ay−Az0AxAy−Ax0⎦⎤sinθ+AAT(1−cosθ)
为罗德里格斯旋转公式,而将其展开写成一个矩阵就可得到旋转矩阵。