Parkinbot rudolf at parkinbot.com
Tue Jan 30 13:30:12 EST 2018

```thehans wrote
> You say this belongs in a library, but is there a single library that
> has a properly implemented rounded cube?  Everyone's implementation is
> different and 99.9% of them are slow and/or poduce ugly geometry.
> This is why It should be standardized from the source.

Well I prefer libraries, which I write on my own, because they let me define
my own parameters and defaults and I can refer to the implementation. I
never understood why cube(), cylinder() and linear_extrude() are not
centered by default. And to be honest, I still don't know which prototypes
and defaults they exactly have. OK, this could be fixed by a proper
documentation ...

We have discussed it before several times that OpenSCAD is missing a
(standard) library concept. Have a look at the libraries folder shipped with
OpenSCAD and you will discover pretty old stuff that hasn't been maintained
for years.

See my implementation of a rounded_cylinder() and how it deals with
conflicts between diameters and radii. It is pretty fast, but I have no way
to figure out, whether it is semantically equivalent with cylinder,
therefore I can't call cylinder() with all its parameters in case r_ is 0.

\$fa=.2;
\$fs=.2;

CyR(r1=1, r2=6, h=7, r_=1.4, center = false);
//CyR(h=12, r_=1, r1=6, d2=1);

module CyR(r = 10, h=10, r_=1, d = undef, r1=undef, r2=undef, d1 = undef, d2
= undef, center=false)
{
r1 = r1==undef?d1==undef?d==undef?r:d/2:d1/2:r1;
r2 = r2==undef?d2==undef?d==undef?r:d/2:d2/2:r2;
r1_=min(abs(h/4), abs(r1), abs(r_));
r2_=min(abs(h/4), abs(r2), abs(r_));
echo(r1, r2, r1_, r2_);
h=abs(h);
translate([0,0,(center?-h/2:0)])
rotate_extrude()
intersection()
{
hull()
{
translate([r1-r1_, r1_]) circle(r1_);
translate([r2-r2_, h-r2_]) circle(r2_);
polygon([[0,0], [r1-r1_, r1_], [r2-r2_, h-r2_], [0,h]] );
}
square([max(r1,r2), h]);
}
}

--