scsl 1.0.1
Shimmering Clarity Standard Library
Loading...
Searching...
No Matches
Math.h
Go to the documentation of this file.
1
24
25#ifndef SCSL_SCMP_MATH_H
26#define SCSL_SCMP_MATH_H
27
28#include <cmath>
29#include <vector>
30
31namespace scmp {
32
33
35constexpr double MAX_RADIAN = 2 * M_PI;
36constexpr double MIN_RADIAN = -2 * M_PI;
37constexpr double PI_D = 3.141592653589793;
38
39
41std::vector<int> Die(int m, int n);
42
44int DieTotal(int m, int n);
45
47int BestDie(int k, int m, int n);
48
49
54float RadiansToDegreesF(float rads);
55
60double RadiansToDegreesD(double rads);
61
66float DegreesToRadiansF(float degrees);
67
72double DegreesToRadiansD(double degrees);
73
80double RotateRadians(double theta0, double theta1);
81
85void DefaultEpsilon(double &epsilon);
86
90void DefaultEpsilon(float &epsilon);
91
92
96void DefaultEpsilon(int& epsilon);
97
98
110template <typename T>
111static T
112WithinTolerance(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.
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.
std::vector< int > Die(int m, int n)
Roll m die of n sides, returning a vector of the dice.
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