FastLED 3.9.15
Loading...
Searching...
No Matches
math_macros.h
Go to the documentation of this file.
1#pragma once
2
3namespace fl {
4// This is needed for math macro ABS to work optimally.
5template <typename T> inline T fl_abs(T value) {
6 return value < 0 ? -value : value;
7}
8} // namespace fl
9
10#ifndef MAX
11#define MAX(a, b) ((a) > (b) ? (a) : (b))
12#endif
13
14#ifndef MIN
15#define MIN(a, b) ((a) < (b) ? (a) : (b))
16#endif
17
18#ifndef ABS
19#define ABS(x) fl::fl_abs(x)
20#endif
21
22#ifndef EPSILON_F
23// smallest possible float
24#define EPSILON_F 1.19209290e-07F
25#endif
26
27#ifndef EPSILON_D
28// smallest possible double
29#define EPSILON_D 2.2204460492503131e-16
30#endif
31
32#ifndef ALMOST_EQUAL
33#define ALMOST_EQUAL(a, b, small) (ABS((a) - (b)) < small)
34#endif
35
36#ifndef ALMOST_EQUAL_FLOAT
37#define ALMOST_EQUAL_FLOAT(a, b) (ABS((a) - (b)) < EPSILON_F)
38#endif
39
40#ifndef ALMOST_EQUAL_DOUBLE
41#define ALMOST_EQUAL_DOUBLE(a, b) (ABS((a) - (b)) < EPSILON_F)
42#endif
43
44#ifndef INFINITY_DOUBLE
45#define INFINITY_DOUBLE (1.0 / 0.0)
46#endif
47
48#ifndef INFINITY_FLOAT
49#define INFINITY_FLOAT (1.0f / 0.0f)
50#endif
51
52#ifndef FLT_MAX
53#define FLT_MAX 3.402823466e+38F
54#endif
55
56#ifndef PI
57#define PI 3.1415926535897932384626433832795
58#endif
59
60#ifndef M_PI
61#define M_PI PI
62#endif
T fl_abs(T value)
Definition math_macros.h:5
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16