坐标系旋转变换,内旋,外旋

从一个坐标系到另一个坐标系的转换有多种方法:欧拉角法、方向余弦矩阵法、四元数法等。
其中欧拉角法的核心思想是:一个坐标系可以用另一个参考坐标系的三次空间旋转来表达。旋转坐标系的方法又有两种:

  • Proper Euler angles, 第一次与第三次旋转相同的坐标轴(z-x-z,x-y-x, y-z-y,z-y-z, x-z-x, y-x-y)。
  • Tait–Bryan angles, 依次旋转三个不同的坐标轴(x-y-z,y-z-x, z-x-y,x-z-y, z-y-x, y-x-z);
    Tait–Bryan angles are 也叫作 Cardan angles; nautical angles; heading, elevation, and bank; or yaw, pitch, and roll. 有时候这两种变换序列都叫做 "Euler angles". 这种情况下,前者叫做 proper or classic Euler angles.

对于每个旋转序列,又有内旋(intrinsic rotations)和外旋(extrinsic rotations)两种方式。设有两个坐标系 \(OX_iY_iZ_i\)\(OX_jY_jZ_j\)\(OX_iY_iZ_i\) 是固定不动的参考系,\(OX_jY_jZ_j\) 是需要被旋转的坐标系,初始时两个坐标系重合。内旋指每次旋转的旋转轴都是上次变换后新系 \(OX_jY_jZ_j\) 的坐标轴,外旋指每次旋转的旋转轴都是固定参考系 \(OX_iY_iZ_i​\) 的坐标轴。

1. 旋转矩阵

1.1 方向余弦矩阵

设有两个共原点的右手坐标系 \(OX_iY_iZ_i\)\(OX_jY_jZ_j\) ,空间有一点 P,该点在 \(i, j\) 坐标系内的坐标分别为

\[[x_i \quad y_i \quad z_i]^T \]

\[[x_j \quad y_j \quad z_j]^T \]

P点从 \(j\) 系变换到 \(i\) 系的坐标变换关系为( \(j\) 坐标系下各坐标轴分量投影到 \(i\) 坐标轴的矢量和):

\[\left\{ \begin{array}{l} x_i = x_j \cos(x_i,x_j) + y_j \cos(x_i,y_j) + z_j \cos(x_i, z_j) \\ y_i = x_j \cos(y_i,x_j) + y_j \cos(y_i,y_j) + z_j \cos(y_i, z_j) \\ z_i = x_j \cos(z_i,x_j) + y_j \cos(z_i,y_j) + z_j \cos(z_i, z_j) \end{array} \right. \tag{1-1} \]

\[[r]_i = [^iR_j][r]_j \tag{1-2} \]

\[[^iR_j] = \left\{ \begin{array}{l} \cos(x_i,x_j) & \cos(x_i,y_j) & \cos(x_i,z_j) \\ \cos(y_i,x_j) & \cos(y_i,y_j) & \cos(y_i,z_j) \\ \cos(z_i,x_j) & \cos(z_i,y_j) & \cos(z_i,z_j) \end{array} \right\} \tag{1-3} \]

即为一般形式的旋转矩阵,也称为从 \(j​\) 系向 \(i​\) 系变换的旋转矩阵。对 \(i​\) 系来说,\([^iR_j]​\) 描述了 \(j​\) 系的姿态,故也称其为姿态矩阵,又因 \([^iR_j]​\) 内各元素皆为坐标轴之间的方向余弦,所以也可称其为方向余弦矩阵,也可用 \([^iC_j]​\) 表示。

当两个坐标系无相对旋转时,\([^iR_j] = [I]\)

若取 \(j\) 系为参考系,则 P 点从 \(i\) 系到 \(j\) 系的坐标变换关系为:

\[[r]_j = [^jR_i][r]_i \tag{1-4} \]

旋转矩阵为正交阵

\[[^jR_i] = \left\{ \begin{array}{l} \cos(x_j,x_i) & \cos(x_j,y_i) & \cos(x_j,z_i) \\ \cos(y_j,x_i) & \cos(y_j,y_i) & \cos(y_j,z_i) \\ \cos(z_j,x_i) & \cos(z_j,y_i) & \cos(z_j,z_i) \end{array} \right\} \tag{1-5} \]

\[[r]_j = [^iR_j]^{-1}[r]_i = [^jR_i][r]_i \]

\[[^jR_i] = [^iR_j]^{-1} = [^iR_j]^T \]

1.2 绕一个坐标轴旋转的旋转矩阵

\(X, Y, Z\) 坐标轴的旋转变换矩阵是最基本的旋转矩阵,他们是一般旋转矩阵的特例,故可直接由一般旋转矩阵得到。

由式 \((1-3)\) 可得到绕 \(X\) 轴旋转 \(\theta\) 角的旋转矩阵为:

\[[^iR_j(X,\theta)] = \left[ \begin{matrix} 1 & 0 & 0 \\ 0 & \cos\theta & -\sin\theta \\ 0 & \sin\theta & \cos\theta \end{matrix} \right] \tag{1-6} \]

\[[^iR_j(Y,\theta)] = \left[ \begin{matrix} \cos\theta & 0 & \sin\theta \\ 0 & 1 & 0 \\ -\sin\theta & 0 & \cos\theta \end{matrix} \right] \tag{1-7} \]

\[[^iR_j(Z,\theta)] = \left[ \begin{matrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{matrix} \right] \tag{1-8} \]

上述三个特例,可用图形直观地推导出来,见

https://www.cnblogs.com/meteoric_cry/p/7987548.html

以 A 系为参考系,绕 z​ 轴旋转 \(\theta\) 到 B 系

\[P_B = \left[ \begin{matrix} \cos\theta & \sin\theta & 0 \\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{matrix} \right] P_A \]

则 B 系坐标 PB 变换到 A 系为(旋转矩阵为正交阵,逆矩阵等于转置矩阵):

\[P_A = \left[ \begin{matrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{matrix} \right] P_B \]

以上旋转矩阵等于 \((1-8)\) ,推导结束。绕 x, y​ 轴同理。

1.3 绕两个坐标轴旋转的旋转矩阵

1.3.1 内旋

设坐标系 \(OX_iY_iZ_i​\) 先绕 \(Z_i​\) 旋转 \(\theta​\) 角形成坐标系 \(OX_mY_mZ_m​\),再绕 \(X_m​\) 轴旋转 \(\alpha​\) 角,形成坐标系 \(OX_jY_jZ_j​\) ,如上图

\[[r]_i = [^iR_m(Z,\theta)][r]_m \tag{1-9} \]

\[[r]_m = [^mR_j(X,\alpha)][r]_j \tag{1-10} \]

\[[r]_i = [^iR_m(Z,\theta)][r]_m = [^iR_m(Z,\theta)][^mR_j(X,\alpha)][r]_j = [^iR_j(\theta,\alpha)][r]_j \tag{1-11} \]

依照定义,上述旋转的旋转轴是前次变换后新系的轴,因此是内旋。可见,内旋要将绕各轴的旋转矩阵从左至右连乘

此时的旋转矩阵为:

\[[^iR_j(\theta,\alpha)]= \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos\alpha & -\sin\alpha \\ 0 & \sin\alpha & \cos\alpha \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta\cos\alpha & \sin\theta\sin\alpha \\ \sin\theta & \cos\theta\cos\alpha & -\cos\theta\sin\alpha \\ 0 & \sin\alpha & \cos\alpha \end{bmatrix} \tag{1-12} \]

1.3.2 外旋

设坐标系 \(OX_iY_iZ_i\) 先绕 \(X_i\) 轴旋转 \(\alpha\) 角形成坐标系 \(OX_mY_mZ_m\),再绕 \(Z_i\) 旋转 \(\theta\) 角,形成坐标系 \(OX_jY_jZ_j\) ,对于外旋,利用点变换推导更直观。 \(i\) 系变换到 \(j\) 系,等效于 \(i\) 系下点 \([r]_i\) 按坐标系变换的逆变换,即先绕 \(Z_i\) 旋转 \(-\theta\) (旋转 \(\theta\) 的逆变换),再绕 \(X_i\) 旋转 \(-\alpha\) ,因为参考系始终是 \(i\) 系,因此矩阵从右至左连乘

\[[r]_j = [R(X,\alpha)]^{-1}[R(Z,\theta)]^{-1}[r]_i \]

\[[r]_i = [R(Z,\theta)][R(X,\alpha)][r]_j \tag{1-13} \]

可知,外旋要将绕各轴的旋转矩阵从右至左连乘,对比 \((1-11)​\) 有,外旋等效于内旋的旋转序列倒序

1.4 绕三个坐标轴旋转的旋转矩阵

机器人学中多采用欧拉角(Euler)旋转,依照上节结论,内旋,旋转矩阵右乘;外旋,旋转矩阵左乘;内旋与外旋的绕轴旋转序列倒序时,两者等效。

外旋, \(i\) 系, \(j\) 系初始时重合, \(j\) 系绕固定参考系 \(i\) 系坐标轴旋转,先绕 \(X\) 轴旋转 \(\phi\) ,然后绕 \(Y\) 轴旋转 \(\theta\) ,最后绕 \(Z\) 轴旋转 \(\psi\)

内旋, \(i​\) 系, \(j​\) 系初始时重合, \(j​\) 系绕自身坐标轴旋转,先绕 \(Z​\) 轴旋转 \(\psi​\) ,然后绕 \(Y​\) 轴旋转 \(\theta​\) ,最后绕 \(X​\) 轴旋转 \(\phi​\)

以上两种旋转方式简记做:x-y-z (extrinsic rotations),z-y′-x″ (intrinsic rotations),他们的旋转矩阵为( \(c\theta\) is shorthand for \(cos\theta\) , \(s\theta\) is shorthand for \(sin\theta\) , and so on.)

\[\begin{align} R_{XYZ}(\phi,\theta,\psi) = R_Z(\psi)R_Y(\theta)R_X(\phi) = \\ R_{ZY'X''}(\psi,\theta,\phi) = R_Z(\psi)R_Y(\theta)R_X(\phi) = \\ \begin{bmatrix} c\psi c\theta & c\psi s\theta s\phi - s\psi c\phi & c\psi s\theta c\phi + s\psi s\phi \\ s\psi c\theta & s\psi s\theta s\phi + c\psi c\phi & s\psi s\theta c\phi - c\psi s\phi \\ -s\theta & c\theta s\phi & c\theta c\phi \end{bmatrix} \end{align} \tag{1-14} \]

内旋序列 z-y′-x″ ,\(\psi\) 称偏航角 yaw,\(\theta\) 称俯仰角 pitch,\(\phi\) 称横滚角 roll,\(\psi, \phi\) 的取值范围 \(2\pi\)\(\theta\) 的取值范围 \(\pi\)

下面左图不是右手系, z 轴应朝下。

yaw, pitch, roll 的定义只在该内旋序列下才有效,且飞行器初始位置必须为参考系,附 wiki 原文如下:

These angles are normally taken as one in the external reference frame (heading, bearing), one in the intrinsic moving frame (bank) and one in a middle frame, representing an elevation or inclination respect the horizontal plane, which is equivalent to the line of nodes for this purpose.

For an aircraft, they can be obtained with three rotations around its principal axes if done in the proper order. A yaw will obtain the bearing, a pitch will yield the elevation and a roll gives the bank angle. Therefore, in aerospace they are sometimes called yaw, pitch and roll. Notice that this will not work if the rotations are applied in any other order or if the airplane axes start in any position non-equivalent to the reference frame.

Tait–Bryan angles, following z-y′-x″ (intrinsic rotations) convention, are also known as nautical angles, because they can be used to describe the orientation of a ship or aircraft, or Cardan angles, after the Italian mathematician and physicist Gerolamo Cardano, who first described in detail the Cardan suspension and the Cardan joint.

(https://en.wikipedia.org/wiki/Euler_angles#Conventions_2)

旋转序列不同,旋转矩阵有不同的表达式,见

https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix

1.5 Euler angles and Tait-Bryan angles

Proper Euler angles 图示。xyz 固定参考系用蓝色显示,XYZ 旋转系用红色显示,The line of nodes (N) 用绿色显示。旋转序列为 z-x'-z'',内旋。

Tait-Bryan angles 图示。 z-y'-x'' 序列,内旋,N 对齐 y‘ 。旋转角序列为 \(\psi, \theta, \phi\),注意该情况 \(\psi > 90 ^{\circ}\)\(\theta < 0\)

两者的不同在于 line of nodes 几何作图的不同,line of nodes 指初始旋转平面与最终旋转平面的交叉线。Proper Euler angles Euler angles 首尾两次旋转同一个轴,所以相交叉的平面在初始时一致(xy and XY),Tait-Bryan angles 首尾两次旋转不同的轴,所以相交叉的平面在初始时垂直(xy and YZ)。

(https://en.wikipedia.org/wiki/Euler_angles)

未完待续...

posted @ 2019-03-25 21:11  armme  阅读(26450)  评论(0编辑  收藏  举报