summaryrefslogtreecommitdiff
path: root/common/accel-linear.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-linear.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-linear.hpp')
-rw-r--r--common/accel-linear.hpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/common/accel-linear.hpp b/common/accel-linear.hpp
index a943594..2bd57b8 100644
--- a/common/accel-linear.hpp
+++ b/common/accel-linear.hpp
@@ -7,13 +7,23 @@ namespace rawaccel {
/// <summary> Struct to hold linear acceleration implementation. </summary>
struct linear_impl {
double accel;
+ double offset;
+ double subtractive_const;
+ double divisive_const;
- linear_impl(const accel_args& args) : accel(args.accel) {}
+ linear_impl(const accel_args& args) : accel(args.accel), offset(args.offset) {
+ subtractive_const = 2 * accel * offset;
+ divisive_const = accel * offset * offset;
+ }
inline double operator()(double speed) const {
- return accel * speed;
+ double base_speed = speed + offset;
+ return accel * base_speed - subtractive_const + divisive_const / base_speed;
}
+ inline double legacy_offset(double speed) const {
+ return accel * speed;
+ }
};
using accel_linear = additive_accel<linear_impl>;