From 93230f2af2ad9c4aae40cdb826f0ed077d0a36c8 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Mon, 7 Nov 2022 21:18:21 -0500 Subject: [PATCH] onion fix & vector_search fix for r=0 --- shapes3d.scad | 10 ++++++---- vectors.scad | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/shapes3d.scad b/shapes3d.scad index f4a3135..72f6060 100644 --- a/shapes3d.scad +++ b/shapes3d.scad @@ -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 = [ diff --git a/vectors.scad b/vectors.scad index ad05740..275cfb8 100644 --- a/vectors.scad +++ b/vectors.scad @@ -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)