diff options
| author | a1xd <[email protected]> | 2020-09-04 00:17:55 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-04 00:17:55 -0400 |
| commit | 159abe32fa9e903e1ac0a2c758d64c4b8e152c3d (patch) | |
| tree | 2230e353985551a21a25b09bfacb89467b52d165 /common/accel-natural.hpp | |
| parent | Merge pull request #18 from a1xd/write-delay (diff) | |
| parent | Add offset options to GUI, make gain options default (diff) | |
| download | rawaccel-159abe32fa9e903e1ac0a2c758d64c4b8e152c3d.tar.xz rawaccel-159abe32fa9e903e1ac0a2c758d64c4b8e152c3d.zip | |
Merge pull request #19 from JacobPalecki/gainOffset
Add gain offset & make gain options default
Diffstat (limited to 'common/accel-natural.hpp')
| -rw-r--r-- | common/accel-natural.hpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index c7d0dcd..03700c1 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -10,15 +10,21 @@ 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)) + double base_speed = speed + offset; + return limit * (1 - ((exp(-rate * speed) * speed + offset) / base_speed)); + } + + inline double legacy_offset(double speed) const { return limit - (limit * exp(-rate * speed)); } |