quaternion
quaternion copied to clipboard
[Question] What is the extrapolation behaviour of squad and slerp
Hi,
I'm interested on knowing how squad and slerp extrapolate data outside of the minum and maximum times provided as input to them. As far as I can tell this is not documented and I haven't been able to find references to what happens in that case within the code itself.
Could you provide some advice on how that works?
That's a good question. Unfortunately, at the moment I don't have any time to document this more thoroughly, but hopefully this will be enough:
Slerp is just linear interpolation, so it uses linear extrapolation. That is, the slerp function basically just does (approximately) this for any inputs:
slerp(R1, R2, t1, t2, t_out) == (R2/R1)**((t_out-t1)/(t2-t1)) * R1
The only exception is that if -R2 is closer to R1 than R2 is, it flips the sign of R2, which is what we usually want for rotations.
Squad also uses linear extrapolation for times outside the input times. So, if t_out is greater than t_in[-1], this should be (approximately) true:
squad(R_in, t_in, t_out) == slerp(R[-2], R[-1], t[-2], t[-1], t_out)
Similarly, if t_out is less than t_in[0], this should be (approximately) true:
squad(R_in, t_in, t_out) == slerp(R[0], R[1], t[0], t[1], t_out)
Unfortunately, that seems to be broken at the moment, so I guess I can't make any promises about extrapolation to earlier times.