姿态变换(一)——旋转矩阵

tech2022-08-26  113

文章目录

一、二维旋转矩阵1.向量绕原点旋转2.坐标轴绕原点旋转 二、三维旋转矩阵1.坐标轴绕z轴旋转2.坐标轴绕y轴旋转3.坐标轴绕x轴旋转4.向量绕某一坐标轴旋转

一、二维旋转矩阵

1.向量绕原点旋转

在二维坐标系xoy中,存在一个向量a=[x,y],将其绕原点O逆时针旋转 θ \theta θ角度,定义逆时针旋转为正,得到新的向量a’=[x’,y’],如图所示。 设向量a的长度为r,则容易得到a的坐标为 [ x y ] = r [ cos ⁡ λ sin ⁡ λ ] \begin{bmatrix} x \\ y \\ \end{bmatrix} = r \begin{bmatrix} \cos\lambda \\ \sin\lambda \end{bmatrix} [xy]=r[cosλsinλ] 向量a’的长度同样为r,可以得到a’的坐标为 [ x ′ y ′ ] = r [ cos ⁡ ( λ + θ ) sin ⁡ ( λ + θ ) ] = r [ cos ⁡ λ cos ⁡ θ − sin ⁡ λ sin ⁡ θ sin ⁡ λ cos ⁡ θ + cos ⁡ λ sin ⁡ θ ] = [ x cos ⁡ θ − y sin ⁡ θ y cos ⁡ θ + x sin ⁡ θ ] = [ cos ⁡ θ − sin ⁡ θ sin ⁡ θ cos ⁡ θ ] [ x y ] \begin{bmatrix} x' \\ y' \end{bmatrix} = r \begin{bmatrix} \cos(\lambda + \theta) \\ \sin(\lambda + \theta) \end{bmatrix} = r \begin{bmatrix} \cos\lambda\cos\theta-\sin\lambda\sin\theta \\ \sin\lambda\cos\theta+\cos\lambda\sin\theta \end{bmatrix} = \begin{bmatrix} x\cos\theta-y\sin\theta \\ y\cos\theta+x\sin\theta \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} [xy]=r[cos(λ+θ)sin(λ+θ)]=r[cosλcosθsinλsinθsinλcosθ+cosλsinθ]=[xcosθysinθycosθ+xsinθ]=[cosθsinθsinθcosθ][xy] 所以可以得到旋转矩阵为 C n b = [ cos ⁡ θ − sin ⁡ θ sin ⁡ θ cos ⁡ θ ] C_{n}^{b} = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} Cnb=[cosθsinθsinθcosθ]

2.坐标轴绕原点旋转

和向量的旋转不同的是,坐标轴的旋转是将坐标轴xoy绕原点O进行旋转,向量保持不动。将坐标轴xoy绕原点O逆时针旋转 θ \theta θ角度,定义逆时针旋转为正,得到一个新的坐标系x’oy’,如图所示。

向量a在坐标系xoy中的坐标为 [ x y ] = r [ cos ⁡ λ sin ⁡ λ ] \begin{bmatrix} x \\ y \\ \end{bmatrix} = r \begin{bmatrix} \cos\lambda \\ \sin\lambda \end{bmatrix} [xy]=r[cosλsinλ] 根据几何关系可以得到向量a’的坐标为 { x ′ = x cos ⁡ θ + y sin ⁡ θ y ′ = y cos ⁡ θ − x sin ⁡ θ \begin{cases} x' = x \cos\theta + y \sin\theta \\ y' = y \cos\theta - x \sin\theta \end{cases} {x=xcosθ+ysinθy=ycosθxsinθ 整理成矩阵形式可以得到 [ x ′ y ′ ] = [ cos ⁡ θ sin ⁡ θ − sin ⁡ θ cos ⁡ θ ] [ x y ] \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta& \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} [xy]=[cosθsinθsinθcosθ][xy] 可以得到旋转矩阵为 C b n = [ cos ⁡ θ sin ⁡ θ − sin ⁡ θ cos ⁡ θ ] C_b^{n}= \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta& \cos\theta \end{bmatrix} Cbn=[cosθsinθsinθcosθ] 我们对比一下向量旋转矩阵 C n b C_n^{b} Cnb和坐标轴旋转矩阵 C b n C_b^{n} Cbn,可以看到 C n b = ( C b n ) T C_n^{b}=(C_b^{n})^{T} Cnb=(Cbn)T,向量旋转矩阵和坐标轴旋转矩阵刚好为转置的关系。因为将向量a逆时针旋转 θ \theta θ角度,相当于将坐标轴顺时针旋转 − θ -\theta θ角度,将 − θ -\theta θ带入 C b n C_b^{n} Cbn中便可以得到 C n b C_n^b Cnb

二、三维旋转矩阵

1.坐标轴绕z轴旋转

定义坐标系Oxyz满足右手系,存在一个向量a的坐标为 [ x y z ] T \begin{bmatrix} x & y & z \end{bmatrix}^T [xyz]T,将坐标轴Oxyz绕z轴逆时针旋转 θ \theta θ角度,定义右手拇指指向z轴正方向,四指弯曲指向方向为正方向,得到新的坐标系Ox’y’z’,向量a在新坐标系Ox’y’z’下的坐标为 [ x ′ y ′ z ′ ] T \begin{bmatrix} x' & y' & z' \end{bmatrix}^T [xyz]T,如图所示。

坐标轴绕z轴旋转,向量a在z轴上的坐标不变,x轴和y轴上的坐标和二维旋转中的坐标轴旋转相同,所以容易得到向量a在新坐标系Ox’y’z’下的坐标为 [ x ′ y ′ z ′ ] = [ cos ⁡ θ sin ⁡ θ 0 − sin ⁡ θ cos ⁡ θ 0 0 0 1 ] [ x y z ] \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 \end{bmatrix} xyz=cosθsinθ0sinθcosθ0001xyz 所以绕z轴旋转的旋转矩阵为 C z = [ cos ⁡ θ sin ⁡ θ 0 − sin ⁡ θ cos ⁡ θ 0 0 0 1 ] C_z = \begin{bmatrix} \cos\theta & \sin\theta & 0 \\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} Cz=cosθsinθ0sinθcosθ0001

2.坐标轴绕y轴旋转

和绕z轴旋转相似,定义右手拇指指向y轴正方向,四指弯曲指向方向为正方向。几何推导关系和绕z轴旋转相似,不再进行推导,直接给出旋转矩阵如下 C y = [ cos ⁡ θ 0 − sin ⁡ θ 0 1 0 sin ⁡ θ 0 cos ⁡ θ ] C_y = \begin{bmatrix} \cos\theta & 0 & -\sin\theta \\ 0 & 1 & 0 \\ \sin\theta & 0 & \cos\theta \\ \end{bmatrix} Cy=cosθ0sinθ010sinθ0cosθ

3.坐标轴绕x轴旋转

定义右手拇指指向x轴正方向,四指弯曲指向方向为方向。旋转矩阵为 C x = [ 1 0 0 0 cos ⁡ θ sin ⁡ θ 0 − sin ⁡ θ cos ⁡ θ ] C_x = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos\theta & \sin\theta \\ 0 & -\sin\theta & \cos\theta \\ \end{bmatrix} Cx=1000cosθsinθ0sinθcosθ

4.向量绕某一坐标轴旋转

向量的旋转和二维坐标系中的向量旋转相似,绕某一个坐标轴进行旋转时,相当于坐标轴进行反方向的旋转,所以只需要将旋转的角度取负值代入对应的坐标轴旋转矩阵即可。

注:欢迎转载,转载请注明出处,谢谢!!!

最新回复(0)