diff --git a/attachments.scad b/attachments.scad index 2475787..a8db9c6 100644 --- a/attachments.scad +++ b/attachments.scad @@ -635,6 +635,16 @@ module force_tags(tags) // Arguments: // neg = String containing space delimited set of tag names of children to difference away. // keep = String containing space delimited set of tag names of children to keep, that is, to union into the model after differencing is completed. +// Example: The "hole" items are subtracted from everything else. The other tags can be anything you find convenient. +// diff("hole") +// sphere(d=100, $tags="body") { +// zcyl(d=55, h=100, $tags="pole"); // attach() not needed for center-to-center. +// tags("hole") { +// xcyl(d=55, h=101); +// ycyl(d=55, h=101); +// } +// zcyl(d=15, h=140, $tags="axle"); +// } // Example: // diff("neg", keep="axle") // sphere(d=100) { diff --git a/distributors.scad b/distributors.scad index d5b351d..a5af6c4 100644 --- a/distributors.scad +++ b/distributors.scad @@ -258,6 +258,20 @@ module ycopies(spacing, n, l, sp) // cube(size=[1,3,1],center=true); // cube(size=[3,1,1],center=true); // } +// Example: Cubic sphere packing +// s = 20; +// s2 = s * sin(45); +// zcopies(s2,n=8) union() +// grid2d([s2,s2],n=8,stagger=($idx%2)? true : "alt") +// sphere(d=s); +// Example: Hexagonal sphere packing +// s = 20; +// xyr = adj_ang_to_hyp(s/2,30); +// h = hyp_adj_to_opp(s,xyr); +// zcopies(h,n=8) union() +// back(($idx%2)*xyr*cos(60)) +// grid2d(s,n=[12,7],stagger=($idx%2)? "alt" : true) +// sphere(d=s); module zcopies(spacing, n, l, sp) { sp = is_finite(sp)? [0,0,sp] : sp; diff --git a/examples/BOSL2logo.scad b/examples/BOSL2logo.scad index f786cf6..c2bd2bd 100644 --- a/examples/BOSL2logo.scad +++ b/examples/BOSL2logo.scad @@ -34,7 +34,7 @@ xdistribute(50) { [ x, y+s1], [ x, y] ]; recolor("#99f") - path_sweep(regular_ngon(n=3,d=10,spin=90), bezier_path(sbez)); + path_sweep(regular_ngon(n=3,d=10,spin=90), bezpath_points(sbez)); recolor("#0bf") translate([-15,-35,0]) diff --git a/examples/attachments.scad b/examples/attachments.scad index 8c8a4e6..c45fddd 100644 --- a/examples/attachments.scad +++ b/examples/attachments.scad @@ -1,9 +1,9 @@ include -include + $fn=32; -cuboid([60,40,40], rounding=5, edges=edges("Z"), anchor=BOTTOM) { +cuboid([60,40,40], rounding=5, edges="Z", anchor=BOTTOM) { attach(TOP, BOTTOM) prismoid([60,40],[20,20], h=50, rounding1=5, rounding2=10) { attach(TOP) cylinder(d=20, h=30, center=false) { attach(TOP) cylinder(d1=50, d2=30, h=12, center=false); diff --git a/examples/bezier_patches.scad b/examples/bezier_patches.scad deleted file mode 100644 index 62f775b..0000000 --- a/examples/bezier_patches.scad +++ /dev/null @@ -1,83 +0,0 @@ -include -include - - -function CR_corner(size, spin=0, orient=UP, trans=[0,0,0]) = - let ( - // This patch might not yet correct for continuous rounding, - // but it's a first approximation proof of concept. - a = 0.68, - b = 0.60, - c = 0.24, - patch = [ - [[0,1,1], [0,a,1], [0,c,1], [c,0,1], [a,0,1], [1,0,1]], - [[0,1,a], [0,b,b], [0,0,b], [b,0,b], [1,0,a]], - [[0,1,c], [0,b,0], [b,0,0], [1,0,c]], - [[c,1,0], [b,b,0], [1,c,0]], - [[a,1,0], [1,a,0]], - [[1,1,0]], - ] - ) - translate(trans, - p=rot(a=spin, from=UP, to=orient, - p=scale(size, p=patch) - ) - ); - - -function CR_edge(size, spin=0, orient=UP, trans=[0,0,0]) = - let ( - // This patch might not be correct for continuous rounding, - // but it's a first approximation proof of concept. - vvals = [1.00, 0.68, 0.24], - xyvals = [ - for (x=vvals) [x,0], - for (y=reverse(vvals)) [0,y] - ], - zvals = [-0.5:0.2:0.5], - patch = [for (xy=xyvals) [for (z=zvals) [each xy, z]]] - ) - translate(trans, - p=rot(a=spin, from=UP, to=orient, - p=scale(size, p=patch) - ) - ); - - -module CR_cube(size=[100,100,100], r=10, splinesteps=8, debug=false) -{ - s = size-2*[r,r,r]; - h = size/2; - corner_pat = CR_corner([r,r,r], trans=[-size.x/2, -size.y/2, -size.z/2]); - edge_pat = CR_edge([r, r, s.z], trans=[-h.x, -h.y, 0]); - face_pat = bezier_patch_flat([s.x, s.z], N=1, orient=FRONT, trans=[0, -h.y, 0]); - corners = bezier_surface([ - for (yr=[0,180], zr=[0:90:270]) let( - m = yrot(yr) * zrot(zr) - ) [for (row=corner_pat) apply(m, row)] - ], splinesteps=splinesteps); - edges = bezier_surface([ - for (axr=[[0,0,0],[90,0,0],[0,90,0]],zr=[0:90:270]) let( - m = rot(axr) * zrot(zr) - ) [for (row=edge_pat) apply(m, row)] - ], splinesteps=[splinesteps,1]); - faces = bezier_surface([ - for (axr=[0,90,180,270,[-90,0,0],[90,0,0]]) let( - m = rot(axr) - ) [for (row=face_pat) apply(m, row)] - ], splinesteps=1); - - if (debug) { - vnf_validate([edges, faces, corners], convexity=4); - } else { - vnf_polyhedron([edges, faces, corners], convexity=4); - } -} - - -CR_cube(size=[100,100,100], r=20, splinesteps=16, debug=false); -cube(1); - - - -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/examples/boolean_geometry.scad b/examples/boolean_geometry.scad index 1e7190f..7dcd300 100644 --- a/examples/boolean_geometry.scad +++ b/examples/boolean_geometry.scad @@ -1,5 +1,4 @@ include -include $fn = 36; diff --git a/examples/cubic_sphere_packing.scad b/examples/cubic_sphere_packing.scad deleted file mode 100644 index 3a782d0..0000000 --- a/examples/cubic_sphere_packing.scad +++ /dev/null @@ -1,13 +0,0 @@ -include - -//$fa=2; -//$fs=2; - -s = 20; -s2 = s * sin(45); -zcopies(s2,n=8) union() - grid2d([s2,s2],n=8,stagger=($idx%2)? true : "alt") - sphere(d=s); - - -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/examples/hex_sphere_packing.scad b/examples/hex_sphere_packing.scad deleted file mode 100644 index c36d31e..0000000 --- a/examples/hex_sphere_packing.scad +++ /dev/null @@ -1,15 +0,0 @@ -include - -//$fa=2; -//$fs=2; - -s = 20; -xyr = adj_ang_to_hyp(s/2,30); -h = hyp_adj_to_opp(s,xyr); -zcopies(h,n=8) union() - back(($idx%2)*xyr*cos(60)) - grid2d(s,n=[12,7],stagger=($idx%2)? "alt" : true) - sphere(d=s); - - -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/examples/randomized_fractal_tree.scad b/examples/randomized_fractal_tree.scad index f7b9d0e..9b0670c 100644 --- a/examples/randomized_fractal_tree.scad +++ b/examples/randomized_fractal_tree.scad @@ -1,6 +1,4 @@ include -include -include module leaf(s) { path = [ @@ -18,8 +16,8 @@ module branches(minsize, s1, s2){ attach(TOP) zrot(gaussian_rands(90,20)[0]) zrot_copies(n=floor(log_rands(2,5,4)[0])) - zrot(gaussian_rands(0,5)[0]) - yrot(gaussian_rands(30,10)[0]) { + zrot(gaussian_rands(1,0,5)) + yrot(gaussian_rands(1,30,10)) { sc = gaussian_rands(0.7,0.05)[0]; cylinder(d1=s2, d2=s2*sc, l=s1) branches(minsize, s1*sc, s2*sc); @@ -32,8 +30,9 @@ module branches(minsize, s1, s2){ } module tree(h, d, minsize) { - sc = gaussian_rands(0.7,0.05)[0]; + sc = gaussian_rands(1,0.7,0.05)[0]; recolor("lightgray") { + echo(d=d,sc=sc); cylinder(d1=d, d2=d*sc, l=h) { branches(minsize, h, d*sc); } diff --git a/examples/screw_anchors.scad b/examples/screw_anchors.scad deleted file mode 100644 index 76d4eff..0000000 --- a/examples/screw_anchors.scad +++ /dev/null @@ -1,13 +0,0 @@ -include -include -include -include -include -include - - -metric_bolt(headtype="oval", size=10, l=15, shank=5, details=true, phillips="#2") -show_anchors(5, std=false); - - -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/examples/spherical_patch.scad b/examples/spherical_patch.scad index 8cc2307..482360f 100644 --- a/examples/spherical_patch.scad +++ b/examples/spherical_patch.scad @@ -13,8 +13,9 @@ patch1 = [ [p[1]+q[2], p[1]+q[1]+u, p[0]+q[0]+u, p[0]+q[3]], [p[1], p[1]+q[0], p[0]+q[1], p[0] ], ]; -patch2 = patch_reverse(zflip(p=patch1)); -trace_bezier_patches([patch1, patch2], splinesteps=16, style="quincunx"); +patch2 = bezier_patch_reverse(zflip(p=patch1)); +//vnf_polyhedron([bezier_vnf(patch1),bezier_vnf(patch2)]); +debug_bezier_patches([patch1, patch2], splinesteps=16, style="quincunx"); // vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/examples/tagged_diff.scad b/examples/tagged_diff.scad deleted file mode 100644 index bbb41f0..0000000 --- a/examples/tagged_diff.scad +++ /dev/null @@ -1,15 +0,0 @@ -include - - -diff("hole", "body pole") -sphere(d=100, $tags="body") { - zcyl(d=55, h=100, $tags="pole"); // attach() not needed for center-to-center. - tags("hole") { - xcyl(d=55, h=101); - ycyl(d=55, h=101); - } - zcyl(d=15, h=140, $tags="axle"); -} - - -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap