diff options
Diffstat (limited to 'common/accel-naturalgain.hpp')
| -rw-r--r-- | common/accel-naturalgain.hpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/common/accel-naturalgain.hpp b/common/accel-naturalgain.hpp index 95c0be2..646b2bb 100644 --- a/common/accel-naturalgain.hpp +++ b/common/accel-naturalgain.hpp @@ -2,31 +2,22 @@ #include <math.h> -#include "accel-base.hpp" +#include "accel-natural.hpp" namespace rawaccel { /// <summary> Struct to hold "natural" (vanishing difference) gain implementation. </summary> - struct accel_naturalgain : accel_base { - double limit = 1; - double midpoint = 0; + struct naturalgain_impl : natural_impl { - accel_naturalgain(const accel_args& args) : accel_base(args) { - verify(args); + using natural_impl::natural_impl; - limit = args.limit - 1; - speed_coeff /= limit; - } - - inline double accelerate(double speed) const { + inline double operator()(double speed) const { // f(x) = k((e^(-mx)-1)/mx + 1) - double scaled_speed = speed_coeff * speed; + double scaled_speed = rate * speed; return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1); } - - void verify(const accel_args& args) const { - if (args.limit <= 1) bad_arg("limit must be greater than 1"); - } + }; + using accel_naturalgain = additive_accel<naturalgain_impl>; } |