3d rounded corner with 2 cylinders and 1 cube

6 messages
Open this post in threaded view
|

3d rounded corner with 2 cylinders and 1 cube

 I wanted to create a "roundedCube" module that accepts for each of the 8 corners all possible combinations of rounded and edged forms. As I was able to get some good results I run into problems where I have to mix rounded and edged corners, e.g. x and y are rounded, z is edged. I can create a corner with 2 cylinders and a cube but the hull() function will kind of flatten the corner. It probably could be done better by adding an elliptical sphere into the corner but I can't figure out how to create it. e.g. I use these basic forms for the corner             color("red")    // x             translate([1,1,1])             rotate([0,90,0])             cylinder(r=1,h=0.01);             color("blue")             translate([1,1,1])             cylinder(r=1,h=0.01);             color("green")             translate([0,0,1])             cube([1,1,1]); and hull creates this rather flattened corner: What additional object would create a smooth rounding with the edge? My trials did not work out because the edge distance is too far out for a torus to work. I assume it would have to be an elliptical sphere in 45 degree angles and some x,y,z offsets? -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

Re: 3d rounded corner with 2 cylinders and 1 cube

 On 12/30/18 2:46 PM, juerg.maier wrote: ```I wanted to create a "roundedCube" module that accepts for each of the 8 corners all possible combinations of rounded and edged forms. As I was able to get some good results I run into problems where I have to mix rounded and edged corners, e.g. x and y are rounded, z is edged. ``` Is this the kind of corner you are seeking? Good luck, --Algot // sharp vertical edges on a rounded-edge cube \$fn=30; hull(){     // bottom     translate([10,-10,-10])     sphere(1);     translate([-10,-10,-10])     sphere(1);        translate([-10,10,-10])     sphere(1);          translate([10,10,-10])     sphere(1);  // top     translate([10,-10,10])     sphere(1);     translate([-10,-10,10])     sphere(1);        translate([-10,10,10])     sphere(1);          translate([10,10,10])     sphere(1); // only one sharp vertical corner put into place to compare translate([-11,-11,-9.25]) cube([2,2,19.25]); } _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

Re: 3d rounded corner with 2 cylinders and 1 cube

 In reply to this post by juerg.maier On 12/30/2018 11:46 AM, juerg.maier wrote: ```I wanted to create a "roundedCube" module that accepts for each of the 8 corners all possible combinations of rounded and edged forms. ``` I looked into this problem a while back, and convinced myself that it isn't meaningful to talk about handling all combinations.  I convinced myself that at any vertex, two of the axes had to have the same radius.  (And of course "edged" is the same as a radius of zero.) What I found was needed was for each corner to be a torus - well, strictly, one half of a quarter of a torus - with the radii of two edges being the minor radius of the torus, and radius of the third edge is the major radius plus the minor radius. The Wikipedia article https://en.wikipedia.org/wiki/Torus defines the major radius as the distance from the center of the torus to the center of the tube, and the minor radius as the radius of the tube. I didn't think about degenerate cases where one of the radii is zero (a hard edge) or where the two edges have a larger radius than the third.  I expect that something derived from a torus would still apply, but right now it's making my head hurt. I'm not a very deep geometry guy, so maybe I'm just not wrapping my head around it right, and maybe there are other definitions for which it's possible to have three distinct radii... but it would involve the radius changing as you turn the corner.  I think. Hope that helps. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

Re: 3d rounded corner with 2 cylinders and 1 cube

 Here's the modules I used.  I was modeling a mattress, with potentially different radii on the corners than on the top and bottom edges, so that's the terminology I used here, but it's really not specific to that application.  I don't remember why I filled the tori. ```module filled_torus(r, r2) { rotate_extrude() { intersection() { translate([r-r2, 0]) circle(r2); translate([0, -(r2+1)]) square([r+1, r2*2+2]); } translate([0, -r2]) square([r-r2, r2*2]); } } // corner_r must be >= both top_r and bot_r // // Centered around xy=0,0; base is at z=0. // // Perhaps unfortunately, the parameters describe a bed that you are facing // the side of. Thus the length of the bed is along the X axis and the // width is along the Y axis. // // w1 is the width of the cushion along its left (-X) edge. // w2 is the width of the cushion along its right (+X) edge. // l1 is the length of the cushion along its front (-Y) edge. // l2 is the length of the cushion along its back (+Y) edge. // // +Y // | // l2 | // ............. // w1 . | . // -X -----.-----+-----.----- +X // . | . w2 // ............. // l1 | // | // -Y // // module cushion(l, w, t, l1, l2, w1, w2, top_r=1*inch, bot_r=1*inch, corner_r=2*inch) { _w1 = w1 == undef ? w : w1; _w2 = w2 == undef ? w : w2; _l1 = l1 == undef ? l : l1; _l2 = l2 == undef ? l : l2; // Rounded-corner box, for cushions if (corner_r < top_r || corner_r < bot_r) { echo("WARNING corner_r must be >= top_r and bot_r", corner_r=corner_r, top_r=top_r, bot_r=bot_r); } hull() for (p = [ [-_l1/2 + corner_r, -_w1/2 + corner_r], // front left [-_l2/2 + corner_r, _w1/2 - corner_r], // back left [_l1/2 - corner_r, -_w2/2 + corner_r], // front right [_l2/2 - corner_r, _w2/2 - corner_r] // back right ]) { x = p[0]; y = p[1]; translate([x,y,bot_r]) filled_torus(r=corner_r, r2=bot_r); translate([x,y,t-top_r]) filled_torus(r=corner_r, r2=top_r); // } } } cushion(l1=80, l2=70, w1=50, w2=40, t=8, top_r=3, bot_r=1, corner_r=3); ``` _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org