Added asserts for regular_ngon().

This commit is contained in:
Revar Desmera 2020-03-02 12:57:24 -08:00
parent 8a29e9e86b
commit 7ea33cc724
2 changed files with 6 additions and 2 deletions

View file

@ -609,7 +609,10 @@ function _turtle_command(command, parm, parm2, state, index) =
function regular_ngon(n=6, r, d, or, od, ir, id, side, rounding=0, realign=false, anchor=CENTER, spin=0) =
let(
sc = 1/cos(180/n),
r = get_radius(r1=ir*sc, r2=or, r=r, d1=id*sc, d2=od, d=d, dflt=side/2/sin(180/n)),
r = get_radius(r1=ir*sc, r2=or, r=r, d1=id*sc, d2=od, d=d, dflt=side/2/sin(180/n))
)
assert(!is_undef(r), "regular_ngon(): need to specify one of r, d, or, od, ir, id, side.")
let(
path = rounding==0? circle(r=r, realign=realign, spin=90, $fn=n) :
let(
steps = floor(segs(r)/n),
@ -628,6 +631,7 @@ function regular_ngon(n=6, r, d, or, od, ir, id, side, rounding=0, realign=false
module regular_ngon(n=6, r, d, or, od, ir, id, side, rounding=0, realign=false, anchor=CENTER, spin=0) {
sc = 1/cos(180/n);
r = get_radius(r1=ir*sc, r2=or, r=r, d1=id*sc, d2=od, d=d, dflt=side/2/sin(180/n));
assert(!is_undef(r), "regular_ngon(): need to specify one of r, d, or, od, ir, id, side.");
path = regular_ngon(n=n, r=r, rounding=rounding, realign=realign);
attachable(anchor,spin, two_d=true, path=path) {
polygon(path);

View file

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,143];
BOSL_VERSION = [2,0,144];
// Section: BOSL Library Version Functions