From 7ea33cc724d2a5e0d57747cc8b33723e21334411 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 2 Mar 2020 12:57:24 -0800 Subject: [PATCH] Added asserts for regular_ngon(). --- shapes2d.scad | 6 +++++- version.scad | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/shapes2d.scad b/shapes2d.scad index 61edf2b..984c674 100644 --- a/shapes2d.scad +++ b/shapes2d.scad @@ -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); diff --git a/version.scad b/version.scad index 939efa6..a7a2f99 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,143]; +BOSL_VERSION = [2,0,144]; // Section: BOSL Library Version Functions