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

#include <math.h>

#include "accel-base.hpp"

namespace rawaccel {

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

		power_impl(const accel_args& args) :
			scale(args.scale), exponent(args.exponent)
		{}

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

	using accel_power = nonadditive_accel<power_impl>;

}