summaryrefslogtreecommitdiff
path: root/common/accel-power.hpp
blob: a21f926c1edac12233a2258223234e9b0a335d4c (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
#pragma once

#include "rawaccel-base.hpp"

#include <math.h>

namespace rawaccel {

	/// <summary> Struct to hold power (non-additive) acceleration implementation. </summary>
	struct power {
		double pre_scale;
		double exponent;
		double post_scale;

		power(const accel_args& args) :
			pre_scale(args.scale), 
			exponent(args.exponent),
			post_scale(args.weight) {}

		double operator()(double speed) const 
		{
			// f(x) = (mx)^k
			return post_scale * pow(speed * pre_scale, exponent);
		}
	};

	using power_legacy = power;
}