/*
A cup divided into multiple spiraling chambers.
Add vertical slots in wall of cup and holes from all but one of the chambers
to the tunnels, but not above the point where there is less twist from the top
than hides the holes. It takes a twist of (180 + 360/chambers) to completely
obstruct the view of the inside of the chamber.
*/
$fa=1;
$fs=1;
num_chambers=3;
shafts_per_chamber=5;
num_shafts=num_chambers*shafts_per_chamber;
module pieSlice(r, start_angle, end_angle, offset)
{
if (end_angle - start_angle > 180)
echo("pie slice has too wide of an angle");
intersection() {
circle(r);
rotate([0, 0, start_angle])
translate([-(r+1), offset, 0])
square(2*(r+1));
rotate([0, 0, end_angle-180])
translate([-(r+1), offset, 0])
square(2*(r+1));
}
}
module chamber(h, r, offset, twist, chamber_index)
{
a = 360/num_chambers;
rotate([0, 0, chamber_index*a])
linear_extrude(height=h, twist=twist, convexity=10)
pieSlice(r, 0, a, offset);
}
module hole(h, r, d, shaft_index)
{
a0 = 180/num_shafts;
a1 = 360/num_shafts;
rotate([0, 0, a0+a1*shaft_index])
translate([r, 0, 0])
cylinder(h=h, d=d, $fn=36);
}
module slot(h, r, thickness, shaft_index)
{
a0 = 180/num_shafts;
a1 = 360/num_shafts;
rotate([0, 0, a0+a1*shaft_index])
translate([0, -thickness/2, 0])
cube([r, thickness, h]);
}
module slots(h, r, thickness, twist)
{
intersection() {
union()
for(chamber_index=[0:num_chambers-2])
chamber(h, r, thickness/2, twist, chamber_index);
translate([0, 0, -1])
union()
for(shaft_index=[0:num_shafts-1])
slot(h+2, r+1, thickness, shaft_index);
}
}
module cup(h, r, thickness, twist)
difference() {
cylinder(h=h, r=r);
translate([0, 0, thickness]) {
slots(h/2, r-thickness/2, thickness/2, twist/2);
for(shaft_index=[0:num_shafts-1])
hole(h, r-thickness/2, thickness/2, shaft_index);
for(chamber_index=[0:num_chambers-1])
color(rands(0, 1, 3))
chamber(h, r-thickness, thickness/2, twist, chamber_index);
}
}
cup(100, 40, 4, 720);
Comments