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

◆ interpolate()

vec2f fl::CatmullRomPath::interpolate ( const vec2f & p0,
const vec2f & p1,
const vec2f & p2,
const vec2f & p3,
float t ) const
private

Definition at line 335 of file xypath_impls.cpp.

337 {
338
339 // Catmull-Rom interpolation formula
340 // Using alpha=0.5 for the "tension" parameter (standard Catmull-Rom)
341 float t2 = t * t;
342 float t3 = t2 * t;
343
344 // Coefficients for x and y
345 float a = -0.5f * p0.x + 1.5f * p1.x - 1.5f * p2.x + 0.5f * p3.x;
346 float b = p0.x - 2.5f * p1.x + 2.0f * p2.x - 0.5f * p3.x;
347 float c = -0.5f * p0.x + 0.5f * p2.x;
348 float d = p1.x;
349
350 float x = a * t3 + b * t2 + c * t + d;
351
352 a = -0.5f * p0.y + 1.5f * p1.y - 1.5f * p2.y + 0.5f * p3.y;
353 b = p0.y - 2.5f * p1.y + 2.0f * p2.y - 0.5f * p3.y;
354 c = -0.5f * p0.y + 0.5f * p2.y;
355 d = p1.y;
356
357 float y = a * t3 + b * t2 + c * t + d;
358
359 return vec2f(x, y);
360}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
vec2< float > vec2f
Definition geometry.h:151

References fl::vec2< T >::x, x, fl::vec2< T >::y, and y.

Referenced by compute().

+ Here is the caller graph for this function: