summaryrefslogtreecommitdiff
path: root/common/accel-naturalgain.hpp
diff options
context:
space:
mode:
authorJacobPalecki <[email protected]>2020-08-31 23:03:46 -0700
committerGitHub <[email protected]>2020-08-31 23:03:46 -0700
commit471fe599bab6ba0632ddd1dacd20c7fc42db0eee (patch)
tree90a82ee14dbb112621657efbd2523ed35f59d154 /common/accel-naturalgain.hpp
parentMerge pull request #16 from JacobPalecki/Misc (diff)
parentadd independent xy accel to driver (diff)
downloadrawaccel-471fe599bab6ba0632ddd1dacd20c7fc42db0eee.tar.xz
rawaccel-471fe599bab6ba0632ddd1dacd20c7fc42db0eee.zip
Merge pull request #17 from a1xd/indep
Indep
Diffstat (limited to 'common/accel-naturalgain.hpp')
-rw-r--r--common/accel-naturalgain.hpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/common/accel-naturalgain.hpp b/common/accel-naturalgain.hpp
index 95c0be2..646b2bb 100644
--- a/common/accel-naturalgain.hpp
+++ b/common/accel-naturalgain.hpp
@@ -2,31 +2,22 @@
#include <math.h>
-#include "accel-base.hpp"
+#include "accel-natural.hpp"
namespace rawaccel {
/// <summary> Struct to hold "natural" (vanishing difference) gain implementation. </summary>
- struct accel_naturalgain : accel_base {
- double limit = 1;
- double midpoint = 0;
+ struct naturalgain_impl : natural_impl {
- accel_naturalgain(const accel_args& args) : accel_base(args) {
- verify(args);
+ using natural_impl::natural_impl;
- limit = args.limit - 1;
- speed_coeff /= limit;
- }
-
- inline double accelerate(double speed) const {
+ inline double operator()(double speed) const {
// f(x) = k((e^(-mx)-1)/mx + 1)
- double scaled_speed = speed_coeff * speed;
+ double scaled_speed = rate * speed;
return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1);
}
-
- void verify(const accel_args& args) const {
- if (args.limit <= 1) bad_arg("limit must be greater than 1");
- }
+
};
+ using accel_naturalgain = additive_accel<naturalgain_impl>;
}