Merge branch 'master' into master

This commit is contained in:
adrianVmariano
2025-03-25 21:51:29 -04:00
committed by GitHub
3 changed files with 11 additions and 6 deletions

BIN
images/metaball_demo2d.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

@@ -1648,7 +1648,6 @@ function debug_tetra(r) = let(size=r/norm([1,1,1])) [
// Section: Metaballs
// ![Metaball animation](https://raw.githubusercontent.com/BelfrySCAD/BOSL2/master/images/metaball_demo.gif)
// ![Metaball animation](https://raw.githubusercontent.com/BelfrySCAD/BOSL2/master/images/metaball_demo2d.gif)
// .
// [Metaballs](https://en.wikipedia.org/wiki/Metaballs), also known as "blobby objects",
// can produce smoothly varying blobs and organic forms. You create metaballs by placing metaball
@@ -2653,13 +2652,13 @@ function mb_stadium(size, cutoff=INF, influence=1, negative=false, hide_debug=fa
length = shape>=0 ? siz[1] : siz[0],
r = shape>=0 ? siz[0]/2 : siz[1]/2,
sl = length-2*r, // straight side length
dum3 = assert(sl>0, "\nTotal length must accommodate rounded ends of rectangle."),
//dum3 = assert(sl>=0, "\nTotal length must accommodate rounded ends of rectangle."),
neg = negative ? -1 : 1,
poly = shape<=EPSILON ? [neg, hide_debug ? circle(r=0.02, $fn=3) : circle(r=r, $fn=20)]
poly = abs(shape)<=EPSILON ? [neg, hide_debug ? circle(r=0.02, $fn=3) : circle(r=r, $fn=20)]
: shape>0 ? [neg, hide_debug ? square(0.02,center=true) : rect([2*r,length], rounding=0.999*r, $fn=20)]
: [neg, hide_debug ? square(0.02,center=true) : rect([length,2*r], rounding=0.999*r, $fn=20)]
) abs(shape)<EPSILON ?
[function (dv) _mb_circle_full(point, r, cutoff, 1/influence, neg), poly]
[function (dv) _mb_circle_full(dv, r, cutoff, 1/influence, neg), poly]
: shape>0 ? [function (dv) _mb_stadium_full(dv, sl/2, r, cutoff, 1/influence, neg), poly]
: [function (dv) _mb_stadium_sideways_full(dv, sl/2, r, cutoff, 1/influence, neg), poly];
@@ -2719,6 +2718,8 @@ function mb_ring(r1,r2, cutoff=INF, influence=1, negative=false, hide_debug=fals
// Usage: As a function
// region = metaballs2d(spec, bounding_box, pixel_size, [isovalue=], [closed=], [use_centers=], [smoothing=], [exact_bounds=], [show_stats=]);
// Description:
// ![Metaball animation](https://raw.githubusercontent.com/BelfrySCAD/BOSL2/master/images/metaball_demo2d.gif)
// .
// 2D metaball shapes can be useful to create interesting polygons for extrusion. When invoked as a
// module, a 2D metaball scene is displayed. When called as a function, a list containing one or more
// [paths](paths.scad) is returned.
@@ -2954,7 +2955,7 @@ function mb_ring(r1,r2, cutoff=INF, influence=1, negative=false, hide_debug=fals
module metaballs2d(spec, bounding_box, pixel_size, pixel_count, isovalue=1, use_centers=false, smoothing=undef, exact_bounds=false, convexity=6, cp="centroid", anchor="origin", spin=0, atype="hull", show_stats=false, show_box=false, debug=false) {
regionlist = metaballs2d(spec, bounding_box, pixel_size, pixel_count, isovalue, true, use_centers, smoothing, exact_bounds, show_stats, _debug=debug);
$metaball_pathlist = debug ? regionlist[0] : regionlist; // for possible use with children
wid = min(0.5, 0.25 * (is_num(pixel_size) ? pixel_size : 0.5*(pixel_size[0]+pixel_size[1])));
wid = min(0.5, 0.5 * (is_num(pixel_size) ? pixel_size : 0.5*(pixel_size[0]+pixel_size[1])));
if(debug) {
// display debug polygons
for(a=regionlist[1])

View File

@@ -3964,6 +3964,7 @@ function _prism_fillet_prism(name, basepoly, bot, top, d, k, N, overlap, uniform
// See Also: parent(), join_prism(), linear_sweep()
// Usage:
// prism_connector(desc1, anchor1, desc2, anchor2, [spin_align=]);
// Description:
// Given descriptions and anchors for two objects, construct a filleted prism that connects the
// anchor points on those objects, with a filleted joint at each end. This is an alternative interface
@@ -4110,6 +4111,7 @@ function _prism_fillet_prism(name, basepoly, bot, top, d, k, N, overlap, uniform
// let(sweep=parent())
// move([24,-22,20]) sphere(d=10)
// prism_connector(circle(r=2.2,$fn=32), sweep, CTR, parent(),CTR, fillet=2);
// Example: Connecting to edges. In this example the triangular prism is aligned with object1, the big cube, so its corner is at the edge. You can't align it with both edges at the same time; that would requires twisting the prism.
// $fn=32;
// tri = subdivide_path(round_corners([[-3,-2],[0,5],[3,-2]], cut=1), maxlen=1,closed=true);
@@ -4213,6 +4215,7 @@ function _prism_fillet_prism(name, basepoly, bot, top, d, k, N, overlap, uniform
// desc_copies(arc_copies(rx=85,ry=45,n=12))
// cyl(d=15,h=27,circum=true,rounding=5,$fn=64)
// prism_connector(circle(r=3,$fn=32), parent(), CTR, $next(), CTR, fillet=4);
// Example(3D,Med): When using {{desc_copies()}} with a varying shape you have to conditionally show only the correct shape for each index, but still specify all the shapes so you can collect their descriptions.
// circ = circle(r=3, $fn=64);
// desc_copies(arc_copies(rx=60,ry=80,n=5,sa=-20,ea=200))
@@ -4430,7 +4433,6 @@ function _extrusion_isect(geom,line,bounded,flip) =
[anchor,shift*RIGHT];
function _find_center_anchor(desc1, desc2, anchor2, flip) =
let(
pt2 = desc_point(desc2, anchor=anchor2),
@@ -4442,6 +4444,7 @@ function _find_center_anchor(desc1, desc2, anchor2, flip) =
: geom[0]=="spheroid" ? [unit(line[1]-line[0]), [0,0,0]]
: starts_with(geom[0],"extrusion") ? _extrusion_isect(geom,line,RAY,flip)
: assert(false,str("Center anchor not supported with geometry type ",geom[0]));
@@ -4475,6 +4478,7 @@ module prism_connector(profile, desc1, anchor1, desc2, anchor2, shift1=0, shift2
corrected_base_anchor = is_vector(anchor1) && norm(anchor1)==0 ? _find_center_anchor(desc1,desc2,anchor2,true) : undef;
corrected_aux_anchor = is_vector(anchor2) && norm(anchor2)==0 ? _find_center_anchor(desc2,desc1,anchor1,false) : undef;
base_anchor=is_string(anchor1) ? anchor1
: is_def(corrected_base_anchor) ? corrected_base_anchor[0]
: point3d(anchor1);