From e32735296cc173890a549f73d8506224af2eef8e Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sun, 26 Apr 2020 04:29:21 -0700 Subject: [PATCH] Various bugfixes found by docs regen. --- geometry.scad | 5 ++++- transforms.scad | 2 +- vectors.scad | 2 +- version.scad | 2 +- vnf.scad | 11 ++++++++--- walls.scad | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/geometry.scad b/geometry.scad index bd05052..a5fe783 100644 --- a/geometry.scad +++ b/geometry.scad @@ -849,6 +849,7 @@ function coplanar(plane, point, eps=EPSILON) = // points = The list of points to test. // eps = How much variance is allowed in testing that each point is on the same plane. Default: `EPSILON` (1e-9) function points_are_coplanar(points, eps=EPSILON) = + points_are_collinear(points, eps=eps)? true : let( plane = plane_from_points(points, fast=true, eps=eps) ) all([for (pt = points) coplanar(plane, pt, eps=eps)]); @@ -1112,7 +1113,9 @@ function polygon_area(poly) = len(poly)<3? 0 : len(poly[0])==2? 0.5*sum([for(i=[0:1:len(poly)-1]) det2(select(poly,i,i+1))]) : let( - plane = plane_from_points(poly), + plane = plane_from_points(poly) + ) plane==undef? undef : + let( n = unit(plane_normal(plane)), total = sum([for (i=[0:1:len(poly)-1]) cross(poly[i], select(poly,i+1))]), res = abs(total * n) / 2 diff --git a/transforms.scad b/transforms.scad index 6f85836..c0e6d74 100644 --- a/transforms.scad +++ b/transforms.scad @@ -668,7 +668,7 @@ function yscale(y=1, p=undef, planar=false) = (planar || (!is_undef(p) && len(p) // zscale(3) sphere(r=10); // // Example: Scaling Points -// path = xrot(90,p=circle(d=50,$fn=12)); +// path = xrot(90,p=path3d(circle(d=50,$fn=12))); // #trace_polyline(path); // trace_polyline(zscale(2,p=path)); module zscale(z=1) scale([1,1,z]) children(); diff --git a/vectors.scad b/vectors.scad index 2ce8e45..d0bf251 100644 --- a/vectors.scad +++ b/vectors.scad @@ -119,7 +119,7 @@ function vceil(v) = [for (x=v) ceil(x)]; // unit([0,0,10]); // Returns: [0,0,1] // unit([0,-10,0]); // Returns: [0,-1,0] // unit([0,0,0]); // Returns: [0,0,0] -function unit(v) = norm(v)<=EPSILON? v : v/norm(v); +function unit(v) = assert(is_vector(v),str(v)) norm(v)<=EPSILON? v : v/norm(v); // Function: vector_angle() diff --git a/version.scad b/version.scad index e79a5af..1b10651 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,283]; +BOSL_VERSION = [2,0,284]; // Section: BOSL Library Version Functions diff --git a/vnf.scad b/vnf.scad index b285eed..8622761 100644 --- a/vnf.scad +++ b/vnf.scad @@ -508,12 +508,15 @@ function vnf_validate(vnf, show_warns=true, check_isects=false) = ], null_faces = !show_warns? [] : [ for (face = faces) let( + face = deduplicate(face,closed=true) + ) + if (len(face)>=3) let( faceverts = [for (k=face) varr[k]], - area = abs(polygon_area(faceverts)) - ) if (area < EPSILON) [ + area = polygon_area(faceverts) + ) if (is_num(area) && abs(area) < EPSILON) [ "WARNING", "NULL_FACE", - str("Face has zero area: ",fmt_float(area,15)), + str("Face has zero area: ",fmt_float(abs(area),15)), faceverts, "brown" ] @@ -541,6 +544,8 @@ function vnf_validate(vnf, show_warns=true, check_isects=false) = ]), reversals = unique([ for(i = idx(faces), j = idx(faces)) if(i != j) + if(len(deduplicate(faces[i],closed=true))>=3) + if(len(deduplicate(faces[j],closed=true))>=3) for(edge1 = pair_wrap(faces[i])) for(edge2 = pair_wrap(faces[j])) if(edge1 == edge2) // Valid adjacent faces will never have the same vertex ordering. diff --git a/walls.scad b/walls.scad index c46d355..61d6872 100644 --- a/walls.scad +++ b/walls.scad @@ -224,7 +224,7 @@ module thinning_wall(h=50, l=100, thick=5, ang=30, braces=false, strut=5, wall=2 extrude_from_to(corner1,corner2) { polygon(bracepath); } - cube([l,thick,h],center=true); + prismoid([l1,thick],[l2,thick],h=h,anchor=CENTER); } } }