From 97723305fb51442c1efcdf1aaff234cc945c1c70 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Wed, 3 Oct 2018 18:22:26 -0700 Subject: [PATCH] Fixed dimensional accuracy of rcube(). --- shapes.scad | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shapes.scad b/shapes.scad index dd64247..1ce2ce6 100644 --- a/shapes.scad +++ b/shapes.scad @@ -158,11 +158,17 @@ module rrect(size=[1,1,1], r=0.25, center=false) // rcube(size=[5,7,3], r=1); module rcube(size=[1,1,1], r=0.25, center=false) { - rr = min(r, min(min(size[0]/2-0.01, size[1]/2-0.01), size[2]/2-0.01)); + dd = min(2*r, min(size)); + $fn=quantup(segs(dd/2), 4); translate(center? [0,0,0] : size/2) { minkowski() { - cube([size[0]-2*rr, size[1]-2*rr, size[2]-2*rr], center=true); - sphere(rr, $fn=quantup(segs(rr), 4)); + cube([max(0.01,size[0]-dd), max(0.01,size[1]-dd), max(0.01,size[2]-dd)], center=true); + rotate_extrude() { + difference() { + circle(dd/2); + left(dd/2) square(dd, center=true); + } + } } } }