三维旋转--欧拉角

欧拉角

定义

它由三个角度组成,分别是绕固定的坐标轴(通常是X轴、Y轴和Z轴)旋转的角度。具体来说,欧拉角通常包括以下三个角度:

  1. 滚转角(Roll):绕Z轴旋转的角度。
  2. 俯仰角(Pitch):绕Y轴旋转的角度。
  3. 偏航角(Yaw):绕X轴旋转的角度。

缺点

旋转的顺序会影响到旋转的结果,且有万向节死锁的问题;

万向节

x x x轴旋转90°

y y y轴旋转90°

现在 z z z轴和旋转之前的 x x x轴的重合,我们再去绕着 z z z轴旋转,会发现无法绕着 z z z轴旋转,而是绕着 x x x轴,由此我们就丢弃了一个自由度

那造成这样的原因是什么呢?

在很多年以前,欧拉就证明了,3D 空间中的任意一个旋转都可以拆分成为沿着物体自身三个正交坐标轴的旋转.
E ( y a w , p i t c h , r o l l ) = R z ( y a w ) R y ( r o l l ) R x ( p i t c h ) E(yaw,pitch,roll)=R_z(yaw)R_y(roll)R_x(pitch) E(yaw,pitch,roll)=Rz(yaw)Ry(roll)Rx(pitch)
其中,
R x ( θ ) = [ 1 0 0 0 cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 sin ⁡ ( θ ) cos ⁡ ( θ ) ] R y ( θ ) = [ cos ⁡ ( θ ) 0 sin ⁡ ( θ ) 0 1 0 − sin ⁡ ( θ ) 0 cos ⁡ ( θ ) ] R z ( θ ) = [ cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 1 ] \begin{gathered} R_{x}(\theta) =\begin{bmatrix}1&0&0\\0&\cos(\theta)&-\sin(\theta)\\0&\sin(\theta)&\cos(\theta)\end{bmatrix} \\ R_{y}(\theta) =\begin{bmatrix}\cos(\theta)&0&\sin(\theta)\\0&1&0\\-\sin(\theta)&0&\cos(\theta)\end{bmatrix} \\ R_{z}(\theta) =\begin{bmatrix}\cos(\theta)&-\sin(\theta)&0\\[0.3em]\sin(\theta)&\cos(\theta)&0\\[0.3em]0&0&1\end{bmatrix} \end{gathered} Rx(θ)= 1000cos(θ)sin(θ)0sin(θ)cos(θ) Ry(θ)= cos(θ)0sin(θ)010sin(θ)0cos(θ) Rz(θ)= cos(θ)sin(θ)0sin(θ)cos(θ)0001
我们可以固定一个旋转的顺序:
E ( yaw, pitch, roll ) = R z ( yaw ) R y ( roll ) R x ( pitch ) E(\text{yaw, pitch, roll})=R_z(\text{yaw})R_y(\text{roll})R_x(\text{pitch}) E(yaw, pitch, roll)=Rz(yaw)Ry(roll)Rx(pitch)
我们按照这个顺序对三个轴进行旋转,在某些特殊情况下,其中的某两个旋转变换可能变换的是同一个轴,这样就导致丧失了一个自由度,从而导致了万向节死结的产生。

假设按照 x − y − z x-y-z xyz的顺序旋转。其中 x x x轴任意旋转,沿 y y y轴旋转 π / 2 \pi/2 π/2,最后沿着 z z z旋转任意角度,大致的过程如下:

这样我们将 z z z轴变换到原来 x x x轴的方向,所以,最后 z z z轴的旋转与 x x x轴的旋转其实操纵的是同一个轴(外部的旋转轴),三次旋转仅仅覆盖了两个外部轴的旋转,就导致了万向节死结的现象。

用公式去表达这个过程的话:
E ( α , π 2 , β ) = R z ( β ) R y ( π 2 ) R x ( α ) = [ 0 cos ⁡ ( β ) ⋅ sin ⁡ ( α ) − cos ⁡ ( α ) ⋅ sin ⁡ ( β ) sin ⁡ ( α ) ⋅ sin ⁡ ( β ) + cos ⁡ ( α ) ⋅ cos ⁡ ( β ) 0 sin ⁡ ( α ) ⋅ sin ⁡ ( β ) + cos ⁡ ( α ) ⋅ cos ⁡ ( β ) cos ⁡ ( α ) ⋅ sin ⁡ ( β ) − cos ⁡ ( β ) ⋅ sin ⁡ ( α ) − 1 0 0 ] = [ 0 sin ⁡ ( α − β ) cos ⁡ ( α − β ) 0 cos ⁡ ( α − β ) − sin ⁡ ( α − β ) − 1 0 0 ] = R y ( π 2 ) R x ( α − β ) \begin{aligned} E(\alpha,\frac{\pi}{2},\beta)& =R_{z}(\beta)R_{y}(\frac{\pi}{2})R_{x}(\alpha) \\ &=\begin{bmatrix}0&\cos(\beta)\cdot\sin(\alpha)-\cos(\alpha)\cdot\sin(\beta)&\sin(\alpha)\cdot\sin(\beta)+\cos(\alpha)\cdot\cos(\beta)\\0&\sin(\alpha)\cdot\sin(\beta)+\cos(\alpha)\cdot\cos(\beta)&\cos(\alpha)\cdot\sin(\beta)-\cos(\beta)\cdot\sin(\alpha)\\-1&0&0\end{bmatrix} \\ &=\begin{bmatrix}0&\sin(\alpha-\beta)&\cos(\alpha-\beta)\\0&\cos(\alpha-\beta)&-\sin(\alpha-\beta)\\-1&0&0\end{bmatrix} \\ &=R_y(\frac{\pi}{2})R_x(\alpha-\beta) \end{aligned} E(α,2π,β)=Rz(β)Ry(2π)Rx(α)= 001cos(β)sin(α)cos(α)sin(β)sin(α)sin(β)+cos(α)cos(β)0sin(α)sin(β)+cos(α)cos(β)cos(α)sin(β)cos(β)sin(α)0 = 001sin(αβ)cos(αβ)0cos(αβ)sin(αβ)0 =Ry(2π)Rx(αβ)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值