scsl  1.1.1
Shimmering Clarity Standard Library
Math.h
Go to the documentation of this file.
1 
25 #ifndef SCSL_SCMP_MATH_H
26 #define SCSL_SCMP_MATH_H
27 
28 #include <cmath>
29 #include <vector>
30 
31 namespace scmp {
32 
33 
35 constexpr double MAX_RADIAN = 2 * M_PI;
36 constexpr double MIN_RADIAN = -2 * M_PI;
37 constexpr double PI_D = 3.141592653589793;
38 
39 
41 std::vector<int> Die(int m, int n);
42 
44 int DieTotal(int m, int n);
45 
47 int BestDie(int k, int m, int n);
48 
49 
54 float RadiansToDegreesF(float rads);
55 
60 double RadiansToDegreesD(double rads);
61 
66 float DegreesToRadiansF(float degrees);
67 
72 double DegreesToRadiansD(double degrees);
73 
80 double RotateRadians(double theta0, double theta1);
81 
85 void DefaultEpsilon(double &epsilon);
86 
90 void DefaultEpsilon(float &epsilon);
91 
92 
96 void DefaultEpsilon(int& epsilon);
97 
98 
110 template <typename T>
111 static T
112 WithinTolerance(T a, T b, T epsilon)
113 {
114  return std::abs(a - b) <= epsilon;
115 }
116 
117 
118 } // namespace scmp
119 
120 
121 #endif //SCSL_SCMP_MATH_H
Shimmering Clarity Math & Physics toolkit.
Definition: estimation.h:31
double RotateRadians(double theta0, double theta1)
RotateRadians rotates theta0 by theta1 radians, wrapping the result to MIN_RADIAN <= result <= MAX_RA...
double RadiansToDegreesD(double rads)
Convert radians to degrees.
std::vector< int > Die(int m, int n)
Roll m die of n sides, returning a vector of the dice.
float DegreesToRadiansF(float degrees)
Convert degrees to radians.
constexpr double MIN_RADIAN
Definition: Math.h:36
double DegreesToRadiansD(double degrees)
Convert degrees to radians.
void DefaultEpsilon(double &epsilon)
Get the default epsilon value.
int BestDie(int k, int m, int n)
Roll m die of n sides, and take the total of the top k die.
float RadiansToDegreesF(float rads)
Convert radians to degrees.
constexpr double MAX_RADIAN
MAX_RADIAN is a precomputed 2 * M_PI.
Definition: Math.h:35
int DieTotal(int m, int n)
Roll m die of n sides, returning the total of the die.
constexpr double PI_D
Definition: Math.h:37