FastLED
3.9.15
Loading...
Searching...
No Matches
math_macros.h
Go to the documentation of this file.
1
#pragma once
2
3
namespace
fl
{
4
// This is needed for math macro ABS to work optimally.
5
template
<
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
41
42
#ifndef ALMOST_EQUAL_DOUBLE
43
#define ALMOST_EQUAL_EPSILON(a, b, epsilon) (ABS((a) - (b)) < (epsilon))
44
#endif
45
46
#ifndef ALMOST_EQUAL_DOUBLE
47
#define ALMOST_EQUAL_DOUBLE(a, b) ALMOST_EQUAL_EPSILON(a, b, EPSILON_F)
48
#endif
49
50
#ifndef INFINITY_DOUBLE
51
#define INFINITY_DOUBLE (1.0 / 0.0)
52
#endif
53
54
#ifndef INFINITY_FLOAT
55
#define INFINITY_FLOAT (1.0f / 0.0f)
56
#endif
57
58
#ifndef FLT_MAX
59
#define FLT_MAX 3.402823466e+38F
60
#endif
61
62
#ifndef PI
63
#define PI 3.1415926535897932384626433832795
64
#endif
65
66
#ifndef M_PI
67
#define M_PI PI
68
#endif
fl::fl_abs
T fl_abs(T value)
Definition
math_macros.h:5
fl
Implements a simple red square effect for 2D LED grids.
Definition
crgb.h:16
fl
math_macros.h
Generated on Mon Jun 16 2025 06:27:48 for FastLED by
1.13.2