FastLED 3.10.8
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 336 of file xypath_impls.cpp.hpp.

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

References fl::FL_NO_EXCEPT, fl::t, fl::x, and fl::y.

Referenced by compute().

+ Here is the caller graph for this function: