GithubHelp home page GithubHelp logo

Comments (2)

Fil avatar Fil commented on April 27, 2024 1

I think it's a bug.

For back it's just a matter of reordering the operations to avoid bad rounding.

backIn(t) is computed as t * t * ((s + 1) * t - s) where s is the "overshoot" parameter. If computed as t * t * (s * (t - 1) + t) it will return 1 for t=1, with no additional cost (same number of multiplications and additions).

For elastic, and exp the formula is not really expected to give 0 in 0 or 1 in 1 as it uses Math.pow(2,-10) instead of 0.

A solution for these would be to introduce easePow(x) = (Math.pow(2, 10 * (x-1)) - 0.0009765625) * 1.0009775171065494 (the two constants being 2^-10 and 1/(1-2^-10)) and use it internally in lieu of Math.pow(2, 10 * (x-1)). This would have an added cost of 1 multiplication and 1 addition. It also means we have to change all the tests.

Finally for sinIn there doesn't seem to be a solution other than an equality test (t === 1 ? 1 : Math.cos(…))

from d3-ease.

Fil avatar Fil commented on April 27, 2024

I've pushed a rather simple solution for back and for sin, and a second commit solves it for elastic and exp (but breaks all the tests).

from d3-ease.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.