Created
October 26, 2018 18:33
-
-
Save Vftdan/c2c43bd6d011df06b042e18b404fb0b6 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
//by Vftdan | |
module detSphere(radius, details=1) scale(1 / details) sphere(radius * details); | |
module zcyl(h, r, details) scale(1 / details) cylinder(h * details, r=r * details, center=true); | |
module xcyl(h, r, details) rotate([0, 90, 0]) zcyl(h, r, details); | |
module ycyl(h, r, details) rotate([90, 0, 0]) zcyl(h, r, details); | |
module bottomSmoothedCuboid(width, depth, height, radius, details=1) { | |
d = radius * 2; | |
intersection() { | |
translate([0, 0, height / 2]) { | |
cube([width, depth, height], true); | |
} | |
union() { | |
translate([0, 0, height / 2]) { | |
translate([0, 0, radius / 2]) { | |
cube([width - d, depth, height - radius], true); | |
cube([width, depth - d, height - radius], true); | |
} | |
cube([width - d, depth - d, height] , true); | |
} | |
translate([0, 0, radius]) { | |
xoff = width / 2 - radius; | |
yoff = depth / 2 - radius; | |
for(xsig = [-1, 1]) translate([xsig * xoff, 0, 0]) ycyl(depth - d, radius, details); | |
for(ysig = [-1, 1]) translate([0, ysig * yoff, 0]) xcyl(width - d, radius, details); | |
for(xsig = [-1, 1]) for(ysig = [-1, 1]) translate([xsig * xoff, ysig * yoff, 0]) { | |
detSphere(radius, details); | |
translate([0, 0, (height - radius) / 2]) zcyl(height - radius, radius, details); | |
} | |
} | |
} | |
} | |
} | |
module soapContainer(width, depth, height, radius, thickness, details=1) { | |
dthickness = thickness * 2; | |
difference() { | |
bottomSmoothedCuboid(width, depth, height, radius, details); | |
translate([0, 0, thickness]) bottomSmoothedCuboid(width - dthickness, depth - dthickness, height, radius - thickness, details); | |
} | |
} | |
//Example: | |
soapContainer(2, 3, 1, .5, .05, 50); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment