FastLED 3.10.8
Loading...
Searching...
No Matches

◆ compute()

vec2f fl::ArchimedeanSpiralPath::compute ( float alpha)
overridevirtual

Implements fl::XYPathGenerator.

Definition at line 86 of file xypath_impls.cpp.hpp.

86 {
87 // Parametric equation for an Archimedean spiral
88 // α in [0,1] → (x,y) on the spiral curve
89
90 // Calculate the angle based on the number of turns
91 float theta = alpha * 2.0f * FL_PI * mTurns;
92
93 // Calculate the radius at this angle (grows linearly with angle)
94 // Scale by alpha to ensure we start at center and grow outward
95 float r = alpha * mRadius;
96
97 // Convert polar coordinates (r, theta) to Cartesian (x, y)
98 float x = r * cosf(theta);
99 float y = r * sinf(theta);
100
101 // Ensure the spiral fits within [-1, 1] range
102 // No additional scaling needed as we control the radius directly
103
104 return vec2f(x, y);
105}
#define FL_PI
Definition math.h:26
float sinf(float value) FL_NO_EXCEPT
Definition math.h:360
vec2< float > vec2f
Definition geometry.h:333
float cosf(float value) FL_NO_EXCEPT
Definition math.h:366

References fl::cosf(), fl::FL_NO_EXCEPT, FL_PI, mRadius, mTurns, fl::sinf(), fl::x, and fl::y.

+ Here is the call graph for this function: