mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
onion fix & vector_search fix for r=0
This commit is contained in:
parent
3bc83463e0
commit
93230f2af2
2 changed files with 9 additions and 7 deletions
|
@ -2618,15 +2618,17 @@ function teardrop(h, r, ang=45, cap_h, r1, r2, d, d1, d2, cap_h1, cap_h2, chamf
|
||||||
// Creates a sphere with a conical hat, to make a 3D teardrop.
|
// Creates a sphere with a conical hat, to make a 3D teardrop.
|
||||||
//
|
//
|
||||||
// Usage: As Module
|
// Usage: As Module
|
||||||
// onion(r|d=, [ang=], [cap_h=], ...) [ATTACHMENTS];
|
// onion(r|d=, [ang=], [cap_h=], [circum=], [realign=], ...) [ATTACHMENTS];
|
||||||
// Usage: As Function
|
// Usage: As Function
|
||||||
// vnf = onion(r|d=, [ang=], [cap_h=], ...);
|
// vnf = onion(r|d=, [ang=], [cap_h=], [circum=], [realign=], ...);
|
||||||
//
|
//
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// r = radius of spherical portion of the bottom. Default: 1
|
// r = radius of spherical portion of the bottom. Default: 1
|
||||||
// ang = Angle of cone on top from vertical. Default: 45 degrees
|
// ang = Angle of cone on top from vertical. Default: 45 degrees
|
||||||
// cap_h = If given, height above sphere center to truncate teardrop shape. Default: `undef` (no truncation)
|
// cap_h = If given, height above sphere center to truncate teardrop shape. Default: `undef` (no truncation)
|
||||||
// ---
|
// ---
|
||||||
|
// circum = set to true to circumscribe the specified radius/diameter. Default: False
|
||||||
|
// realign = adjust point alignment to determine if bottom is flat or pointy. Default: False
|
||||||
// d = diameter of spherical portion of bottom.
|
// d = diameter of spherical portion of bottom.
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
|
@ -2653,10 +2655,10 @@ function teardrop(h, r, ang=45, cap_h, r1, r2, d, d1, d2, cap_h1, cap_h2, chamf
|
||||||
// Example: Standard Connectors
|
// Example: Standard Connectors
|
||||||
// onion(d=30, ang=30, cap_h=20) show_anchors();
|
// onion(d=30, ang=30, cap_h=20) show_anchors();
|
||||||
|
|
||||||
module onion(r, ang=45, cap_h, d, anchor=CENTER, spin=0, orient=UP)
|
module onion(r, ang=45, cap_h, d, circum=false, realign=false, anchor=CENTER, spin=0, orient=UP)
|
||||||
{
|
{
|
||||||
r = get_radius(r=r, d=d, dflt=1);
|
r = get_radius(r=r, d=d, dflt=1);
|
||||||
xyprofile = teardrop2d(r=r, ang=ang, cap_h=cap_h);
|
xyprofile = teardrop2d(r=r, ang=ang, cap_h=cap_h, circum=circum, realign=realign);
|
||||||
tip_h = max(column(xyprofile,1));
|
tip_h = max(column(xyprofile,1));
|
||||||
_cap_h = min(default(cap_h,tip_h), tip_h);
|
_cap_h = min(default(cap_h,tip_h), tip_h);
|
||||||
anchors = [
|
anchors = [
|
||||||
|
|
|
@ -376,7 +376,7 @@ function furthest_point(pt, points) =
|
||||||
// color("blue")stroke(move(queries[i],circle(r=1)), closed=true, width=.08);
|
// color("blue")stroke(move(queries[i],circle(r=1)), closed=true, width=.08);
|
||||||
// color("red") move_copies(select(points, search_ind[i])) circle(r=.08);
|
// color("red") move_copies(select(points, search_ind[i])) circle(r=.08);
|
||||||
// }
|
// }
|
||||||
// Example: when a series of search with different radius are needed, its is faster to pre-compute the tree
|
// Example: when a series of searches with different radius are needed, its is faster to pre-compute the tree
|
||||||
// $fn=32;
|
// $fn=32;
|
||||||
// k = 2000;
|
// k = 2000;
|
||||||
// points = list_to_matrix(rands(0,10,k*2),2,seed=13333);
|
// points = list_to_matrix(rands(0,10,k*2),2,seed=13333);
|
||||||
|
@ -419,8 +419,8 @@ function vector_search(query, r, target) =
|
||||||
"The query points should be a list of points compatible with the target point list.")
|
"The query points should be a list of points compatible with the target point list.")
|
||||||
tgpts
|
tgpts
|
||||||
? len(target)<=400
|
? len(target)<=400
|
||||||
? simple ? [for(i=idx(target)) if(norm(target[i]-query)<r) i ] :
|
? simple ? [for(i=idx(target)) if(norm(target[i]-query)<=r) i ] :
|
||||||
[for(q=query) [for(i=idx(target)) if(norm(target[i]-q)<r) i ] ]
|
[for(q=query) [for(i=idx(target)) if(norm(target[i]-q)<=r) i ] ]
|
||||||
: let( tree = _bt_tree(target, count(len(target)), leafsize=25) )
|
: let( tree = _bt_tree(target, count(len(target)), leafsize=25) )
|
||||||
simple ? _bt_search(query, r, target, tree) :
|
simple ? _bt_search(query, r, target, tree) :
|
||||||
[for(q=query) _bt_search(q, r, target, tree)]
|
[for(q=query) _bt_search(q, r, target, tree)]
|
||||||
|
|
Loading…
Reference in a new issue