Created
January 15, 2025 19:29
-
-
Save eugen/bf289aedf3038bea5ec50f8e75220d5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l1=15; | |
l2=50/4; | |
h=16; | |
step=0.3; | |
module wavey(length, height, thickness, amplitudes, periods, step) { | |
edge=1; | |
amp_bot = amplitudes[0]; | |
amp_top = amplitudes[1]; | |
sine_coords=[ for (l = [0:step:length]) | |
let ( | |
edge_factor = (l<edge || l>(length-edge)) | |
? 1-(max(edge-l, l-(length-edge))/edge) | |
: 1 | |
) | |
[ | |
l, | |
edge_factor*sin(-(l/length)*((periods*2+1)*180.0)) | |
] | |
]; | |
for (i=[0:len(sine_coords)-2]) { | |
coord1 = sine_coords[i]; | |
coord2 = sine_coords[i+1]; | |
translate([i*0.1, 0, 0]) | |
polyhedron( | |
points = [ | |
// base ↙ ↘ ↗ ↖ | |
[coord1[0], amp_bot*coord1[1], 0], | |
[coord2[0], amp_bot*coord2[1], 0], | |
[coord2[0], amp_bot*coord2[1]+thickness, 0], | |
[coord1[0], amp_bot*coord1[1]+thickness, 0], | |
// top ↙ ↘ ↗ ↖ | |
[coord1[0], amp_top*coord1[1], height], | |
[coord2[0], amp_top*coord2[1], height], | |
[coord2[0], amp_top*coord2[1]+thickness, height], | |
[coord1[0], amp_top*coord1[1]+thickness, height], | |
], | |
faces = [ | |
[0,1,2,3], // bottom | |
[4,5,1,0], // front | |
[7,6,5,4], // top | |
[5,6,2,1], // right | |
[6,7,3,2], // back | |
[7,4,0,3] // left | |
], | |
convexity = 10x, | |
); | |
}; | |
} | |
wavey(0.4, 1, 0.2, [0.2,0], 10, 0.2); | |
//translate([0, 0, 1]) { | |
// wavey(l1, 1, 0.04, 0.05, 10, 0.1); | |
//} | |
//*rotate([0,0,90]) wavey(h, 0.1, l1, 0.05, 10, 0.1); V |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment