1 以原点为中心的旋转矩阵推导
为了推导绕任意中心位置旋转的旋转矩阵,可以先从简单绕原点旋转开始推导。
假设有点 P ( x a , x b ) P(x_a,x_b) P(xa,xb),绕原点顺时针旋转了 θ \theta θ度后,求其旋转矩阵 T \boldsymbol{T} T(图1)。
P绕原点顺时针旋转 θ \theta θ,可以看成是坐标轴逆时针旋转旋转 θ \theta θ,求P点在新坐标轴上的坐标(图2)。
由上图可知, O P A → = [ x a y a ] , O P B → = [ x b y b ] \overrightarrow{OP_A}=\left[\begin{matrix}x_a \\ y_a\end{matrix} \right],\overrightarrow{OP_B}=\left[\begin{matrix}x_b \\ y_b\end{matrix} \right] OPA=[xaya],OPB=[xbyb],所求的便是 O P A → = T O P B → \overrightarrow{OP_A}=\boldsymbol{T}\overrightarrow{OP_B} OPA=TOPB中的变换矩阵 T \boldsymbol{T} T。
在图中作辅助线如下图(图3),可以知道
∠ A O B = ∠ A P D = θ O B = O A c o s θ B C = A D = A P s i n θ \angle AOB = \angle APD = \theta \\ OB=OAcos\theta\\ BC = AD = APsin\theta \\ ∠AOB=∠APD=θOB=OAcosθBC=AD=APsinθ
即
x b = O B + O C = x a c o s θ + y a s i n θ x_b = OB+OC = x_acos\theta + y_asin\theta xb=OB+OC=xacosθ+yasinθ
同理可得
y b = − x a s i n θ + y a c o s θ y_b=-x_asin\theta + y_acos\theta yb=−xasinθ+yacosθ
转化为矩阵形式为
[ x b y b ] = [ c o s θ s i n θ − s i n θ c o s θ ] [ x a y a ] T = [ c o s θ s i n θ − s i n θ c o s θ ] \left[\begin{matrix}x_b \\ y_b\end{matrix} \right]=\left[\begin{matrix} cos\theta &sin\theta\\ -sin\theta&cos\theta \end{matrix}\right]\left[\begin{matrix}x_a \\ y_a\end{matrix} \right]\\ \boldsymbol{T}= \left[\begin{matrix} cos\theta &sin\theta\\ -sin\theta&cos\theta \end{matrix}\right] [xbyb]=[cosθ−sinθsinθcosθ