Various bugfixes found by docs regen.

This commit is contained in:
Revar Desmera 2020-04-26 04:29:21 -07:00
parent 2834e8bc56
commit e32735296c
6 changed files with 16 additions and 8 deletions

View File

@ -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

View File

@ -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();

View File

@ -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()

View File

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

View File

@ -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.

View File

@ -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);
}
}
}