Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the real problem with the OP's straw-proposal interpolation method is that it's stateless and doesn't need to be. I would instead record the start position, then interpolate along a function F(t) to the end position. F(0)=0, F(1)=1, F'(0)=F'(1)=0 just so the ends aren't jerky. The curve can even overshoot 1 to give the animation some bounce.

I'm sure somewhere on the Internet somebody's written down some good choices of curve; hopefully someone else knows what to search for.

(I don't know what to do if another change interrupts the first but it's a rare case and can probably be handled imperfectly.)



> (I don't know what to do if another change interrupts the first but it's a rare case and can probably be handled imperfectly.)

This kind of lerp trick, while imperfect, is useful in exactly these sort of situations. It allows you to smooth movement even if the target point is changing at at arbitrary intervals (note too that it works okay generalised to multiple dimensions). And the statelessness is very useful too - I don't think the feel is great and it's not very controllable, but being able to just add some damping to the movement without having to track animation states or anything like that is super useful.


> I don't know what to do if another change interrupts the first but it's a rare case and can probably be handled imperfectly.

Extract the position (p0) and velocity (v0) vectors at the moment of interruption, and derive a new function F(t) that meets the constraints {F(0)=p0, F'(0)=v0, F(1)=p1, F'(1)=0}.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: