Skip to content

Instantly share code, notes, and snippets.

@shift
Last active November 15, 2024 00:10
Show Gist options
  • Save shift/13c5889980490098b235cff035e85c44 to your computer and use it in GitHub Desktop.
Save shift/13c5889980490098b235cff035e85c44 to your computer and use it in GitHub Desktop.
module star_2d(num_points = 5, outer_radius = 10, inner_radius = 4) {
angle = 360 / num_points;
points = [ for (i = [0 : num_points - 1]) [
outer_radius * cos(i * angle),
outer_radius * sin(i * angle)
] ];
inner_points = [ for (i = [0 : num_points - 1]) [
inner_radius * cos(i * angle + angle),
inner_radius * sin(i * angle + angle)
] ];
polygon(concat(points, inner_points));
}
module star_3d(num_points = 5, outer_radius = 10, inner_radius = 4, height = 5) {
linear_extrude(height = height) star_2d(num_points, outer_radius, inner_radius);
}
star_3d(); // Create a default 5-pointed star with height 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment