当前位置: 代码迷 >> 综合 >> 四元数和欧拉角互转
  详细解决方案

四元数和欧拉角互转

热度:61   发布时间:2024-02-23 23:05:32.0
转至元数据起始 import numpy as npimport math
r = np.pi/2
p = 0
y = 0sinp = math.sin(math.radians(p/2))
siny = math.sin(math.radians(y/2))
sinr = math.sin(math.radians(r/2))cosp = math.cos(math.radians(p/2))
cosy = math.cos(math.radians(y/2))
cosr = math.cos(math.radians(r/2))w = cosr*cosp*cosy + sinr*sinp*siny
x = sinr*cosp*cosy - cosr*sinp*siny
y = cosr*sinp*cosy + sinr*cosp*siny
z = cosr*cosp*siny - sinr*sinp*cosyprint(w,x,y,z)   ##欧拉2四元数r = math.atan2(2*(w*x+y*z),1-2*(x*x+y*y))
p = math.asin(2*(w*y-z*x))
y = math.atan2(2*(w*z+x*y),1-2*(z*z+y*y))angleR = r*180/math.pi
angleP = p*180/math.pi
angleY = y*180/math.piprint(angleR,angleP,angleY)  ##四元数2欧拉

 

  相关解决方案