diff options
| author | Jacob Palecki <[email protected]> | 2020-09-21 14:26:04 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-21 14:26:04 -0700 |
| commit | e1acbaa344c2c571a9f7730afba6cd4fbd36ecf6 (patch) | |
| tree | 6ffdee3a16c7b5c89b6f12117e8a9b78b1112e6f /common/accel-experimentone.hpp | |
| parent | Merge pull request #21 from JacobPalecki/GUI (diff) | |
| parent | conditional around lookup map (diff) | |
| download | rawaccel-e1acbaa344c2c571a9f7730afba6cd4fbd36ecf6.tar.xz rawaccel-e1acbaa344c2c571a9f7730afba6cd4fbd36ecf6.zip | |
Merge remote-tracking branch 'downstream/experiment' into Experiment
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>; + +} |