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

◆ compute()

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

Implements fl::XYPathGenerator.

Definition at line 85 of file xypath_impls.cpp.

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

References mRadius, mTurns, PI, x, and y.