summaryrefslogtreecommitdiff
path: root/common/accel-classic.hpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-07-30 17:07:35 -0400
committera1xd <[email protected]>2020-07-30 17:07:35 -0400
commite8417a29fb2153ea035a757f36bfa300cf8b480d (patch)
tree802905bbf262196678e140463150e66d0a674b01 /common/accel-classic.hpp
parentMerge remote-tracking branch 'downstream/Inheritance' into st-refactor (diff)
downloadrawaccel-e8417a29fb2153ea035a757f36bfa300cf8b480d.tar.xz
rawaccel-e8417a29fb2153ea035a757f36bfa300cf8b480d.zip
add tweaks for st-refactor
Diffstat (limited to 'common/accel-classic.hpp')
-rw-r--r--common/accel-classic.hpp29
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..e2eb494
--- /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(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(accel_args args) const {
+ if (args.exponent <= 1) error("exponent must be greater than 1");
+ }
+ };
+
+}