Я использую scipy.spatial.transform.Rotation, чтобы получить вращение = Rotation.from_quat([q1, q2, q3, q_c]).
У меня также есть функция который я написал для получения кватерниона из DCM:
Код: Выделить всё
def convert_dcm_to_quaternion(dcm):
"""
Convert DCM to a quaternion
"""
C_11 = dcm[0,0] #angle between vector 1 of initial frame and vector 1 of rotated frame
C_12 = dcm[0,1] #angle between vector 2 of initial frame and vector 1 of rotated frame
C_13 = dcm[0,2]
C_21 = dcm[1,0] #angle between vector 1 of initial frame and vector 2 of rotated frame
C_22 = dcm[1,1]
C_23 = dcm[1,2]
C_31 = dcm[2,0]
C_32 = dcm[2,1]
C_33 = dcm[2,2]
q_c = 1/2 * np.sqrt(C_11 + C_22 + C_33 + 1) #consider that scalar value != 0, i.e. not at a singularity. Use Markley or Shepperd methods otherwise.
q_vec = np.array([[C_23 - C_32], [C_31 - C_13], [C_12 - C_21]]) / (4*q_c)
q = np.vstack((q_vec,q_c ))
q = q.flatten()
return q
В зависимости от литературы я иногда нахожу q1 = (C_23 - C_32) / (4 * q_c), а иногда и другой знак, и я не уверен, почему, который мог бы объяснить эту сопряженную проблему. Не могли бы вы мне помочь, пожалуйста?
спасибо за помощь!
Подробнее здесь: https://stackoverflow.com/questions/798 ... sing-scipy
Мобильная версия