Skip to content

Instantly share code, notes, and snippets.

@groovenectar
Last active June 16, 2023 08:55
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groovenectar/292db1688b79efd6ce11 to your computer and use it in GitHub Desktop.
Save groovenectar/292db1688b79efd6ce11 to your computer and use it in GitHub Desktop.
// 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);
}
}
@daSpud46
Copy link

daSpud46 commented Aug 1, 2021

I am wondering about how to convert this to roundedcylinder_simple.

Thoughts?

@groovenectar
Copy link
Author

groovenectar commented Aug 2, 2021

I am wondering about how to convert this to roundedcylinder_simple.

Thoughts?

It's been a long while since I've worked on this...

I would think that a rounded cylinder could also involve the minkowski transform:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#minkowski

So I guess you would take a cylinder, and then add another cylinder (or perhaps a sphere) on a perpendicular axis along the edge, then apply a minkowski transformation to the whole thing? Actually I wonder if I could have used a cylinder or two for this rather than a sphere, now that I'm digging back in a little bit... I hope/wish I can get back into printing and designing within the next few years!

@daSpud46
Copy link

daSpud46 commented Aug 2, 2021 via email

@groovenectar
Copy link
Author

Thank you for sharing!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment