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

◆ compute()

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

Implements fl::XYPathGenerator.

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

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

References fl::cosf(), fl::FL_NO_EXCEPT, FL_PI, params(), fl::sinf(), fl::sqrtf(), fl::x, and fl::y.

+ Here is the call graph for this function: