I found a good answer here:
http://answers.unity3d.com/questions/168779/extrapolating-quaternion-rotation.html
I adapted the code to my needs and it works very well!
For two quaternions qa, qb this will give you interpolation and extrapolation using the same formula. t is the amount of interpolation / extrapolation, t 0.1 = 0.1 the path from qa-> qb, t = -1 → extrapolate the entire step from qa-> qb back, etc. I used self-tuning functions to enable the use of the / axisAngle quaternions with opencv cv :: Mat, but I would probably choose Eigen for this instead
Quat qc = QuaternionMultiply(qb, QuaternionInverse(qa));
AxisAngle axisAngleC = QuaternionToAxisAngle(qc);
double ang = axisAngleC.angle;
if (ang > M_PI) ang -= 2.0*M_PI;
ang = fmod(ang * t,2.0*M_PI);
axisAngleC.angle = ang;
return QuaternionMultiply(AxisAngleToQuaternion(axisAngleC),qa);
source
share