diff options
| author | Jacob Palecki <[email protected]> | 2020-07-31 12:20:11 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-07-31 12:20:11 -0700 |
| commit | 6537db04f7e717eda2f21e007cdba7e13b7f559e (patch) | |
| tree | efb65bf3f305f376ea75f4f687b08bf8998c020f /common/accel-classic.hpp | |
| parent | Add class for storing settings from file (diff) | |
| parent | Merge pull request #6 from a1xd/st-refactor (diff) | |
| download | rawaccel-6537db04f7e717eda2f21e007cdba7e13b7f559e.tar.xz rawaccel-6537db04f7e717eda2f21e007cdba7e13b7f559e.zip | |
Show no settings for off, remove unused class for PR
Diffstat (limited to 'common/accel-classic.hpp')
| -rw-r--r-- | common/accel-classic.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common/accel-classic.hpp b/common/accel-classic.hpp new file mode 100644 index 0000000..1a2adca --- /dev/null +++ b/common/accel-classic.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include <math.h> + +#include "accel-base.hpp" + +namespace rawaccel { + + /// <summary> Struct to hold "classic" (linear raised to power) acceleration implementation. </summary> + struct accel_classic : accel_base { + double exponent; + + accel_classic(const accel_args& args) : accel_base(args) { + verify(args); + + 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) error("exponent must be greater than 1"); + } + }; + +} |