papagina / RotationContinuity

Coder for "On the Continuity of Rotation Representations"
MIT License
338 stars 55 forks source link

How we can compute Euler angles from Quaternion form? #16

Open Algabri opened 1 year ago

Algabri commented 1 year ago

I am trying to use the Quaternion form instead of rotation matrices.

I already trained my model, but when I need to test the model, I must compute Euler angles from the Quaternion form as you did with computing Euler angles from rotation matrices.

For example, the output in Quaternion form for B = batch_size = 2 (-> Bx4) is :

 tensor([[ 0.0725, -0.0645,  0.0308,  0.9948],
        [-0.5235, -0.2456,  0.0824,  0.8117]], device='cuda:0')

And, the output in rotation matrices form for B = batch_size = 2 (-> Bx3x3) :

tensor([[[ 0.9933, -0.0871,  0.0755],
         [ 0.0850,  0.9959,  0.0316],
         [-0.0779, -0.0250,  0.9966]],

        [[ 0.7244, -0.0551, -0.6871],
         [ 0.2493,  0.9503,  0.1866],
         [ 0.6427, -0.3065,  0.7021]]], device='cuda:0')

Could you help me with how we can compute Euler angles from Quaternion form?

papagina commented 11 months ago

you could first compute the rotation matrix from quaternion and then compute the Euler angles from the rotation matrix.