blob: 1a2adca79f61148ef6ec5d9312bae4ea549f33d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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");
}
};
}
|