旋转矩阵的理解

矩阵 R 12 \boldsymbol{R}_{12} R12 是旋转矩阵,其描述了坐标系1到坐标系2的旋转。矩阵 R 12 \boldsymbol{R}_{12} R12 的下标有两个含义:

  • 表示坐标系1到坐标系2的旋转
  • 表示将坐标系2中点的坐标通过旋转变换,从而得到同一个点在坐标系1中的坐标

向量 t 12 \boldsymbol{t}_{12} t12 是平移向量,其描述了坐标系1到坐标系2的平移。其下标同样也有两个含义:

  • 表示坐标系1到坐标系2的平移(对应坐标系1的原点指向坐标系2的原点的向量)
  • 表示将坐标系2中点的坐标通过平移变换,从而得到同一个点在坐标系1中的坐标

首先看一个简单的例子
在这里插入图片描述

如图1, P 0 , P 1 P_0, P_1 P0,P1是坐标系 W W W 下的两个点,其中 P 1 P_1 P1 P 0 P_0 P0 旋转 θ \theta θ (逆时针为正)而来,则二者之间的坐标满足关系:
x 1 = r ∗ cos ⁡ ( θ + θ 0 ) = r ∗ cos ⁡ ( θ ) cos ⁡ ( θ 0 ) − r ∗ sin ⁡ ( θ ) sin ⁡ ( θ 0 ) = x 0 ∗ cos ⁡ ( θ ) − y 0 ∗ sin ⁡ ( θ ) y 1 = r ∗ sin ⁡ ( θ + θ 0 ) = r ∗ sin ⁡ ( θ ) cos ⁡ ( θ 0 ) + r ∗ cos ⁡ ( θ ) sin ⁡ ( θ 0 ) = x 0 ∗ sin ⁡ ( θ ) + y 0 ∗ cos ⁡ ( θ ) \begin{aligned} x_1 &= r * \cos(\theta + \theta_0) \\ &= r * \cos(\theta)\cos(\theta_0) - r*\sin(\theta)\sin(\theta_0) \\ &= x_0 * \cos(\theta) - y_0*\sin(\theta) \\ y_1 &= r * \sin(\theta + \theta_0) \\ &= r * \sin(\theta)\cos(\theta_0) + r*\cos(\theta)\sin(\theta_0) \\ & = x_0 * \sin(\theta) + y_0*\cos(\theta) \\ \end{aligned} x1y1=rcos(θ+θ0)=rcos(θ)cos(θ0)rsin(θ)sin(θ0)=x0cos(θ)y0sin(θ)=rsin(θ+θ0)=rsin(θ)cos(θ0)+rcos(θ)sin(θ0)=x0sin(θ)+y0cos(θ)
P 1 = R P 0 P_1 = RP_0 P1=RP0, 其中
R = ( cos ⁡ ( θ ) − sin ⁡ ( θ ) sin ⁡ ( θ ) cos ⁡ ( θ ) ) R = \begin{pmatrix} \cos(\theta)& -\sin(\theta) \\ \sin(\theta)& \cos(\theta) \\ \end{pmatrix} R=(cos(θ)sin(θ)sin(θ)cos(θ))
这个比较容易理解了,不多赘述。

如图2, P 1 P_1 P1 P 0 P_0 P0 在旋转之后多了一个平移而来,则 P 0 , P 1 P_0, P_1 P0,P1 之间的关系为:
P 1 = R P 0 + t P_1 = RP_0 + t P1=RP0+t, 其中 t = ( Δ x , Δ y ) T t = (\Delta x, \Delta y)^T t=(Δx,Δy)T


现在我们换一种角度,不再将点看作普通的点,而是一个新坐标系的原点,如图3。那么如何描述从一个坐标系到另一个坐标系呢? 例如在图3中,将 W W W 坐标系转到 P 0 P_0 P0 坐标系,那么可以仿照上述两个例子写出这个变换:
R = ( cos ⁡ ( θ 0 ) − sin ⁡ ( θ 0 ) sin ⁡ ( θ 0 ) cos ⁡ ( θ 0 ) ) , t = ( x 0 y 0 ) R = \begin{pmatrix} \cos(\theta_0)& -\sin(\theta_0) \\ \sin(\theta_0)& \cos(\theta_0) \\ \end{pmatrix}, t = \begin{pmatrix} x_0 \\ y_0 \\ \end{pmatrix} R=(cos(θ0)sin(θ0)sin(θ0)cos(θ0)),t=(x0y0)

其中 ( x 0 , y 0 ) (x_0, y_0) (x0,y0) P 0 P_0 P0 坐标系原点在 W W W 坐标系下的表示, θ 0 \theta_0 θ0 是坐标系旋转的角度.
具体地, 对于 P 0 P_0 P0 坐标系描述下的一点 p ( x p , y p ) p(x_p, y_p) p(xp,yp), 其在 W W W 坐标系下的表示为
( x w y w ) = R ( x p y p ) + t \begin{pmatrix} x_w \\ y_w \\ \end{pmatrix} = R \begin{pmatrix} x_p \\ y_p \\ \end{pmatrix} + t (xwyw)=R(xpyp)+t
注意!此时我们称 T P 0 W = ( R t 0 1 ) T_{P_0}^W = \begin{pmatrix} R & t \\ 0 & 1 \\ \end{pmatrix} TP0W=(R0t1) W W W 坐标系 到 P 0 P_0 P0 坐标系的变换,它可以将 点在 P 0 P_0 P0 坐标系的表示 转为在 W W W 坐标系的表示
通常, W W W 坐标系 到 P 0 P_0 P0 坐标系的变换 称为 P P P 的位姿。


在这里插入图片描述

最后一个例子,如图4,一辆车从 P 0 P_0 P0 移动到 P 1 P_1 P1,它们也被两个时刻下的车坐标系,那么如何描述它们之间的变换呢?
显然根据上述例子,我们很容易地得到 W W W 坐标系到两个车坐标系的变换:
R R R 描述 从 W W W 转到 目标系 的 角度, t t t 是 从 W W W原点指向 目标系原点 的向量 在 W W W 系下的表示,即
R P 0 W = ( cos ⁡ θ 0 − sin ⁡ θ 0 sin ⁡ θ 0 cos ⁡ θ 0 ) , t = ( x 0 y 0 ) R P 1 W = ( cos ⁡ θ 1 − sin ⁡ θ 1 sin ⁡ θ 1 cos ⁡ θ 1 ) , t = ( x 1 y 1 ) \begin{aligned} R_{P_0}^W &= \begin{pmatrix} \cos\theta_0 & -\sin\theta_0 \\ \sin\theta_0 & \cos\theta_0 \\ \end{pmatrix}, t = \begin{pmatrix} x_0 \\ y_0 \\ \end{pmatrix} \\ R_{P_1}^W &= \begin{pmatrix} \cos\theta_1 & -\sin\theta_1 \\ \sin\theta_1 & \cos\theta_1 \\ \end{pmatrix}, t = \begin{pmatrix} x_1 \\ y_1 \\ \end{pmatrix} \\ \end{aligned} RP0WRP1W=(cosθ0sinθ0sinθ0cosθ0),t=(x0y0)=(cosθ1sinθ1sinθ1cosθ1),t=(x1y1)

  • 坐标系变换的角度来看, P 0 P_0 P0 P 1 P_1 P1 的变换等同于 P 0 P_0 P0 W W W,再从 W W W P 1 P_1 P1, 即
    T P 1 P 0 = ( T P 0 W ) T T P 1 W T_{P_1}^{P_0} = \begin{pmatrix} T_{P_0}^{W} \end{pmatrix}^T T_{P_1}^{W} TP1P0=(TP0W)TTP1W
    具体地,我们也可以直接根据规则直接写出二者之间的变换,令 θ = θ 1 − θ 0 \theta = \theta_1 - \theta_0 θ=θ1θ0,
    R P 1 P 0 = ( cos ⁡ θ − sin ⁡ θ sin ⁡ θ sin ⁡ θ ) t P 1 P 0 = ( R P 0 W ) T ( t P 1 W − t P 0 W ) \begin{aligned} R_{P_1}^{P_0} &= \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \sin\theta \\ \end{pmatrix} \\ t_{P_1}^{P_0} &= \begin{pmatrix} R_{P_0}^W \end{pmatrix}^T (t_{P_1}^W - t_{P_0}^W) \end{aligned} RP1P0tP1P0=(cosθsinθsinθsinθ)=(RP0W)T(tP1WtP0W)
  • 坐标点转换来看,上述变换又可解释为 将 点在 P 1 P_1 P1坐标系下的表示 转到 点在 P 0 P_0 P0坐标系的表示,即
    p 0 = T P 1 P 0 p 1 = ( T P 0 W ) T T P 1 W p 1 p_0 = T_{P_1}^{P_0} p_1 = \begin{pmatrix} T_{P_0}^{W} \end{pmatrix}^T T_{P_1}^{W} p_1 p0=TP1P0p1=(TP0W)TTP1Wp1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值