Last active
April 13, 2025 17:50
-
-
Save groovenectar/292db1688b79efd6ce11 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
// More information: https://danielupshaw.com/openscad-rounded-corners/ | |
module roundedcube_simple(size = [1, 1, 1], center = false, radius = 0.5) { | |
// If single value, convert to [x, y, z] vector | |
size = (size[0] == undef) ? [size, size, size] : size; | |
translate = (center == false) ? | |
[radius, radius, radius] : | |
[ | |
radius - (size[0] / 2), | |
radius - (size[1] / 2), | |
radius - (size[2] / 2) | |
]; | |
translate(v = translate) | |
minkowski() { | |
cube(size = [ | |
size[0] - (radius * 2), | |
size[1] - (radius * 2), | |
size[2] - (radius * 2) | |
]); | |
sphere(r = radius); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to grovenectar for the roundedcube_simple() and roundedcube() modules - they helped me a lot, and enabled me to understand the minkowski operation!
Thanks to daSpud46 for the roundedcylinder_simple() module. However, I think that there is a mistake in the code.
Because he copied the translate part from grovenectar's roundedcube_simple() module, he assumed that the true/false choice affects cylinder in exactly the same way as it affects the position of cube(). But it doesn't!
In cube(), "true" locates the center of the cube at [0,0,0], and "false" locates the lower bottom corner at [0,0,0]. But with cylinder(), "true" only affects the z-position of the cylinder; Whether "true" or "false", the x-center and y-center of the cylinder() is always at [0,0].
So here is my modified code: