12constexpr float pi = 3.1415926535897932384626433f;
16 return f > 0 ? (int)(f + 0.5f) : (int)(f - 0.5f);
24template<
typename T,
typename TB>
25constexpr inline T
mix(
const T a,
const T b, TB amount)
27 return a + (b - a) * amount;
30template<
typename T,
typename TB>
31inline T
bezier(
const T p0,
const T p1,
const T p2,
const T p3, TB amount)
34 const T c10 =
mix(p0, p1, amount);
35 const T c11 =
mix(p1, p2, amount);
36 const T c12 =
mix(p2, p3, amount);
38 const T c20 =
mix(c10, c11, amount);
39 const T c21 =
mix(c11, c12, amount);
41 return mix(c20, c21, amount);
46 return rand() / (float)(RAND_MAX);
61 return 2.0f *
pi * (rand() / std::nextafter((
float)RAND_MAX, std::numeric_limits<float>::max()));
67constexpr inline int f2fx(
float v)
71constexpr inline float fx2f(
int v)
77constexpr inline int i2fx(
int v)
81constexpr inline int fx2i(
int v)
113 operator float()
const
122 return std::min(a, b);
127 return std::min(std::min(a, b), c);
132 return std::max(a, b);
137 return std::max(std::max(a, b), c);
142 return a < T(0) ? -a : a;
148 return lower <= a && a <= upper;
void set(int v)
Definition: math.h:91
int value
Definition: math.h:88
int get() const
Definition: math.h:95
fxp & operator=(float v)
Definition: math.h:104
fxp & operator=(int v)
Definition: math.h:99
constexpr float pi
Definition: math.h:12
constexpr T minimum(T a, T b)
Definition: math.h:120
float random_float()
Definition: math.h:44
constexpr int fx2i(int v)
Definition: math.h:81
constexpr int fxpscale
Definition: math.h:64
constexpr float fx2f(int v)
Definition: math.h:71
constexpr T in_range(T a, T lower, T upper)
Definition: math.h:146
float random_angle()
Definition: math.h:59
constexpr T mix(const T a, const T b, TB amount)
Definition: math.h:25
constexpr int i2fx(int v)
Definition: math.h:77
constexpr int round_to_int(float f)
Definition: math.h:14
constexpr T maximum(T a, T b)
Definition: math.h:130
constexpr int f2fx(float v)
Definition: math.h:67
constexpr int round_truncate(float f)
Definition: math.h:19
constexpr T absolute(T a)
Definition: math.h:140
T bezier(const T p0, const T p1, const T p2, const T p3, TB amount)
Definition: math.h:31