# Rectangle with one curved edge Classic List Threaded 34 messages 12
Open this post in threaded view
|

## Rectangle with one curved edge

Open this post in threaded view
|

## Re: Rectangle with one curved edge

 Administrator Something like this: intersection(){ //     linear_extrude(height=12)         circle(r=R); // Extrude the disc     translate([2*X-(.5*H),-CX/2,0])         cube([CX,CX,12]); } translate([2*X-(.5*H),0,0])     linear_extrude(height=12)     jawx(); // Extrude rect jaw x-section Admin - email* me if you need anything, or if I've done something stupid... * click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 In reply to this post by John Tucker Don't be embarrassed. Even those who don't act makes mistakes.Hull() doesn't help here.To get a rectangle with rounded edges, intersect circles:\$fn = 120;module arc_square(sx,sy,Rx,Ry) render()intersection(){    translate([-Rx+sx/2,0]) circle(Rx);    translate([ Rx-sx/2,0]) circle(Rx);    translate([0,-Ry+sy/2]) circle(Ry);    translate([0, Ry-sy/2]) circle(Ry);} ​To round vertices, use offset:offset(r) square([a,b], center=true); ​To get both, a little math is needed:a = 30; // rectangle widthb = 20; // rectangle heighte = 2;  // rect. side bulgeRx = e/2 + b*b/e/8;Ry = e/2 + a*a/e/8; echo(Rx, Ry);r = 3;color("blue")offset(r) arc_square(a+2*e-2*r,b+2*e-2*r,Rx,Ry);# translate([0,0,2]) square([a,b],center=true); // just to compare/*Using PythagorasR^2 = (R-e)^2 + (a/2)^20 = -2*e*R + e^2 + (a/2)^2R = e/2 + (a/2)^2 / e / 2*/ ​Now just linear_extrude() this polygon.BTW, to make a cylinder you don't need linear_extrude().​2017-04-05 21:57 GMT-03:00 John Tucker : I've embarrassed myself by asking stupid things on this list before; I hope this isn't another. I'm trying to make a bit of a fiddly part. It's to be a positive of an existing jaw which will later be a negative (differenced) insert for a fit-over part.   The cross section is basically a rectangle with one side slightly convex and the corners are slightly radiused. I had my first printing (SLS) made without the convex face and the fit was unacceptable. My question is: Is it possible to make an intersection of an arc of a circle and a rectangle made by hulling circles ?   Here's one of my attempts: CX=9.525; // Cross section CR=1; // Corner (fillet) Radius X=CX-CR; // Cen to Cen of Circles H=CX-9; // Cord height R=(pow(CX,2)+(4*pow(H,2)))/(8*H); \$fn=64;   echo("radius= ",R);   module jawx(){ hull(){ translate([X/2-(1.15*H),X/2])circle(CR); // 1.15 empirical translate([X/2-(1.15*H),-X/2])circle(CR);// to approx tang pt translate([-X/2,X/2])circle(CR); translate([-X/2,-X/2])circle(CR); } }   intersection(){ // % linear_extrude(height=12) circle(r=R); // Extrude the disc translate([2*X-(.5*H),0,0]) # linear_extrude(height=12) jawx(); // Extrude rect jaw x-section }   I'm still using that crufty OpenSCAD version 2012.05.26 on Debian 3.2.86-1 i686 GNU/Linux.   TIA for any clues._______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 Minkowski() is a good way to radius corners.On 6/04/2017 14:59, "Ronaldo Persiano" <[hidden email]> wrote:Don't be embarrassed. Even those who don't act makes mistakes.Hull() doesn't help here.To get a rectangle with rounded edges, intersect circles:\$fn = 120;module arc_square(sx,sy,Rx,Ry) render()intersection(){    translate([-Rx+sx/2,0]) circle(Rx);    translate([ Rx-sx/2,0]) circle(Rx);    translate([0,-Ry+sy/2]) circle(Ry);    translate([0, Ry-sy/2]) circle(Ry);} ​To round vertices, use offset:offset(r) square([a,b], center=true); ​To get both, a little math is needed:a = 30; // rectangle widthb = 20; // rectangle heighte = 2;  // rect. side bulgeRx = e/2 + b*b/e/8;Ry = e/2 + a*a/e/8; echo(Rx, Ry);r = 3;color("blue")offset(r) arc_square(a+2*e-2*r,b+2*e-2*r,Rx,Ry);# translate([0,0,2]) square([a,b],center=true); // just to compare/*Using PythagorasR^2 = (R-e)^2 + (a/2)^20 = -2*e*R + e^2 + (a/2)^2R = e/2 + (a/2)^2 / e / 2*/ ​Now just linear_extrude() this polygon.BTW, to make a cylinder you don't need linear_extrude().​2017-04-05 21:57 GMT-03:00 John Tucker : I've embarrassed myself by asking stupid things on this list before; I hope this isn't another. I'm trying to make a bit of a fiddly part. It's to be a positive of an existing jaw which will later be a negative (differenced) insert for a fit-over part.   The cross section is basically a rectangle with one side slightly convex and the corners are slightly radiused. I had my first printing (SLS) made without the convex face and the fit was unacceptable. My question is: Is it possible to make an intersection of an arc of a circle and a rectangle made by hulling circles ?   Here's one of my attempts: CX=9.525; // Cross section CR=1; // Corner (fillet) Radius X=CX-CR; // Cen to Cen of Circles H=CX-9; // Cord height R=(pow(CX,2)+(4*pow(H,2)))/(8*H); \$fn=64;   echo("radius= ",R);   module jawx(){ hull(){ translate([X/2-(1.15*H),X/2])circle(CR); // 1.15 empirical translate([X/2-(1.15*H),-X/2])circle(CR);// to approx tang pt translate([-X/2,X/2])circle(CR); translate([-X/2,-X/2])circle(CR); } }   intersection(){ // % linear_extrude(height=12) circle(r=R); // Extrude the disc translate([2*X-(.5*H),0,0]) # linear_extrude(height=12) jawx(); // Extrude rect jaw x-section }   I'm still using that crufty OpenSCAD version 2012.05.26 on Debian 3.2.86-1 i686 GNU/Linux.   TIA for any clues._______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 Administrator > one side slightly convex > using that crufty OpenSCAD version 2012.05.26 Thus no offset() Admin - email* me if you need anything, or if I've done something stupid... * click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 2017-04-06 0:33 GMT-03:00 MichaelAtOz :> one side slightly convex > using that crufty OpenSCAD version 2012.05.26 Thus no offset()Does it have minkowski() ?module offset(r) {    very_big = 1e16; // something greater then the children size    render()    if(r>0)         minkowski(){            children();            circle(r);        }    else        difference(){            square(very_big-1,center=true);            minkowski(){                difference(){                    square(very_big,center=true);                    children();                }                circle(-r);            }        }}          _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 Ronaldo,  Why does your offset square example above have slightly curved edges? It should have straight edges and rounded corners and does when I try it.On 6 April 2017 at 05:22, Ronaldo Persiano wrote:2017-04-06 0:33 GMT-03:00 MichaelAtOz :> one side slightly convex > using that crufty OpenSCAD version 2012.05.26 Thus no offset()Does it have minkowski() ?module offset(r) {    very_big = 1e16; // something greater then the children size    render()    if(r>0)         minkowski(){            children();            circle(r);        }    else        difference(){            square(very_big-1,center=true);            minkowski(){                difference(){                    square(very_big,center=true);                    children();                }                circle(-r);            }        }}          _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 In reply to this post by John Tucker Just got the daily digest ... thanks to all who helped ... Embarrassment is ok with me, it forces me to go further on my own instead of looking for easy solutions. I'm in awe of those of you on this forum that are so willing to help and divert your attention from more serious things.   I'm on digest mode and will have to now work with the suggestions all of you have contributed. Thanks again to all.  _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 In reply to this post by nophead 2017-04-06 7:24 GMT-03:00 nop head :Ronaldo,  Why does your offset square example above have slightly curved edges? It should have straight edges and rounded corners and does when I try it. You are right. The second image is a wrong image. That is what I should have include instead: ​I should correct myself in the statement that hull() would not help here. It is possible to do it just with hull, without offset() or minkowski(). But the the math would be a little more complicate and I mention it here for completeness. The solution would be the intersection of the rounded edge rectangle with 4 big triangles with rounded vertices (a hull of 3 circles) well dimensioned and positioned. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 In reply to this post by John Tucker John,One more detail about my solution. The assignment \$fn=120; may not be adequate depending on the rectangle sizes you need. A better choice would be:\$fn = 100*max(Rx/sx,Ry/sy);That assignment should be inside arc_square() just after intersection(){  . A value of \$fn=32 might be enough for the circles inside module offset() .2017-04-06 13:16 GMT-03:00 John Tucker : Just got the daily digest ... thanks to all who helped ... Embarrassment is ok with me, it forces me to go further on my own instead of looking for easy solutions. I'm in awe of those of you on this forum that are so willing to help and divert your attention from more serious things.   I'm on digest mode and will have to now work with the suggestions all of you have contributed. Thanks again to all. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rectangle with one curved edge

 In reply to this post by John Tucker Do you have access to a CAD program that produces a DXF file? The simple way would be to draw the profile in cad using your exact dimensions and then import it into OpenSCAD. Open this post in threaded view
|

## Re: Rectangle with one curved edge

 In reply to this post by John Tucker Bit of a necropost here but I had a similar question with rounded corners and though I'd share my formulae, which combine and outer/inner cube and cylinders to create beveled corners module beveled_rect(w,d,h,r){   union() {   translate([r,r,h/2]) cylinder(r = r, h = h, center = true);   translate([w-r,r,h/2]) cylinder(r = r, h = h, center = true);   translate([r,0, 0]) cube([w-(r*2),r,h]);   translate([r,d-r,h/2]) cylinder(r = r, h = h, center = true);   translate([w-r,d-r,h/2]) cylinder(r = r, h = h, center = true);   translate([r,d-r, 0]) cube([w-(r*2),r,h]);       translate([0, r, 0]) cube([w,d-(r*2),h]);   } } module beveled_rect_bot(w,d,h,r){   union() {   translate([r,r,h/2]) cylinder(r = r, h = h, center = true);   translate([w-r,r,h/2]) cylinder(r = r, h = h, center = true);   translate([r,0, 0]) cube([w-(r*2),r,h]);       translate([0, r, 0]) cube([w,d-r,h]);   } } This of course focuses on bevelled/rounded corners, but one could just as easily do the same logic with the whole edge. As I make formulae etc I'll be posting them to my own wiki as well: https://wiki.phormix.com/pub/index.php?title=OpenSCAD_Modules-- 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: Rectangle with one curved edge

 In reply to this post by John Tucker A 2 year old post, but it challenged me. I started with a simple one. One side slightly convex... module roundfrontcube() {   intersection(){     cylinder(d=200,h=20);     translate([-30,-100,-.001])     #cube([60,30,21]);   } } Then I tried fillets and one side slightly convex... intersection() { #  fil_cube();   translate([0,98,0]) #    cylinder(h=12,d=200); } module fil_cube() {   union(){     translate([-15.5,1,0])     hull() {       cylinder(h=12,r=2);       translate([30,0,0])         cylinder(h=12,r=2);       translate([30,20,0])         cylinder(h=12,r=2);       translate([0,20,0])         cylinder(h=12,r=2);     }     translate([-16,-4,0])       cube([31,3,12]);   } } -- 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: Rectangle with one curved edge

 That solution has a non-smooth transition where the cylinder meets the rounded cube---a small corner.  It may not really matter, since it's pretty subtle, but it seems inelegant to me: I see three basic approaches.  One is to do something like previously suggested with circles, for example.  Note that my solution below actually directly sets the bulge amount.  But round2d() depends on offset().   The Round-Anything library is here: https://github.com/Irev-Dev/Round-Anything// Draw a segment of a circle with specified length and height module segment(length, height){   r=(length*length+4*height*height)/8/height;   intersection(){     translate([0,(height+1)/2])       square([length+2, height+1], center=true);     translate([0,-r+height])circle(r=r);   } } use \$fn=120; bulge = 1; cornerR = 1; round2d(cornerR){   square([10,5],center=true);   translate([0,2.5])segment(10,bulge); } Here's a second approach that avoids using offset() but instead relies on polyRound, a function which applies a specified roundover radius at every corner of a polygon.   use bulge=2;   // Actual bulge is less due to rounding to the inside width=10; height=5; cornerR=1; bulgeR=2*width; rect = [[0,0,cornerR],         [width,0,cornerR],         [width,height,cornerR],         [width/2,height+bulge,bulgeR],         [0,height,cornerR]]; polygon(polyRound(rect,fn=20)); Here's the third solution, my least favorite, using minkowski().   Of the three, it took me the most fiddling to get this method working correctly, and of course it runs slowly.  It would be a bit simpler if I didn't cut off the curved ends of the cylinder with the intersection---it wasn't clear whether rounded ends were OK or not.   \$fn=120; bulge = 1; cornerR = 1; width = 10; height = 5; length = 10; intersection(){   translate([0,bulge/2,length/2])     cube([width, height+bulge, length],center=true);   render() minkowski()   {     sphere(r=cornerR, \$fn=32);     linear_extrude(height=length){       square([width-2*cornerR,height-2*cornerR],center=true);       translate([0,height/2-cornerR])segment(width-2*cornerR,bulge);     }   } } -- 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: Rectangle with one curved edge

 I knew when I posted that it was a little kludgy, but figured all I had to do was to refine the Y offset of the large cylinder to find the sweet spot. Tried (trial and error) for a while, but could not get it exactly right. I was hoping that someone would figure out a better way, and perhaps even a way to use math to position everything. Anyway, thanks a bunch for your solutions, and a special thank you for the Round-Anything library. That's a keeper! All I have to do now is to figure it out and get some practice. adrianv wrote > That solution has a non-smooth transition where the cylinder meets the > rounded cube---a small corner.  It may not really matter, since it's > pretty > subtle, but it seems inelegant to me: > > <http://forum.openscad.org/file/t2477/rect4.png>  > > I see three basic approaches.  One is to do something like previously > suggested with circles, for example.  Note that my solution below actually > directly sets the bulge amount.  But round2d() depends on offset().   > > The Round-Anything library is here: > https://github.com/Irev-Dev/Round-Anything-- 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: Rectangle with one curved edge

 lar3ry wrote > I knew when I posted that it was a little kludgy, but figured all I had to > do > was to refine the Y offset of the large cylinder to find the sweet spot. > Tried (trial and error) for a while, but could not get it exactly right. I suspect that to get a smooth transition you would have needed to vary the radius of your cylinder, not just its position.  That is, if you picked a cylinder of a certain size the angle at which it connected with the rectangle would probably be wrong for the rectangle's width.   The equations for this seem like they are probably messy to work out, so I haven't checked.   > I was hoping that someone would figure out a better way, and perhaps even > a > way to use math to position everything. Fortunately, it's not necessary to use much math to get good positioning. In my opinion, when you have to resort to using a lot of math in the design, and doing calculations for positioning things, it means something is wrong. The math should be encapsulated into libraries and the designer should not have to fuss with it.  Good solutions to most problems shouldn't require using a lot of math at the high level.   They also shouldn't require trial and error.   -- 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: Rectangle with one curved edge

Open this post in threaded view
|

## Re: Rectangle with one curved edge

Open this post in threaded view
|