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

◆ compute()

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

Implements fl::XYPathGenerator.

Definition at line 163 of file xypath_impls.cpp.

163 {
164 // 1) map alpha to angle θ ∈ [0 … 2π)
165 constexpr float kTwoPi = 6.283185307179586f;
166 float theta = alpha * kTwoPi;
167
168 // 2) superformula parameters (members of your path)
169 // a, b control the “shape scale” (often both = 1)
170 // m controls symmetry (integer number of lobes)
171 // n1,n2,n3 control curvature/sharpness
172 float a = params().a;
173 float b = params().b;
174 float m = params().m;
175 float n1 = params().n1;
176 float n2 = params().n2;
177 float n3 = params().n3;
178
179 // 3) compute radius from superformula
180 float t2 = m * theta / 4.0f;
181 float part1 = powf(fabsf(cosf(t2) / a), n2);
182 float part2 = powf(fabsf(sinf(t2) / b), n3);
183 float r = powf(part1 + part2, -1.0f / n1);
184
185 // 4) polar → Cartesian in unit circle
186 float x = r * cosf(theta);
187 float y = r * sinf(theta);
188
189 return vec2f{x, y};
190}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
GielisCurveParams & params()
vec2< float > vec2f
Definition geometry.h:151

References fl::GielisCurveParams::a, fl::GielisCurveParams::b, fl::GielisCurveParams::m, fl::GielisCurveParams::n1, fl::GielisCurveParams::n2, fl::GielisCurveParams::n3, params(), x, and y.

+ Here is the call graph for this function: