欧拉角和四元数的相互转换

设四元数为:
q = ( w , x , y , z ) q = (w, x, y, z) q=(w,x,y,z)

对应欧拉角为:

  • 俯仰角(pitch): θ \theta θ
  • 滚转角(roll): ϕ \phi ϕ
  • 偏航角(yaw): ψ \psi ψ
    在这里插入图片描述

则四元数到欧拉角的转换公式为:

欧拉角到四元数

w = cos ⁡ ( θ 2 ) cos ⁡ ( ϕ 2 ) cos ⁡ ( ψ 2 ) + sin ⁡ ( θ 2 ) sin ⁡ ( ϕ 2 ) sin ⁡ ( ψ 2 ) x = sin ⁡ ( θ 2 ) cos ⁡ ( ϕ 2 ) cos ⁡ ( ψ 2 ) − cos ⁡ ( θ 2 ) sin ⁡ ( ϕ 2 ) sin ⁡ ( ψ 2 ) y = cos ⁡ ( θ 2 ) sin ⁡ ( ϕ 2 ) cos ⁡ ( ψ 2 ) + sin ⁡ ( θ 2 ) cos ⁡ ( ϕ 2 ) sin ⁡ ( ψ 2 ) z = cos ⁡ ( θ 2 ) cos ⁡ ( ϕ 2 ) sin ⁡ ( ψ 2 ) − sin ⁡ ( θ 2 ) sin ⁡ ( ϕ 2 ) cos ⁡ ( ψ 2 ) \begin{aligned} w &= \cos(\frac{\theta}{2})\cos(\frac{\phi}{2})\cos(\frac{\psi}{2}) + \sin(\frac{\theta}{2})\sin(\frac{\phi}{2})\sin(\frac{\psi}{2}) \\ x &= \sin(\frac{\theta}{2})\cos(\frac{\phi}{2})\cos(\frac{\psi}{2}) - \cos(\frac{\theta}{2})\sin(\frac{\phi}{2})\sin(\frac{\psi}{2}) \\ y &= \cos(\frac{\theta}{2})\sin(\frac{\phi}{2})\cos(\frac{\psi}{2}) + \sin(\frac{\theta}{2})\cos(\frac{\phi}{2})\sin(\frac{\psi}{2}) \\ z &= \cos(\frac{\theta}{2})\cos(\frac{\phi}{2})\sin(\frac{\psi}{2}) - \sin(\frac{\theta}{2})\sin(\frac{\phi}{2})\cos(\frac{\psi}{2}) \end{aligned} wxyz=cos(2θ)cos(2ϕ)cos(2ψ)+sin(2θ)sin(2ϕ)sin(2ψ)=sin(2θ)cos(2ϕ)cos(2ψ)cos(2θ)sin(2ϕ)sin(2ψ)=cos(2θ)sin(2ϕ)cos(2ψ)+sin(2θ)cos(2ϕ)sin(2ψ)=cos(2θ)cos(2ϕ)sin(2ψ)sin(2θ)sin(2ϕ)cos(2ψ)

四元数到欧拉角

θ = arcsin ⁡ ( 2 ( w ⋅ y − z ⋅ x ) ) ϕ = arctan ⁡ 2 ( 2 ( w ⋅ x + y ⋅ z ) , 1 − 2 ( x 2 + y 2 ) ) ψ = arctan ⁡ 2 ( 2 ( w ⋅ z + x ⋅ y ) , 1 − 2 ( y 2 + z 2 ) ) \begin{aligned} \theta &= \arcsin(2(w \cdot y - z \cdot x)) \\ \phi &= \arctan2(2(w \cdot x + y \cdot z), 1 - 2(x^2 + y^2)) \\ \psi &= \arctan2(2(w \cdot z + x \cdot y), 1 - 2(y^2 + z^2)) \end{aligned} θϕψ=arcsin(2(wyzx))=arctan2(2(wx+yz),12(x2+y2))=arctan2(2(wz+xy),12(y2+z2))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值