Fixes for bounding_box() and minkowsi_difference()

This commit is contained in:
Garth Minette 2020-12-18 19:04:28 -08:00
parent 4b4304d794
commit 423fef1094
2 changed files with 11 additions and 11 deletions

View file

@ -27,15 +27,15 @@
// translate([10,8,4]) cube(5); // translate([10,8,4]) cube(5);
// translate([3,0,12]) cube(2); // translate([3,0,12]) cube(2);
module bounding_box(excess=0) { module bounding_box(excess=0) {
xs = excess>0? excess : 1; xs = excess>.1? excess : 1;
// a 3D approx. of the children projection on X axis // a 3D approx. of the children projection on X axis
module _xProjection() module _xProjection()
linear_extrude(xs, center=true) linear_extrude(xs, center=true)
hull() projection()
projection() rotate([90,0,0])
rotate([90,0,0]) linear_extrude(xs, center=true)
linear_extrude(xs, center=true) projection()
projection() hull()
children(); children();
// a bounding box with an offset of 1 in all axis // a bounding box with an offset of 1 in all axis
@ -50,13 +50,13 @@ module bounding_box(excess=0) {
// offset children() (a cube) by -1 in all axis // offset children() (a cube) by -1 in all axis
module _shrink_cube() { module _shrink_cube() {
intersection() { intersection() {
translate([ 1, 1, 1]) children(); translate((1-excess)*[ 1, 1, 1]) children();
translate([-1,-1,-1]) children(); translate((1-excess)*[-1,-1,-1]) children();
} }
} }
render(convexity=2) render(convexity=2)
if (excess>0) { if (excess>.1) {
_oversize_bbox() children(); _oversize_bbox() children();
} else { } else {
_shrink_cube() _oversize_bbox() children(); _shrink_cube() _oversize_bbox() children();
@ -674,7 +674,7 @@ module minkowski_difference() {
bounding_box(excess=1) children(0); bounding_box(excess=1) children(0);
children(0); children(0);
} }
for (i=[1,1,$children-1]) children(i); for (i=[1:1:$children-1]) children(i);
} }
} }
} }

View file

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