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

◆ compute()

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

Implements fl::XYPathGenerator.

Definition at line 139 of file xypath_impls.cpp.

139 {
140 // total number of points you want in the pattern
141 const float N = static_cast<float>(params().c);
142
143 // continuous “index” from 0…N
144 float n = alpha * N;
145
146 // use the golden angle in radians:
147 // π * (3 – √5) ≈ 2.399963229728653
148 constexpr float goldenAngle = PI * (3.0f - 1.6180339887498948f);
149
150 // normalized radius [0…1]: sqrt(n/N) gives uniform point density
151 float r = sqrtf(n / N);
152
153 // spiral angle
154 float theta = n * goldenAngle;
155
156 // polar → Cartesian
157 float x = r * cosf(theta);
158 float y = r * sinf(theta);
159
160 return vec2f{x, y};
161}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
PhyllotaxisParams & params()
#define PI
Definition math_macros.h:57
vec2< float > vec2f
Definition geometry.h:151

References fl::PhyllotaxisParams::c, params(), PI, x, and y.

+ Here is the call graph for this function: