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

◆ makeCorkScrew()

fl::vector< vec3f > makeCorkScrew ( corkscrew_args args = corkscrew_args())

Definition at line 50 of file FestivalStick.ino.

50 {
51 // int num_leds, float leds_per_turn, float width_cm
52 int num_leds = args.num_leds;
53 float leds_per_turn = args.leds_per_turn;
54 float width_cm = args.width_cm;
55
56 const float circumference = leds_per_turn;
57 const float radius = circumference / (2.0 * PI); // radius in mm
58 const float angle_per_led = 2.0 * PI / leds_per_turn; // degrees per LED
59 const float total_angle_radians = angle_per_led * num_leds;
60 const float total_turns = total_angle_radians / (2.0 * PI); // total turns
61 const float height_per_turn_cm = width_cm; // 10cm height per turn
62 const float height_per_led =
63 height_per_turn_cm /
64 leds_per_turn; // this is the changing height per led.
65 const float total_height =
66 height_per_turn_cm * total_turns; // total height of the corkscrew
68 for (int i = 0; i < num_leds; i++) {
69 float angle = i * angle_per_led; // angle in radians
70 float height = (i / leds_per_turn) * height_per_turn_cm; // height in cm
71
72 // Calculate the x, y, z coordinates for the corkscrew
73 float x = radius * cos(angle); // x coordinate
74 float z = radius * sin(angle); // y coordinate
75 float y = height; // z coordinate
76
77 // Store the 3D coordinates in the vector
78 vec3f led_position(x, y, z);
79 // screenMap.set(i, led_position);
80 out.push_back(led_position);
81 }
82 return out;
83}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
corkscrew_args args
uint32_t z[NUM_LAYERS]
Definition Fire2023.ino:84
void push_back(const T &value)
Definition vector.h:442
#define PI
Definition math_macros.h:57
vec3< float > vec3f
Definition geometry.h:156
HeapVector< T > vector
Definition vector.h:1028

References args, PI, fl::HeapVector< T >::push_back(), x, y, and z.

+ Here is the call graph for this function: