diff options
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"); + } + }; + +} |