fix broken examples

This commit is contained in:
Adrian Mariano 2022-03-24 00:15:25 -04:00
parent 5bcd7e571b
commit b4b62f86dd
12 changed files with 34 additions and 150 deletions

View file

@ -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) {

View file

@ -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;

View file

@ -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])

View file

@ -1,9 +1,9 @@
include <BOSL2/std.scad>
include <BOSL2/hull.scad>
$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);

View file

@ -1,83 +0,0 @@
include <BOSL2/std.scad>
include <BOSL2/beziers.scad>
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

View file

@ -1,5 +1,4 @@
include <BOSL2/std.scad>
include <BOSL2/debug.scad>
$fn = 36;

View file

@ -1,13 +0,0 @@
include <BOSL2/std.scad>
//$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

View file

@ -1,15 +0,0 @@
include <BOSL2/std.scad>
//$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

View file

@ -1,6 +1,4 @@
include <BOSL2/std.scad>
include <BOSL2/paths.scad>
include <BOSL2/beziers.scad>
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);
}

View file

@ -1,13 +0,0 @@
include <BOSL2/std.scad>
include <BOSL2/threading.scad>
include <BOSL2/phillips_drive.scad>
include <BOSL2/torx_drive.scad>
include <BOSL2/metric_screws.scad>
include <BOSL2/debug.scad>
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

View file

@ -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

View file

@ -1,15 +0,0 @@
include <BOSL2/std.scad>
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