summaryrefslogtreecommitdiff
path: root/common/accel-naturalgain.hpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-09-04 00:17:55 -0400
committerGitHub <[email protected]>2020-09-04 00:17:55 -0400
commit159abe32fa9e903e1ac0a2c758d64c4b8e152c3d (patch)
tree2230e353985551a21a25b09bfacb89467b52d165 /common/accel-naturalgain.hpp
parentMerge pull request #18 from a1xd/write-delay (diff)
parentAdd offset options to GUI, make gain options default (diff)
downloadrawaccel-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-naturalgain.hpp')
-rw-r--r--common/accel-naturalgain.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/common/accel-naturalgain.hpp b/common/accel-naturalgain.hpp
index 646b2bb..cdfd1fa 100644
--- a/common/accel-naturalgain.hpp
+++ b/common/accel-naturalgain.hpp
@@ -13,10 +13,15 @@ namespace rawaccel {
inline double operator()(double speed) const {
// f(x) = k((e^(-mx)-1)/mx + 1)
+ double base_speed = speed + offset;
double scaled_speed = rate * speed;
- return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1);
+ 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>;