mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 00:09:41 +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.
|
||||
//
|
||||
// Usage: As Module
|
||||
// onion(r|d=, [ang=], [cap_h=], ...) [ATTACHMENTS];
|
||||
// onion(r|d=, [ang=], [cap_h=], [circum=], [realign=], ...) [ATTACHMENTS];
|
||||
// Usage: As Function
|
||||
// vnf = onion(r|d=, [ang=], [cap_h=], ...);
|
||||
// vnf = onion(r|d=, [ang=], [cap_h=], [circum=], [realign=], ...);
|
||||
//
|
||||
// Arguments:
|
||||
// r = radius of spherical portion of the bottom. Default: 1
|
||||
// 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)
|
||||
// ---
|
||||
// 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.
|
||||
// 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`
|
||||
|
@ -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
|
||||
// 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);
|
||||
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));
|
||||
_cap_h = min(default(cap_h,tip_h), tip_h);
|
||||
anchors = [
|
||||
|
|
|
@ -376,7 +376,7 @@ function furthest_point(pt, points) =
|
|||
// 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);
|
||||
// }
|
||||
// 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;
|
||||
// k = 2000;
|
||||
// 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.")
|
||||
tgpts
|
||||
? len(target)<=400
|
||||
? 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 ] ]
|
||||
? 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 ] ]
|
||||
: let( tree = _bt_tree(target, count(len(target)), leafsize=25) )
|
||||
simple ? _bt_search(query, r, target, tree) :
|
||||
[for(q=query) _bt_search(q, r, target, tree)]
|
||||
|
|
Loading…
Reference in a new issue