Exponential approach tool

As told by Carlos Jambrina on 06/02/2019

Rough tool to map equations of the form valuen = valuen-1 + (target - valuen-1) * expFactor
which depend on the number of iterations, to ones that consume time deltas and behave a bit better with varying framerates valuen = target - (valuen-1 - target) / edt / timeHorizon

[here's a more detailed write-up on this]

Given expFactor and a framerate, you can adjust timeHorizon to make the functions match (for example, timeHorizon = 0.1494 matches expFactor = 0.2 with 30 fps). Support for different implementations of ex is provided, though in practice a 3rd order Taylor series works well enough. The analytical solution only guarantees accurate results when using Math.exp.

HTML5 canvas not supported in this browser.
exponential function