mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 00:09:37 +00:00
Various bugfixes found by docs regen.
This commit is contained in:
parent
2834e8bc56
commit
e32735296c
6 changed files with 16 additions and 8 deletions
|
@ -849,6 +849,7 @@ function coplanar(plane, point, eps=EPSILON) =
|
||||||
// points = The list of points to test.
|
// 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)
|
// 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) =
|
function points_are_coplanar(points, eps=EPSILON) =
|
||||||
|
points_are_collinear(points, eps=eps)? true :
|
||||||
let(
|
let(
|
||||||
plane = plane_from_points(points, fast=true, eps=eps)
|
plane = plane_from_points(points, fast=true, eps=eps)
|
||||||
) all([for (pt = points) coplanar(plane, pt, 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)<3? 0 :
|
||||||
len(poly[0])==2? 0.5*sum([for(i=[0:1:len(poly)-1]) det2(select(poly,i,i+1))]) :
|
len(poly[0])==2? 0.5*sum([for(i=[0:1:len(poly)-1]) det2(select(poly,i,i+1))]) :
|
||||||
let(
|
let(
|
||||||
plane = plane_from_points(poly),
|
plane = plane_from_points(poly)
|
||||||
|
) plane==undef? undef :
|
||||||
|
let(
|
||||||
n = unit(plane_normal(plane)),
|
n = unit(plane_normal(plane)),
|
||||||
total = sum([for (i=[0:1:len(poly)-1]) cross(poly[i], select(poly,i+1))]),
|
total = sum([for (i=[0:1:len(poly)-1]) cross(poly[i], select(poly,i+1))]),
|
||||||
res = abs(total * n) / 2
|
res = abs(total * n) / 2
|
||||||
|
|
|
@ -668,7 +668,7 @@ function yscale(y=1, p=undef, planar=false) = (planar || (!is_undef(p) && len(p)
|
||||||
// zscale(3) sphere(r=10);
|
// zscale(3) sphere(r=10);
|
||||||
//
|
//
|
||||||
// Example: Scaling Points
|
// 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(path);
|
||||||
// trace_polyline(zscale(2,p=path));
|
// trace_polyline(zscale(2,p=path));
|
||||||
module zscale(z=1) scale([1,1,z]) children();
|
module zscale(z=1) scale([1,1,z]) children();
|
||||||
|
|
|
@ -119,7 +119,7 @@ function vceil(v) = [for (x=v) ceil(x)];
|
||||||
// unit([0,0,10]); // Returns: [0,0,1]
|
// unit([0,0,10]); // Returns: [0,0,1]
|
||||||
// unit([0,-10,0]); // Returns: [0,-1,0]
|
// unit([0,-10,0]); // Returns: [0,-1,0]
|
||||||
// unit([0,0,0]); // Returns: [0,0,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()
|
// Function: vector_angle()
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,283];
|
BOSL_VERSION = [2,0,284];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
11
vnf.scad
11
vnf.scad
|
@ -508,12 +508,15 @@ function vnf_validate(vnf, show_warns=true, check_isects=false) =
|
||||||
],
|
],
|
||||||
null_faces = !show_warns? [] : [
|
null_faces = !show_warns? [] : [
|
||||||
for (face = faces) let(
|
for (face = faces) let(
|
||||||
|
face = deduplicate(face,closed=true)
|
||||||
|
)
|
||||||
|
if (len(face)>=3) let(
|
||||||
faceverts = [for (k=face) varr[k]],
|
faceverts = [for (k=face) varr[k]],
|
||||||
area = abs(polygon_area(faceverts))
|
area = polygon_area(faceverts)
|
||||||
) if (area < EPSILON) [
|
) if (is_num(area) && abs(area) < EPSILON) [
|
||||||
"WARNING",
|
"WARNING",
|
||||||
"NULL_FACE",
|
"NULL_FACE",
|
||||||
str("Face has zero area: ",fmt_float(area,15)),
|
str("Face has zero area: ",fmt_float(abs(area),15)),
|
||||||
faceverts,
|
faceverts,
|
||||||
"brown"
|
"brown"
|
||||||
]
|
]
|
||||||
|
@ -541,6 +544,8 @@ function vnf_validate(vnf, show_warns=true, check_isects=false) =
|
||||||
]),
|
]),
|
||||||
reversals = unique([
|
reversals = unique([
|
||||||
for(i = idx(faces), j = idx(faces)) if(i != j)
|
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(edge1 = pair_wrap(faces[i]))
|
||||||
for(edge2 = pair_wrap(faces[j]))
|
for(edge2 = pair_wrap(faces[j]))
|
||||||
if(edge1 == edge2) // Valid adjacent faces will never have the same vertex ordering.
|
if(edge1 == edge2) // Valid adjacent faces will never have the same vertex ordering.
|
||||||
|
|
|
@ -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) {
|
extrude_from_to(corner1,corner2) {
|
||||||
polygon(bracepath);
|
polygon(bracepath);
|
||||||
}
|
}
|
||||||
cube([l,thick,h],center=true);
|
prismoid([l1,thick],[l2,thick],h=h,anchor=CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue