Verschiedene Formeln zur Quaternionenberechnung aus Matrizen mit ScipyPython

Python-Programme
Anonymous
 Verschiedene Formeln zur Quaternionenberechnung aus Matrizen mit Scipy

Post by Anonymous »

Ich habe [q1, q2, q3, q_c] eine Quaternion (skalares Letztes), die die Rotation von einem Ursprung zu einem Körperrahmen darstellt.
Ich verwende scipy.spatial.transform.Rotation, um rotation = Rotation.from_quat([q1, q2, q3, q_c]) zu erhalten.
Ich habe auch eine Funktion dass ich codiert habe, um aus einem DCM eine Quaternion zu erhalten:

Code: Select all

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
Aber bei Verwendung von „convert_dcm_to_quaternion(rotation.as_matrix())“ erhalte ich das Konjugat aus meinen anfänglichen Quaternionen. Können Sie erklären, warum?
Abhängig von der Literatur finde ich manchmal q1 = (C_23 - C_32) / (4 * q_c) und manchmal das andere Vorzeichen, und ich bin mir nicht sicher, warum, was dieses konjugierte Problem erklären würde. Könnten Sie mir bitte helfen?
Vielen Dank für Ihre Hilfe!

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post