For now, what we are using just considers 2D vectors. Instead, we can use this method where the rotation matrix between two surfaces is found via SVD. I have tried this on my data and the results look quite right.

For now, head kinematics is calculated correctly either way so I will implement this as an additional feature later on.
Note that this rigid body transformation can be used not only for head kinematics but also correcting fly's orientation, etc.
For now, what we are using just considers 2D vectors. Instead, we can use this method where the rotation matrix between two surfaces is found via SVD. I have tried this on my data and the results look quite right.
For now, head kinematics is calculated correctly either way so I will implement this as an additional feature later on.
Note that this rigid body transformation can be used not only for head kinematics but also correcting fly's orientation, etc.