Created
August 6, 2020 19:35
-
-
Save patmandenver/0acd62c627840ef0da71039ef206cf12 to your computer and use it in GitHub Desktop.
This file contains 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
$fn=200; | |
pipes=[35,35,35]; | |
spacing=8; | |
height=120; | |
thickness=15; | |
bottom_thickness=4; | |
//Function for adding a list up | |
function add(v, i = 0, r = 0) = i < len(v) ? add(v, i + 1, r + v[i]) : r; | |
//Function for accumulatings sums | |
function accumulated_sums(input, i=0, acc_sum=[]) = | |
i == len(input) ? | |
acc_sum : | |
let( sum_i = (i==0 ? input[0]: acc_sum[i-1] + input[i]) ) | |
accumulated_sums(input, i=i+1, acc_sum = concat(acc_sum, [ sum_i ]) ); | |
function accumulated_partial_sums(input, i=0, acc_sum=[]) = | |
i == len(input) ? | |
acc_sum : | |
let( sum_i = (i==0 ? input[0]: acc_sum[i-1] + (input[i-1] + input[i])/2 )) | |
accumulated_partial_sums(input, i=i+1, acc_sum = concat(acc_sum, [ sum_i ]) ); | |
function maximum(a, i = 0) = (i < len(a) - 1) ? max(a[i], maximum(a, i +1)) : a[i]; | |
//Calculate width | |
width=add(pipes) + | |
((len(pipes)-1)+3)*spacing | |
+ 2*bottom_thickness; | |
radius=pipes[0]/2; | |
intersection(){ | |
union(){ | |
difference(){ | |
linear_extrude(thickness){ | |
wedge(radius, pipes, | |
spacing, height, width); | |
} | |
linear_extrude(thickness*2){ | |
polygon(points=[[bottom_thickness+spacing,-radius], | |
[width-(bottom_thickness+spacing),-radius], | |
[width-bottom_thickness,-height+2*radius], | |
[bottom_thickness,-height+2*radius]]); | |
} | |
linear_extrude(thickness){ | |
y=accumulated_partial_sums(pipes); | |
maxh = maximum(pipes); | |
for(x=[0:len(pipes)-1]){ | |
translate([y[x]-y[0]/2+(2+x)*spacing, | |
pipes[x]/2 - maxh/2]){ | |
circle(d=pipes[x]); | |
translate([-pipes[x]/2,-pipes[x]]){ | |
square(pipes[x]); | |
} | |
} | |
} | |
} | |
} | |
linear_extrude(thickness){ | |
y=accumulated_partial_sums(pipes); | |
maxh = maximum(pipes); | |
for(x=[0:len(pipes)-1]){ | |
translate([y[x]-y[0]/2+(2+x)*spacing, | |
-maxh/2]){ | |
translate([(pipes[x]+spacing)/2,0]){ | |
circle(d=spacing); | |
} | |
translate([(-pipes[x]-spacing)/2,0]){ | |
circle(d=spacing); | |
} | |
} | |
} | |
} | |
} | |
translate([0,2*radius,thickness]){ | |
rotate(90, [0,1,0]){ | |
linear_extrude(width){ | |
polygon(points=[[0,0], | |
[thickness,0], | |
[thickness, -height], | |
[thickness - bottom_thickness, | |
-height]]); | |
} | |
} | |
} | |
} | |
module wedge(radius, pipes, spacing, height, width){ | |
hull(){ | |
translate([radius, radius]){ | |
circle(radius); | |
translate([width-2*radius, 0]){ | |
circle(radius); | |
} | |
} | |
} | |
translate([0,-height+2*radius]){ | |
square([width,height-radius]); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment