FastLED 3.9.15
Loading...
Searching...
No Matches

◆ easeInOutSine16()

u16 fl::easeInOutSine16 ( u16 i)

16-bit sine ease-in/ease-out function Takes an input value 0-65535 and returns an eased value 0-65535

Definition at line 326 of file ease.cpp.hpp.

326 {
327 // ease-in-out sine: -(cos(π*t) - 1) / 2
328 // Handle boundary conditions explicitly
329 if (i == 0)
330 return 0;
331 if (i == 65535)
332 return 65535;
333
334 // For 16-bit: use cos32 for efficiency and accuracy
335 // Map i from [0,65535] to [0,8388608] in cos32 space (0 to half wave)
336 // Formula: (1 - cos(π*t)) / 2 where t goes from 0 to 1
337 // sin32/cos32 half cycle is 16777216/2 = 8388608
338 u32 angle = ((fl::u64)i * 8388608ULL) / 65535ULL;
339 i32 cos_result = fl::cos32(angle);
340
341 // Convert cos32 output and apply easing formula: (1 - cos(π*t)) / 2
342 // cos32 output range is [-2147418112, 2147418112]
343 // We want: (2147418112 - cos_result) / 2, then scale to [0, 65535]
344 fl::i64 adjusted = (2147418112LL - (fl::i64)cos_result) / 2;
345 return (u16)((fl::u64)adjusted * 65535ULL / 2147418112ULL);
346}
FASTLED_FORCE_INLINE i32 cos32(u32 angle) FL_NOEXCEPT
Definition sin32.h:81
fl::i64 i64
Definition s16x16x4.h:222
fl::u64 u64
Definition s16x16x4.h:221

References cos32().

Referenced by ease16(), ease16(), and easeInOutSine8().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: