Last active
August 2, 2017 20:53
-
-
Save llamasoft/aff977f15ae483235e4da060d6191c2a to your computer and use it in GitHub Desktop.
Film Canister Holder
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
inches = 25.4; | |
module HexPack(rows, columns, spacing) { | |
// Assuming the circles are hexagonally packed, | |
// this is how far their center points are from each other. | |
// We can find the y spacing of the center points using the Pythagorean theorem because | |
// the center points between three adjacent circles will form an equilateral triangle. | |
function pythag(side, hypot) = sqrt(pow(hypot, 2) - pow(side, 2)); | |
hex_x_spacing = spacing; | |
hex_y_spacing = pythag(spacing / 2, spacing); | |
for ( row = [0 : rows - 1] ) { | |
is_offset = ( row % 2 ); | |
x_offset = (is_offset * (hex_x_spacing / 2)); | |
y_offset = (row * hex_y_spacing); | |
for ( column = [0 : columns - 1] ) { | |
cur_x_offset = x_offset + (column * hex_x_spacing); | |
cur_offset = [cur_x_offset, y_offset, 0]; | |
translate(cur_offset) children(); | |
} | |
} | |
} | |
module BottleHolder(rows, columns, diameter, height, gap, padding_scale = 1.25) { | |
difference() { | |
HexPack(rows, columns, diameter + gap) cylinder(height, d = diameter + (2 * gap * padding_scale)); | |
HexPack(rows, columns, diameter + gap) cylinder(height, d = diameter); | |
} | |
} | |
BottleHolder( | |
rows = 3, | |
columns = 4, | |
diameter = 1.25 * inches, | |
height = 0.25 * inches, | |
gap = 0.20 * inches | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment