diff options
| author | Jacob Palecki <[email protected]> | 2020-09-19 21:24:59 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-19 21:24:59 -0700 |
| commit | 7622f542daa27db332334d0af25faa9651a1c831 (patch) | |
| tree | a10bce066ea6454ccec60309c5af2adec0a9aa4e /common/accel-experimentone.hpp | |
| parent | Fix chart scaling for DPIs < 1200 (diff) | |
| download | rawaccel-7622f542daa27db332334d0af25faa9651a1c831.tar.xz rawaccel-7622f542daa27db332334d0af25faa9651a1c831.zip | |
log sigmoid sens done
Diffstat (limited to 'common/accel-experimentone.hpp')
| -rw-r--r-- | common/accel-experimentone.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/common/accel-experimentone.hpp b/common/accel-experimentone.hpp new file mode 100644 index 0000000..7d21b58 --- /dev/null +++ b/common/accel-experimentone.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <math.h> + +#include "accel-base.hpp" + +namespace rawaccel { + + /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary> + struct experimentone_impl { + double rate; + double limit; + double midpoint; + double subtractive_constant; + + experimentone_impl(const accel_args& args) : + rate(pow(10,args.rate)), limit(2*log10(args.limit)), midpoint(log10(args.midpoint)) + { + subtractive_constant = limit / 2; + } + + inline double operator()(double speed) const { + double log_speed = log10(speed); + return pow(10, limit / (exp(-rate * (log_speed - midpoint)) + 1) - subtractive_constant); + + } + + inline double legacy_offset(double speed) const { return operator()(speed); } + }; + + using accel_experimentone = nonadditive_accel<experimentone_impl>; + +} |