Skip to content

Instantly share code, notes, and snippets.

@maxme
Last active November 11, 2023 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxme/3eddb80320620f2d8eebd7dc9b3b2693 to your computer and use it in GitHub Desktop.
Save maxme/3eddb80320620f2d8eebd7dc9b3b2693 to your computer and use it in GitHub Desktop.
// Params
plank_width = 48;
plank_height = 30;
plank_length_start = 1300;
plank_length_end = 30;
total_height = 1900;
base_height = 250;
base_length = 70;
rotation_angle = 60;
// Variables
base_iterations = floor(base_height / plank_height);
recalculated_base_height = base_iterations * plank_height;
tree_height = total_height - recalculated_base_height;
iterations = floor(tree_height / plank_height);
sub = floor((plank_length_start - plank_length_end) / iterations);
echo("number of layers", iterations + base_iterations)
// base
for (i = [0: floor(recalculated_base_height / plank_height) - 1]) {
rotate([0, 0, i * rotation_angle])
translate([0, 0, i * plank_height])
cube([plank_width, base_length, plank_height], center = true);
echo(plank_width, base_length, plank_height);
}
// tree
for (i = [0: iterations]) {
rotate([0, 0, i * rotation_angle])
translate([0, 0, recalculated_base_height + i * plank_height])
cube([plank_width, plank_length_start - i * sub, plank_height], center = true);
echo(plank_width, plank_length_start - i * sub, plank_height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment