diff options
| author | Jacob Palecki <[email protected]> | 2020-09-03 13:21:45 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-03 13:21:45 -0700 |
| commit | c7e9641e8688c82874dbfa067f7dc8cb4d40e23d (patch) | |
| tree | f621b568c8fac71126829f8db1bc72808ab4e059 /common/accel-natural.hpp | |
| parent | Start adding gain offsets (diff) | |
| download | rawaccel-c7e9641e8688c82874dbfa067f7dc8cb4d40e23d.tar.xz rawaccel-c7e9641e8688c82874dbfa067f7dc8cb4d40e23d.zip | |
Change classic, natural, naturalgain to use gain offset
Diffstat (limited to 'common/accel-natural.hpp')
| -rw-r--r-- | common/accel-natural.hpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index c7d0dcd..32bc365 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -10,16 +10,18 @@ namespace rawaccel { struct natural_impl { double rate; double limit; + double offset; natural_impl(const accel_args& args) : - rate(args.accel), limit(args.limit - 1) + rate(args.accel), limit(args.limit - 1), offset(args.offset) { rate /= limit; } inline double operator()(double speed) const { // f(x) = k(1-e^(-mx)) - return limit - (limit * exp(-rate * speed)); + double base_speed = speed + offset; + return limit * (1 - ((exp(-rate * speed) * speed + offset) / base_speed)); } }; |