diff options
| author | Jacob Palecki <[email protected]> | 2020-09-03 19:36:44 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-03 19:36:44 -0700 |
| commit | 01f870a493378a62ab76dcbf5dc37c0390ca7afe (patch) | |
| tree | b3dac41f6c0fa67b6c62c6643145f01b464c1a46 /common/accel-naturalgain.hpp | |
| parent | Change classic, natural, naturalgain to use gain offset (diff) | |
| download | rawaccel-01f870a493378a62ab76dcbf5dc37c0390ca7afe.tar.xz rawaccel-01f870a493378a62ab76dcbf5dc37c0390ca7afe.zip | |
Refactor for nice gain offset
Diffstat (limited to 'common/accel-naturalgain.hpp')
| -rw-r--r-- | common/accel-naturalgain.hpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/common/accel-naturalgain.hpp b/common/accel-naturalgain.hpp index 5979d92..cdfd1fa 100644 --- a/common/accel-naturalgain.hpp +++ b/common/accel-naturalgain.hpp @@ -13,16 +13,15 @@ namespace rawaccel { inline double operator()(double speed) const { // f(x) = k((e^(-mx)-1)/mx + 1) - if (speed <= 0) - { - return 0; - } - double base_speed = speed + offset; double scaled_speed = rate * speed; return limit * (((exp(-scaled_speed) - 1) / (base_speed * rate) ) + 1 - offset / base_speed); } + inline double legacy_offset(double speed) const { + double scaled_speed = rate * speed; + return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1); + } }; using accel_naturalgain = additive_accel<naturalgain_impl>; |