d3-ease
d3-ease copied to clipboard
easeBezier
todo:
- [ ] tests
- [ ] document
closes #3
demo: https://observablehq.com/d/51cd89b1a3f17913
speed/accuracy tests https://observablehq.com/d/e7d4fef33e304f2b
I'd love a review @enjalot ; in particular I'm making grandiose claims about having a shorter and more accurate code than the reference implementation so I must be wrong somehow :)
I took a look and compared the reference implementation. It seems they do extra work to a) provide an initial guess and b) switch to binary subdivision if the derivative is too close to 0. I noticed your implementation removes those as the optimization for initial guess is unnecessary and it would seem that there isn't a reasonable input to the easing function that would result in a divergent solution.
I'll admit that I can't remember enough numerical analysis to determine if you COULD have an input that would diverge, especially in the bounds of whats considered a "reasonable" easing function.
I found your implementation to be easier to read than the reference as well.
I also have a trick to avoid divergence in https://github.com/d3/d3-ease/pull/29/files#diff-98bd2b6dedcb4fda72304031dbf8d928R24 "when we're moving too fast, slow down".
I've used this trick a lot in the 2D Newton-Raphson solver in d3-geo.
Ah I see, yes that makes sense and looks good to me
On Sun, Aug 9, 2020 at 3:41 PM Philippe Rivière [email protected] wrote:
I also have a trick to avoid divergence in
https://github.com/d3/d3-ease/pull/29/files#diff-98bd2b6dedcb4fda72304031dbf8d928R24 "when we're moving too fast, slow down".
I've used this trick a lot in the 2D Newton-Raphson solver in d3-geo.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/d3/d3-ease/pull/29#issuecomment-671109541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXPPLX3JRDPEDAMXC2LF3R74Q2JANCNFSM4PE45GXQ .
-- Ian Johnson - 周彦 http://enjalot.github.io/ http://enja.org
Hi there, this is very cool – I've been looking for an implementation for a Bézier-based easing function! Any news as to when this will be merged into master? :)
Thanks! Yes, we should make a new push for all the outstanding features that have been waiting in pull-requests—some of them might be merged, others made available as notebooks or independent libraries. In the meantime it helps if someone plays with them, finds bugs, gives them real-world use cases, etc.
In the case of this particular PR, I still need to complete it with documentation and unit tests.