[OpenSCAD] Rectangle with one curved edge

phormix alias.openscad at phormix.com
Thu Oct 11 03:08:24 EDT 2018


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/



More information about the Discuss mailing list