I've got an object spinning in 3 axes and I'm tracking it with a motion capture system. For each timepoint, depending on how I export the data, I either get 4 columns of data for the quaternion rotation or 3 columns for the rotation around the global XYZ axes.
For the XYZ data, I can calculate the rotational velocity in each axis but I'm not sure how to combine this data into a speed. I've tried using the sqrt(dx^2 + dy^2 + dz^2) formula you would use for combining linear velocities into a speed but when I picture the problem this doesn't seem like the right approach.
For the quaternion data I used the pyquaternion library in python to calculate the angle between consecutive data points then calculated the rate of change in the angle. For the angle calculation I used the approach given here; I've copied the approach below in case the link breaks. This seems like a better approach than my attempt with the XYZ data but I'd never heard of quaternions until today so I'm doubting my approach.
Assuming these represent attitude rotations from one coordinate frame to another, if you are simply asking what is the minimum rotation to take you from one quaternion to the other, you simply multiply one quaternion by the conjugate of the other and then pick off the rotation angle of the resulting quaternion. But we really need to know what these quaternions represent, and what angle you are trying to recover, before we know what you want. E.g., suppose x and y represent ECI->BODY rotation quaternions, and you want to know the minimum rotation angle that would take you from the x BODY position to the y BODY position. Then you could do this: >> x = [ 0.968, 0.008, -0.008, 0.252]; x = x/norm(x); % ECI->BODY1 >> y = [ 0.382, 0.605, 0.413, 0.563]; y = y/norm(y); % ECI->BODY2 >> z = quatmultiply(quatconj(x),y) % BODY1->BODY2 >> z = 0.5132 0.6911 0.2549 0.4405 >> a = 2*acosd(z(4)) % min angle rotation from BODY1 to BODY2 >> a = 127.7227 But, again, these calculations are dependent on how I have the quaternions defined. Your specific case may be different. The scalar part is the 4th element.