MCPcopy Create free account
hub / github.com/FastLED/FastLED / easeOutSine16

Function easeOutSine16

src/fl/math/ease.cpp.hpp:305–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305u16 easeOutSine16(u16 i) {
306 // ease-out sine: sin(t * π/2)
307 // Handle boundary conditions explicitly
308 if (i == 0)
309 return 0;
310 if (i == 65535)
311 return 65535;
312
313 // For 16-bit: use sin32 for efficiency and accuracy
314 // Map i from [0,65535] to [0,4194304] in sin32 space (zero to quarter wave)
315 // Formula: sin(t * π/2) where t goes from 0 to 1
316 // sin32 quarter cycle is 16777216/4 = 4194304
317 u32 angle = ((fl::u64)i * 4194304ULL) / 65535ULL;
318 i32 sin_result = fl::sin32(angle);
319
320 // Convert sin32 output range [-2147418112, 2147418112] to [0, 65535]
321 // sin32 output is in range -32767*65536 to +32767*65536
322 // For ease-out sine, we only use positive portion [0, 2147418112] -> [0, 65535]
323 return (u16)((fl::u64)sin_result * 65535ULL / 2147418112ULL);
324}
325
326u16 easeInOutSine16(u16 i) {
327 // ease-in-out sine: -(cos(π*t) - 1) / 2

Callers 2

ease16Function · 0.85
easeOutSine8Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected