summaryrefslogtreecommitdiff
path: root/common/accel-classic.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-classic.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-classic.hpp')
-rw-r--r--common/accel-classic.hpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/common/accel-classic.hpp b/common/accel-classic.hpp
index 0a380dd..4cc52ca 100644
--- a/common/accel-classic.hpp
+++ b/common/accel-classic.hpp
@@ -7,23 +7,20 @@
namespace rawaccel {
/// <summary> Struct to hold "classic" (linear raised to power) acceleration implementation. </summary>
- struct accel_classic : accel_base {
- double exponent;
+ struct classic_impl {
+ double accel;
+ double power;
- accel_classic(const accel_args& args) : accel_base(args) {
- verify(args);
+ classic_impl(const accel_args& args) :
+ accel(args.accel), power(args.exponent - 1)
+ {}
- exponent = args.exponent - 1;
- }
-
- inline double accelerate(double speed) const {
- //f(x) = (mx)^k
- return pow(speed_coeff * speed, exponent);
- }
-
- void verify(const accel_args& args) const {
- if (args.exponent <= 1) bad_arg("exponent must be greater than 1");
+ inline double operator()(double speed) const {
+ //f(x) = (mx)^(k-1)
+ return pow(accel * speed, power);
}
};
+
+ using accel_classic = additive_accel<classic_impl>;
}