-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmathutils.h
84 lines (76 loc) · 2.84 KB
/
mathutils.h
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef MATHUTILS_H
#define MATHUTILS_H
#include "vector2d.h"
#include <random>
/**
* @brief The MathUtils class
* This class concentrates functions not present in cmath
*/
class MathUtils
{
public:
MathUtils();
/**
* Finds the value corresponding to x scaled between min and max with a smoothed scale
* @param[in] min the minimal value of the new scale
* @param[in] max the maximal value of the new scale
* @param[in] x the value to process
* @return the new value of x, between min and max
*/
static double fonctionQuadratique(double min, double max, double x);
/**
* Find the value corresponding to x scaled between min and max, from max to min
* @param[in] min the minimal value of the scale
* @param[in] max the maximal value of the scale
* @param[in] x the value to process
* @see fonctionQuadratique()
* @return the new value of x, between max and min
*/
static double fonctionQuadratiqueInv(double min, double max, double x);
/**
* Cubic interpolation of a value, t, contained between p0 and p1
* @param[in] before_p0 the value before p0
* @param[in] p0 the value before t
* @param[in] p1 the value after t
* @param[in] after_p1 the value after p1
* @param[in] t the place of the value to find, between p0 and p1
* @return the cubic interpolation of t
*/
static double interpolate(double before_p0, double p0, double p1, double after_p1, double t);
/**
* Reverses the value after a certain threshold
* @param[in] n the value before the ridge
* @param[in] s the threshold to apply
* @return 2*s-n if n > s, n else
*/
static double ridge(double n, double s);
/**
* Takes two doubles and returns the rest of a - X*b as long as a > X*b
* @param[in] a the divided
* @param[in] b the divisor
* @return minimal positive value of a - X*b with a > X*b
*/
static double mod(double a, double b);
/**
* The absolute value of a double
* @param[in] d the double we want the absolute value
* @return the absolute value of d
*/
static double dabs(double d);
/**
* @brief aireTriangle Calculates the area of a triangle, based on three points
* @param[in] a The first vertex of the triangle
* @param[in] b The second vertex of the triangle
* @param[in] c The third vertex of the triangle
* @return The area of the triangle.
*/
static double aireTriangle(const Vector2D & a, const Vector2D & b, const Vector2D & c);
/**
* @brief random Returns a random value contained between min and max
* @param[in] min The minimal value of the random
* @param[in] max The maximal value of the random
* @return A random value between min and max
*/
static double random(double min, double max);
};
#endif // MATHUTILS_H