Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] What is the extrapolation behaviour of squad and slerp #241

Open
GCBallesteros opened this issue Dec 2, 2024 · 1 comment
Open

Comments

@GCBallesteros
Copy link

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?

@moble
Copy link
Owner

moble commented Dec 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants