FastLED 3.10.8
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1#pragma once
2
3// Centralized math functions for FastLED.
4//
5// All math lives here: basic ops (min/max/abs/clamp), transcendentals
6// (sin/cos/exp/log/pow/sqrt), rounding, angle conversion, and constants.
7//
8// Type dispatch:
9// float — explicit f-suffix overloads (sinf, cosf, etc.)
10// double — explicit non-template overloads (sin, cos, etc.)
11// integral — template promotes to float, returns float
12// fixed-point — overloads in fl/math/fixed_point.h (SFINAE-guarded)
13//
14// Backward-compatible headers fl/math_macros.h and fl/clamp.h still exist
15// and forward here.
16
18#include "fl/stl/int.h"
19#include "fl/stl/type_traits.h"
20#include "fl/stl/undef.h" // IWYU pragma: keep
21#include "fl/stl/noexcept.h"
22
23// ===== Constants =============================================================
24
25#ifndef FL_PI
26#define FL_PI 3.1415926535897932384626433832795
27#endif
28
29#ifndef FL_E
30#define FL_E 2.71828182845904523536
31#endif
32
33#ifndef FL_M_PI
34#define FL_M_PI FL_PI
35#endif
36
37#ifndef FL_EPSILON_F
38#define FL_EPSILON_F 1.19209290e-07F
39#endif
40
41#ifndef FL_EPSILON_D
42#define FL_EPSILON_D 2.2204460492503131e-16
43#endif
44
45#ifndef FL_INFINITY_FLOAT
46#define FL_INFINITY_FLOAT (1.0f / 0.0f)
47#endif
48
49#ifndef FL_INFINITY_DOUBLE
50#define FL_INFINITY_DOUBLE (1.0 / 0.0)
51#endif
52
53#ifndef FL_FLT_MAX
54#define FL_FLT_MAX 3.402823466e+38F
55#endif
56
57namespace fl {
58
59// ===== Basic: min, max, abs, clamp ===========================================
60
61template <typename T> constexpr inline T abs(T value) FL_NO_EXCEPT {
62 return value < 0 ? -value : value;
63}
64
70
71template <typename T, typename U> constexpr inline common_type_t<T, U> min(T a, U b) FL_NO_EXCEPT {
72 return (a < b) ? a : b;
73}
74
75template <typename T, typename U> constexpr inline common_type_t<T, U> max(T a, U b) FL_NO_EXCEPT {
76 return (a > b) ? a : b;
77}
78
80
81// lo/hi are their own template parameters, constrained to T, so this generic
82// clamp is less specialized than C++17 std::clamp(const T&, ...). Under
83// `using namespace std` an unqualified clamp on an fl type picks std::clamp
84// instead of tying (FastLED#4827); fl's fixed-point clamp overloads stay
85// more specialized than this one.
86template <typename T, typename L, typename H>
87FASTLED_FORCE_INLINE enable_if_t<is_same<T, L>::value && is_same<T, H>::value, T>
88clamp(T value, L lo, H hi) FL_NO_EXCEPT {
89 if (value < lo) return lo;
90 if (value > hi) return hi;
91 return value;
92}
93
94
95// ===== Approximate equality ===================================================
96
97template <typename T, typename U>
98constexpr inline bool almost_equal(T a, T b, U tolerance) FL_NO_EXCEPT {
99 return fl::abs(a - b) < tolerance;
100}
101
102inline bool almost_equal(float a, float b) FL_NO_EXCEPT {
103 return fl::abs(a - b) < FL_EPSILON_F;
104}
105
106inline bool almost_equal(double a, double b) FL_NO_EXCEPT {
107 return fl::abs(a - b) < FL_EPSILON_F;
108}
109
110// ===== Legacy macros (prefer fl:: functions directly) ========================
111
112#ifndef FL_MAX
113#define FL_MAX(a, b) fl::max(a, b)
114#endif
115
116#ifndef FL_MIN
117#define FL_MIN(a, b) fl::min(a, b)
118#endif
119
120#ifndef FL_ABS
121#define FL_ABS(x) fl::abs(x)
122#endif
123
124#ifndef FL_ALMOST_EQUAL
125#define FL_ALMOST_EQUAL(a, b, small) fl::almost_equal(a, b, small)
126#endif
127
128#ifndef FL_ALMOST_EQUAL_FLOAT
129#define FL_ALMOST_EQUAL_FLOAT(a, b) fl::almost_equal(static_cast<float>(a), static_cast<float>(b))
130#endif
131
132#ifndef FL_ALMOST_EQUAL_EPSILON
133#define FL_ALMOST_EQUAL_EPSILON(a, b, epsilon) fl::almost_equal(a, b, epsilon)
134#endif
135
136#ifndef FL_ALMOST_EQUAL_DOUBLE
137#define FL_ALMOST_EQUAL_DOUBLE(a, b) fl::almost_equal(static_cast<double>(a), static_cast<double>(b))
138#endif
139
140// ===== Map range =============================================================
141
144FL_DISABLE_WARNING(double-promotion)
149
150namespace map_range_detail {
151
152// Primary template for map_range_math
153template <typename T, typename U> struct map_range_math {
154 static U map(T value, T in_min, T in_max, U out_min, U out_max) FL_NO_EXCEPT {
155 if (in_min == in_max)
156 return out_min;
157 return out_min +
158 (value - in_min) * (out_max - out_min) / (in_max - in_min);
159 }
160};
161
162// Specialization for u8 -> u8
163template <> struct map_range_math<u8, u8> {
164 static u8 map(u8 value, u8 in_min, u8 in_max,
165 u8 out_min, u8 out_max) FL_NO_EXCEPT;
166};
167
168// Specialization for u16 -> u16
169template <> struct map_range_math<u16, u16> {
170 static u16 map(u16 value, u16 in_min, u16 in_max,
171 u16 out_min, u16 out_max) FL_NO_EXCEPT;
172};
173
174// Equality comparison helpers
175template <typename T> bool equals(T a, T b) FL_NO_EXCEPT { return a == b; }
176inline bool equals(float a, float b) FL_NO_EXCEPT { return fl::almost_equal(a, b); }
177inline bool equals(double d, double d2) FL_NO_EXCEPT { return fl::almost_equal(d, d2); }
178
179} // namespace map_range_detail
180
181template <typename T, typename U>
182FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min,
183 U out_max) FL_NO_EXCEPT {
184 if (map_range_detail::equals(value, in_min)) {
185 return out_min;
186 }
187 if (map_range_detail::equals(value, in_max)) {
188 return out_max;
189 }
190 return map_range_detail::map_range_math<T, U>::map(value, in_min, in_max, out_min, out_max);
191}
192
193template <typename T, typename U>
194FASTLED_FORCE_INLINE U map_range_clamped(T value, T in_min, T in_max, U out_min,
195 U out_max) FL_NO_EXCEPT {
196 value = clamp(value, in_min, in_max);
197 return map_range<T, U>(value, in_min, in_max, out_min, out_max);
198}
199
200namespace map_range_detail {
201
202inline u8 map_range_math<u8, u8>::map(u8 value, u8 in_min, u8 in_max,
203 u8 out_min, u8 out_max) FL_NO_EXCEPT {
204 if (value == in_min) {
205 return out_min;
206 }
207 if (value == in_max) {
208 return out_max;
209 }
210 i16 v16 = value;
211 i16 in_min16 = in_min;
212 i16 in_max16 = in_max;
213 i16 out_min16 = out_min;
214 i16 out_max16 = out_max;
215 i16 out16 = fl::map_range<i16, i16>(v16, in_min16, in_max16,
216 out_min16, out_max16);
217 if (out16 < 0) {
218 out16 = 0;
219 } else if (out16 > 255) {
220 out16 = 255;
221 }
222 return static_cast<u8>(out16);
223}
224
225inline u16 map_range_math<u16, u16>::map(u16 value, u16 in_min, u16 in_max,
226 u16 out_min, u16 out_max) FL_NO_EXCEPT {
227 if (value == in_min) {
228 return out_min;
229 }
230 if (value == in_max) {
231 return out_max;
232 }
233 u32 v32 = value;
234 u32 in_min32 = in_min;
235 u32 in_max32 = in_max;
236 u32 out_min32 = out_min;
237 u32 out_max32 = out_max;
238 u32 out32 = fl::map_range<u32, u32>(v32, in_min32, in_max32,
239 out_min32, out_max32);
240 if (out32 > 65535) {
241 out32 = 65535;
242 }
243 return static_cast<u16>(out32);
244}
245
246} // namespace map_range_detail
247
249
250// ===== Forward declarations (implementations in math.cpp.hpp) ================
251
255double ceil_impl_double(double value) FL_NO_EXCEPT;
257double exp_impl_double(double value) FL_NO_EXCEPT;
259double sqrt_impl_double(double value) FL_NO_EXCEPT;
261double sin_impl_double(double value) FL_NO_EXCEPT;
263double cos_impl_double(double value) FL_NO_EXCEPT;
265double log_impl_double(double value) FL_NO_EXCEPT;
268float pow_impl_float(float base, float exponent) FL_NO_EXCEPT;
269double pow_impl_double(double base, double exponent) FL_NO_EXCEPT;
271double fabs_impl_double(double value) FL_NO_EXCEPT;
276float fmod_impl_float(float x, float y) FL_NO_EXCEPT;
277double fmod_impl_double(double x, double y) FL_NO_EXCEPT;
278float atan2_impl_float(float y, float x) FL_NO_EXCEPT;
279double atan2_impl_double(double y, double x) FL_NO_EXCEPT;
280float hypot_impl_float(float x, float y) FL_NO_EXCEPT;
281double hypot_impl_double(double x, double y) FL_NO_EXCEPT;
283double atan_impl_double(double value) FL_NO_EXCEPT;
285double asin_impl_double(double value) FL_NO_EXCEPT;
287double acos_impl_double(double value) FL_NO_EXCEPT;
289double tan_impl_double(double value) FL_NO_EXCEPT;
290float ldexp_impl_float(float value, int exp) FL_NO_EXCEPT;
291double ldexp_impl_double(double value, int exp) FL_NO_EXCEPT;
292
293// ===== Constexpr helpers =====================================================
294
295constexpr int ceil_constexpr(float value) FL_NO_EXCEPT {
296 return static_cast<int>((value > static_cast<float>(static_cast<int>(value)))
297 ? static_cast<int>(value) + 1
298 : static_cast<int>(value));
299}
300
301// ===== Rounding ==============================================================
302//
303// Pattern for each function:
304// 1. Explicit float version (f-suffix, e.g. floorf)
305// 2. Explicit double version (no suffix, e.g. floor)
306// 3. Integral promotion template — accepts integer types, returns float
307//
308// Fixed-point overloads live in fl/math/fixed_point.h and are guarded by
309// enable_if<is_fixed_point<T>>, so there is no ambiguity.
310
311// floor
312inline float floorf(float value) FL_NO_EXCEPT { return floor_impl_float(value); }
313inline double floor(double value) FL_NO_EXCEPT { return floor_impl_double(value); }
314template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
315floor(T value) FL_NO_EXCEPT { return floor_impl_float(static_cast<float>(value)); }
316
317// ceil
318inline float ceilf(float value) FL_NO_EXCEPT { return ceil_impl_float(value); }
319inline double ceil(double value) FL_NO_EXCEPT { return ceil_impl_double(value); }
320template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
321ceil(T value) FL_NO_EXCEPT { return ceil_impl_float(static_cast<float>(value)); }
322
323// round — template form avoids "using fl::round" conflict with ::round
324inline float roundf(float value) FL_NO_EXCEPT { return round_impl_float(value); }
325template<typename T>
326inline typename enable_if<!is_integral<T>::value, T>::type
328 return static_cast<T>(round_impl_float(static_cast<float>(value)));
329}
330template<>
331inline double round<double>(double value) FL_NO_EXCEPT {
332 return round_impl_double(value);
333}
334template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
335round(T value) FL_NO_EXCEPT { return static_cast<float>(value); }
336
337// lround
338inline long lroundf(float value) FL_NO_EXCEPT { return lround_impl_float(value); }
339inline long lround(double value) FL_NO_EXCEPT { return lround_impl_double(value); }
340template<typename T> inline typename enable_if<is_integral<T>::value, long>::type
341lround(T value) FL_NO_EXCEPT { return static_cast<long>(value); }
342
343// fmod — template form avoids "using fl::fmod" conflict with ::fmod
344inline float fmodf(float x, float y) FL_NO_EXCEPT { return fmod_impl_float(x, y); }
345template<typename T>
346inline typename enable_if<!is_integral<T>::value, T>::type
348 return static_cast<T>(fmod_impl_float(static_cast<float>(x), static_cast<float>(y)));
349}
350template<>
351inline double fmod<double>(double x, double y) FL_NO_EXCEPT {
352 return fmod_impl_double(x, y);
353}
354template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
355fmod(T x, T y) FL_NO_EXCEPT { return fmod_impl_float(static_cast<float>(x), static_cast<float>(y)); }
356
357// ===== Trigonometry ==========================================================
358
359// sin
360inline float sinf(float value) FL_NO_EXCEPT { return sin_impl_float(value); }
361inline double sin(double value) FL_NO_EXCEPT { return sin_impl_double(value); }
362template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
363sin(T value) FL_NO_EXCEPT { return sin_impl_float(static_cast<float>(value)); }
364
365// cos
366inline float cosf(float value) FL_NO_EXCEPT { return cos_impl_float(value); }
367inline double cos(double value) FL_NO_EXCEPT { return cos_impl_double(value); }
368template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
369cos(T value) FL_NO_EXCEPT { return cos_impl_float(static_cast<float>(value)); }
370
371// tan
372inline float tanf(float value) FL_NO_EXCEPT { return tan_impl_float(value); }
373inline double tan(double value) FL_NO_EXCEPT { return tan_impl_double(value); }
374template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
375tan(T value) FL_NO_EXCEPT { return tan_impl_float(static_cast<float>(value)); }
376
377// ===== Inverse trigonometry ==================================================
378
379// asin
380inline float asinf(float value) FL_NO_EXCEPT { return asin_impl_float(value); }
381inline double asin(double value) FL_NO_EXCEPT { return asin_impl_double(value); }
382template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
383asin(T value) FL_NO_EXCEPT { return asin_impl_float(static_cast<float>(value)); }
384
385// acos
386inline float acosf(float value) FL_NO_EXCEPT { return acos_impl_float(value); }
387inline double acos(double value) FL_NO_EXCEPT { return acos_impl_double(value); }
388template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
389acos(T value) FL_NO_EXCEPT { return acos_impl_float(static_cast<float>(value)); }
390
391// atan
392inline float atanf(float value) FL_NO_EXCEPT { return atan_impl_float(value); }
393inline double atan(double value) FL_NO_EXCEPT { return atan_impl_double(value); }
394template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
395atan(T value) FL_NO_EXCEPT { return atan_impl_float(static_cast<float>(value)); }
396
397// atan2
398inline float atan2f(float y, float x) FL_NO_EXCEPT { return atan2_impl_float(y, x); }
399inline double atan2(double y, double x) FL_NO_EXCEPT { return atan2_impl_double(y, x); }
400template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
401atan2(T y, T x) FL_NO_EXCEPT { return atan2_impl_float(static_cast<float>(y), static_cast<float>(x)); }
402
403// ===== Exponential / logarithmic =============================================
404
405// exp
406inline float expf(float value) FL_NO_EXCEPT { return exp_impl_float(value); }
407inline double exp(double value) FL_NO_EXCEPT { return exp_impl_double(value); }
408template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
409exp(T value) FL_NO_EXCEPT { return exp_impl_float(static_cast<float>(value)); }
410
411// log (natural) - fast approximate version
412// Uses IEEE 754 bit extraction + minimax quadratic. ~1.5% max relative error.
413// ~5-10x faster than standard logf on embedded targets.
414inline float fast_logf_approx(float x) FL_NO_EXCEPT {
415 union { float f; u32 i; } u;
416 u.f = x;
417 i32 e = static_cast<i32>(u.i >> 23) - 127;
418 u.i = (u.i & 0x007FFFFFu) | 0x3F800000u;
419 float m = u.f;
420 float t = m - 1.0f;
421 float log2m = t * (1.3327635f + t * (-0.3327635f));
422 return (static_cast<float>(e) + log2m) * 0.6931471805599453f;
423}
424
425// log (natural)
426inline float logf(float value) FL_NO_EXCEPT { return log_impl_float(value); }
427inline double log(double value) FL_NO_EXCEPT { return log_impl_double(value); }
428template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
429log(T value) FL_NO_EXCEPT { return log_impl_float(static_cast<float>(value)); }
430
431// log10
432inline float log10f(float value) FL_NO_EXCEPT { return log10_impl_float(value); }
433inline double log10(double value) FL_NO_EXCEPT { return log10_impl_double(value); }
434template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
435log10(T value) FL_NO_EXCEPT { return log10_impl_float(static_cast<float>(value)); }
436
437// log2
438inline float log2f(float value) FL_NO_EXCEPT { return log_impl_float(value) / log_impl_float(2.0f); }
439inline double log2(double value) FL_NO_EXCEPT { return log_impl_double(value) / log_impl_double(2.0); }
440template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
441log2(T value) FL_NO_EXCEPT { return log_impl_float(static_cast<float>(value)) / log_impl_float(2.0f); }
442
443// pow
444inline float powf(float base, float exponent) FL_NO_EXCEPT { return pow_impl_float(base, exponent); }
445inline double pow(double base, double exponent) FL_NO_EXCEPT { return pow_impl_double(base, exponent); }
446template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
447pow(T base, T exponent) FL_NO_EXCEPT { return pow_impl_float(static_cast<float>(base), static_cast<float>(exponent)); }
448
449// ===== Roots / distance ======================================================
450
451namespace sqrt_detail {
452// Type trait to detect if T has a static sqrt method
453template<typename T, typename = void>
455
456template<typename T>
457struct has_static_sqrt<T, decltype(static_cast<void>(T::sqrt(declval<T>())))> : true_type {};
458}
459
460// sqrt
461inline float sqrtf(float value) FL_NO_EXCEPT { return sqrt_impl_float(value); }
462inline float sqrt(float value) FL_NO_EXCEPT { return sqrt_impl_float(value); }
463inline double sqrt(double value) FL_NO_EXCEPT { return sqrt_impl_double(value); }
464template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
465sqrt(T value) FL_NO_EXCEPT { return sqrt_impl_float(static_cast<float>(value)); }
466
467// Generic sqrt that auto-binds to types with static sqrt method
468// If T doesn't have a static sqrt, this overload is discarded (SFINAE)
469template<typename T>
470inline typename enable_if<sqrt_detail::has_static_sqrt<T>::value, decltype(T::sqrt(declval<T>()))>::type
472 return T::sqrt(value);
473}
474
475namespace floor_detail {
476// Type trait to detect if T has a static floor method
477template<typename T, typename = void>
479
480template<typename T>
481struct has_static_floor<T, decltype(static_cast<void>(T::floor(declval<T>())))> : true_type {};
482}
483
484// Generic floor that auto-binds to types with static floor method
485template<typename T>
486inline typename enable_if<floor_detail::has_static_floor<T>::value, decltype(T::floor(declval<T>()))>::type
488 return T::floor(value);
489}
490
491namespace ceil_detail {
492// Type trait to detect if T has a static ceil method
493template<typename T, typename = void>
495
496template<typename T>
497struct has_static_ceil<T, decltype(static_cast<void>(T::ceil(declval<T>())))> : true_type {};
498}
499
500// Generic ceil that auto-binds to types with static ceil method
501template<typename T>
502inline typename enable_if<ceil_detail::has_static_ceil<T>::value, decltype(T::ceil(declval<T>()))>::type
504 return T::ceil(value);
505}
506
507// hypot
508inline float hypotf(float x, float y) FL_NO_EXCEPT { return hypot_impl_float(x, y); }
509inline double hypot(double x, double y) FL_NO_EXCEPT { return hypot_impl_double(x, y); }
510template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
511hypot(T x, T y) FL_NO_EXCEPT { return hypot_impl_float(static_cast<float>(x), static_cast<float>(y)); }
512
513// ===== Floating-point utilities ==============================================
514
515// fabs
516inline float fabsf(float value) FL_NO_EXCEPT { return fabs_impl_float(value); }
517inline double fabs(double value) FL_NO_EXCEPT { return fabs_impl_double(value); }
518template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
519fabs(T value) FL_NO_EXCEPT { return fabs_impl_float(static_cast<float>(value)); }
520
521// ldexp — multiply by power of 2: value * 2^exp
522inline float ldexpf(float value, int exp) FL_NO_EXCEPT { return ldexp_impl_float(value, exp); }
523inline double ldexp(double value, int exp) FL_NO_EXCEPT { return ldexp_impl_double(value, exp); }
524template<typename T> inline typename enable_if<is_integral<T>::value, float>::type
525ldexp(T value, int exp) FL_NO_EXCEPT { return ldexp_impl_float(static_cast<float>(value), exp); }
526
527// ===== Angle conversion ======================================================
528
529template<typename T>
530constexpr inline T radians(T deg) FL_NO_EXCEPT {
531 return deg * static_cast<T>(0.017453292519943295); // PI / 180
532}
533
534template<typename T>
535constexpr inline T degrees(T rad) FL_NO_EXCEPT {
536 return rad * static_cast<T>(57.29577951308232); // 180 / PI
537}
538
539// ===== sincos ================================================================
540
541// sincos(angle, &out_sin, &out_cos) for floating-point types
542template <typename T>
543inline typename enable_if<is_floating_point<T>::value>::type
544sincos(T angle, T& out_sin, T& out_cos) FL_NO_EXCEPT {
545 out_sin = static_cast<T>(fl::sinf(static_cast<float>(angle)));
546 out_cos = static_cast<T>(fl::cosf(static_cast<float>(angle)));
547}
548
549// sincos(angle, &out_sin, &out_cos) for integral types
550template <typename T>
551inline typename enable_if<is_integral<T>::value>::type
552sincos(T angle, float& out_sin, float& out_cos) FL_NO_EXCEPT {
553 out_sin = fl::sinf(static_cast<float>(angle));
554 out_cos = fl::cosf(static_cast<float>(angle));
555}
556
557} // namespace fl
static const int H
Definition PerfDisc.ino:21
unsigned char u8
Definition stdint.h:131
#define FL_EPSILON_F
Definition math.h:38
bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2) FL_NO_EXCEPT
Definition algorithm.h:99
float logf(float value) FL_NO_EXCEPT
Definition math.h:426
float acosf(float value) FL_NO_EXCEPT
Definition math.h:386
double ceil_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:71
unsigned char u8
Definition stdint.h:131
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
Definition math.h:75
enable_if< is_fixed_point< T >::value, T >::type sin(T angle) FL_NO_EXCEPT
double fabs_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:441
typename common_type< T, U >::type common_type_t
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
constexpr int type_rank< T >::value
long lround_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:445
double ldexp_impl_double(double value, int exp) FL_NO_EXCEPT
Definition math.cpp.hpp:735
constexpr bool almost_equal(T a, T b, U tolerance) FL_NO_EXCEPT
Definition math.h:98
double tan_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:680
double sin_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:346
double hypot(double x, double y) FL_NO_EXCEPT
Definition math.h:509
float hypotf(float x, float y) FL_NO_EXCEPT
Definition math.h:508
enable_if< is_fixed_point< T >::value, T >::type cos(T angle) FL_NO_EXCEPT
MapRedBlackTree< Key, T, Compare, fl::allocator_slab< char > > map
Definition map.h:283
float log2f(float value) FL_NO_EXCEPT
Definition math.h:438
float asinf(float value) FL_NO_EXCEPT
Definition math.h:380
add_rvalue_reference< T >::type declval() FL_NO_EXCEPT
enable_if<!is_integral< T >::value, T >::type fmod(T x, T y) FL_NO_EXCEPT
Definition math.h:347
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
Definition math.h:71
float sqrt_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:322
float tanf(float value) FL_NO_EXCEPT
Definition math.h:372
float sinf(float value) FL_NO_EXCEPT
Definition math.h:360
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NO_EXCEPT
float fast_logf_approx(float x) FL_NO_EXCEPT
Definition math.h:414
double fmod_impl_double(double x, double y) FL_NO_EXCEPT
Definition math.cpp.hpp:495
float atan2f(float y, float x) FL_NO_EXCEPT
Definition math.h:398
enable_if< is_fixed_point< T >::value, T >::type atan2(T y, T x) FL_NO_EXCEPT
float exp_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:201
double ldexp(double value, int exp) FL_NO_EXCEPT
Definition math.h:523
integral_constant< bool, false > false_type
Definition type_traits.h:29
float floor_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:44
constexpr enable_if< is_fixed_point< T >::value, T >::type ceil(T x) FL_NO_EXCEPT
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max) FL_NO_EXCEPT
Definition math.h:182
enable_if< is_fixed_point< T >::value, T >::type acos(T x) FL_NO_EXCEPT
double sqrt_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:330
double floor_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:53
long lround(double value) FL_NO_EXCEPT
Definition math.h:339
double pow_impl_double(double base, double exponent) FL_NO_EXCEPT
Definition math.cpp.hpp:420
float atanf(float value) FL_NO_EXCEPT
Definition math.h:392
double acos_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:661
long lround_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:454
float atan_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:610
FASTLED_FORCE_INLINE U map_range_clamped(T value, T in_min, T in_max, U out_min, U out_max) FL_NO_EXCEPT
Definition math.h:194
float sin_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:338
float log10f(float value) FL_NO_EXCEPT
Definition math.h:432
enable_if< is_fixed_point< T >::value, T >::type atan(T x) FL_NO_EXCEPT
float acos_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:652
float pow_impl_float(float base, float exponent) FL_NO_EXCEPT
Definition math.cpp.hpp:404
float hypot_impl_float(float x, float y) FL_NO_EXCEPT
Definition math.cpp.hpp:594
enable_if< is_fixed_point< T >::value, void >::type sincos(T angle, T &out_sin, T &out_cos) FL_NO_EXCEPT
float ceil_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:62
double asin_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:639
constexpr int ceil_constexpr(float value) FL_NO_EXCEPT
Definition math.h:295
double atan_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:618
enable_if< is_fixed_point< T >::value, T >::type pow(T base, T exp) FL_NO_EXCEPT
double cos_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:362
double log(double value) FL_NO_EXCEPT
Definition math.h:427
float sqrtf(float value) FL_NO_EXCEPT
Definition math.h:461
double log10(double value) FL_NO_EXCEPT
Definition math.h:433
float round_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:466
enable_if< is_fixed_point< T >::value, T >::type asin(T x) FL_NO_EXCEPT
double round< double >(double value) FL_NO_EXCEPT
Definition math.h:331
double tan(double value) FL_NO_EXCEPT
Definition math.h:373
double fabs(double value) FL_NO_EXCEPT
Definition math.h:517
float log_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:370
float fmodf(float x, float y) FL_NO_EXCEPT
Definition math.h:344
double log2(double value) FL_NO_EXCEPT
Definition math.h:439
float cosf(float value) FL_NO_EXCEPT
Definition math.h:366
double fmod< double >(double x, double y) FL_NO_EXCEPT
Definition math.h:351
float fabsf(float value) FL_NO_EXCEPT
Definition math.h:516
float roundf(float value) FL_NO_EXCEPT
Definition math.h:324
float powf(float base, float exponent) FL_NO_EXCEPT
Definition math.h:444
float log10_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:386
float floorf(float value) FL_NO_EXCEPT
Definition math.h:312
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NO_EXCEPT
double round_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:474
double log_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:378
constexpr T degrees(T rad) FL_NO_EXCEPT
Definition math.h:535
float ldexp_impl_float(float value, int exp) FL_NO_EXCEPT
Definition math.cpp.hpp:727
float ceilf(float value) FL_NO_EXCEPT
Definition math.h:318
double atan2_impl_double(double y, double x) FL_NO_EXCEPT
Definition math.cpp.hpp:586
double hypot_impl_double(double x, double y) FL_NO_EXCEPT
Definition math.cpp.hpp:602
long lroundf(float value) FL_NO_EXCEPT
Definition math.h:338
float tan_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:670
constexpr enable_if< is_fixed_point< T >::value, T >::type sqrt(T x) FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, int >::type sign(T x) FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NO_EXCEPT
float asin_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:626
integral_constant< bool, true > true_type
Definition type_traits.h:28
float expf(float value) FL_NO_EXCEPT
Definition math.h:406
double exp_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:202
constexpr T radians(T deg) FL_NO_EXCEPT
Definition math.h:530
double log10_impl_double(double value) FL_NO_EXCEPT
Definition math.cpp.hpp:395
float fabs_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:437
float cos_impl_float(float value) FL_NO_EXCEPT
Definition math.cpp.hpp:354
float atan2_impl_float(float y, float x) FL_NO_EXCEPT
Definition math.cpp.hpp:578
constexpr enable_if< is_fixed_point< T >::value, T >::type floor(T x) FL_NO_EXCEPT
float ldexpf(float value, int exp) FL_NO_EXCEPT
Definition math.h:522
float fmod_impl_float(float x, float y) FL_NO_EXCEPT
Definition math.cpp.hpp:483
Base definition for an LED controller.
#define FL_DISABLE_WARNING(warning)
#define FL_DISABLE_WARNING_IMPLICIT_INT_CONVERSION
#define FASTLED_FORCE_INLINE
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_SIGN_CONVERSION
#define FL_DISABLE_WARNING_POP
#define FL_NO_EXCEPT
#define FL_DISABLE_WARNING_FLOAT_CONVERSION
#define round(x)
Definition util.h:11