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

#include <math.h>

#include "accel-natural.hpp"

namespace rawaccel {

	/// <summary> Struct to hold "natural" (vanishing difference) gain implementation. </summary>
	struct naturalgain_impl : natural_impl {

		using natural_impl::natural_impl;

		inline double operator()(double speed) const {
			// f(x) = k((e^(-mx)-1)/mx + 1)
			double scaled_speed = rate * speed;
			return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1);
		}
		
	};

	using accel_naturalgain = additive_accel<naturalgain_impl>;
}