Standardize indention on spaces, not tabs.

This commit is contained in:
Revar Desmera
2020-05-29 19:04:34 -07:00
parent 5fe35de963
commit 53c1e25395
89 changed files with 13618 additions and 13618 deletions

View File

@@ -4,15 +4,15 @@ include <BOSL2/hull.scad>
$fn=32;
cuboid([60,40,40], rounding=5, edges=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);
}
attach([FRONT, BACK, LEFT, RIGHT]) cylinder(d1=14, d2=5, h=20) {
attach(TOP, LEFT, overlap=5) prismoid([30,20], [20,20], h=10, shift=[-7,0]);
}
}
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);
}
attach([FRONT, BACK, LEFT, RIGHT]) cylinder(d1=14, d2=5, h=20) {
attach(TOP, LEFT, overlap=5) prismoid([30,20], [20,20], h=10, shift=[-7,0]);
}
}
}
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -3,75 +3,75 @@ 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, patch)
)
);
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, 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)
)
);
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);
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);
}
if (debug) {
vnf_validate([edges, faces, corners], convexity=4);
} else {
vnf_polyhedron([edges, faces, corners], convexity=4);
}
}
@@ -80,4 +80,4 @@ cube(1);
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -4,15 +4,15 @@ include <BOSL2/debug.scad>
$fn = 36;
rgn1 = [
square(100),
move([50,50], p=circle(d=60)),
[[35,35],[35,65],[65,65]]
square(100),
move([50,50], p=circle(d=60)),
[[35,35],[35,65],[65,65]]
];
rgn2 = [
[[0,0], [100,100], [100,0]],
[[27,10], [90,73], [90,10]],
move([70,30], p=circle(d=25))
[[0,0], [100,100], [100,0]],
[[27,10], [90,73], [90,10]],
move([70,30], p=circle(d=25))
];
@@ -21,29 +21,29 @@ outlinecolor="black";
module showit(label, rgn, poly=polycolor, outline=outlinecolor, width=0.5) {
move([-50,-50]) {
if(outline) color(outline) linear_extrude(height=max(0.1,1-width)) for(path=rgn) stroke(path, width=width, closed=true);
if(poly) color(poly) linear_extrude(height=0.1) region(rgn);
color("black") right(50) fwd(7) linear_extrude(height=0.1) text(text=label, size=8, halign="center", valign="center");
}
move([-50,-50]) {
if(outline) color(outline) linear_extrude(height=max(0.1,1-width)) for(path=rgn) stroke(path, width=width, closed=true);
if(poly) color(poly) linear_extrude(height=0.1) region(rgn);
color("black") right(50) fwd(7) linear_extrude(height=0.1) text(text=label, size=8, halign="center", valign="center");
}
}
ydistribute(-125) {
xdistribute(120) {
showit("Region A", rgn1, poly=[1,0,0,0.5]);
showit("Region B", rgn2, poly=[0,0,1,0.5]);
union() {
showit("A and B Overlaid", rgn1, poly=[1,0,0,0.5]);
showit("", rgn2, poly=[0,0,1,0.5]);
}
}
xdistribute(120) {
showit("Union A+B", union(rgn1, rgn2));
showit("Difference A-B", difference(rgn1, rgn2));
showit("Intersection A&B", intersection(rgn1, rgn2));
showit("Exclusive OR A^B", exclusive_or(rgn1, rgn2));
}
xdistribute(120) {
showit("Region A", rgn1, poly=[1,0,0,0.5]);
showit("Region B", rgn2, poly=[0,0,1,0.5]);
union() {
showit("A and B Overlaid", rgn1, poly=[1,0,0,0.5]);
showit("", rgn2, poly=[0,0,1,0.5]);
}
}
xdistribute(120) {
showit("Union A+B", union(rgn1, rgn2));
showit("Difference A-B", difference(rgn1, rgn2));
showit("Intersection A&B", intersection(rgn1, rgn2));
showit("Exclusive OR A^B", exclusive_or(rgn1, rgn2));
}
}
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -5,4 +5,4 @@ include <BOSL2/debug.scad>
cylinder(h=30, d1=50, d2=30) show_anchors();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -5,4 +5,4 @@ include <BOSL2/debug.scad>
cube(40, center=true) show_anchors();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -6,8 +6,8 @@ include <BOSL2/std.scad>
s = 20;
s2 = s * sin(45);
zcopies(s2,n=8) union()
grid2d([s2,s2],n=8,stagger=($idx%2)? true : "alt")
sphere(d=s);
grid2d([s2,s2],n=8,stagger=($idx%2)? true : "alt")
sphere(d=s);
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -5,4 +5,4 @@ include <BOSL2/debug.scad>
cylinder(h=30, d=30) show_anchors();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -1,17 +1,17 @@
include <BOSL2/std.scad>
module tree(l=1500, sc=0.7, depth=10)
recolor("lightgray")
cylinder(l=l, d1=l/5, d2=l/5*sc)
attach(TOP)
if (depth>0)
zrot(90)
zrot_copies(n=2)
yrot(30) tree(depth=depth-1, l=l*sc, sc=sc);
else
recolor("springgreen")
yscale(0.67)
teardrop(d=l*3, l=1, anchor=BOT, spin=90);
recolor("lightgray")
cylinder(l=l, d1=l/5, d2=l/5*sc)
attach(TOP)
if (depth>0)
zrot(90)
zrot_copies(n=2)
yrot(30) tree(depth=depth-1, l=l*sc, sc=sc);
else
recolor("springgreen")
yscale(0.67)
teardrop(d=l*3, l=1, anchor=BOT, spin=90);
tree();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -7,9 +7,9 @@ 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);
back(($idx%2)*xyr*cos(60))
grid2d(s,n=[12,7],stagger=($idx%2)? "alt" : true)
sphere(d=s);
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -1,46 +1,46 @@
include <BOSL2/std.scad>
function _lsystem_recurse(s, rules, lev) =
lev<=0? s : _lsystem_recurse([
for (
i = 0,
slen = len(s),
sout = "";
lev<=0? s : _lsystem_recurse([
for (
i = 0,
slen = len(s),
sout = "";
i <= slen;
i <= slen;
ch = s[i],
found = search([ch], rules)[0],
sout = str(sout, i==slen? "" : found==[]? ch : rules[found][1]),
i = i + 1
) if (i==slen) sout
][0], rules, lev-1);
ch = s[i],
found = search([ch], rules)[0],
sout = str(sout, i==slen? "" : found==[]? ch : rules[found][1]),
i = i + 1
) if (i==slen) sout
][0], rules, lev-1);
function _lsystem_to_turtle(s, step=1, angle=90, startang=0) =
concat(
startang? ["left", startang] : [],
["angle", angle, "length", step],
[
for (
i = 0,
slen = len(s);
concat(
startang? ["left", startang] : [],
["angle", angle, "length", step],
[
for (
i = 0,
slen = len(s);
i <= slen;
i <= slen;
ch = s[i],
cmd = (ch=="A" || ch=="B" || ch=="F")? ["move"] :
(ch=="+")? ["left"] :
(ch=="-")? ["right"] :
[],
i=i+1
) if(i>0 && cmd!=[]) each cmd
]
);
ch = s[i],
cmd = (ch=="A" || ch=="B" || ch=="F")? ["move"] :
(ch=="+")? ["left"] :
(ch=="-")? ["right"] :
[],
i=i+1
) if(i>0 && cmd!=[]) each cmd
]
);
function lsystem_turtle(basis, rules, levels=5, step=1, angle=90, startang=0) =
turtle(_lsystem_to_turtle(_lsystem_recurse(basis, rules, levels), step=step, angle=angle, startang=startang));
turtle(_lsystem_to_turtle(_lsystem_recurse(basis, rules, levels), step=step, angle=angle, startang=startang));
function dragon_curve (levels=9, step=1) = lsystem_turtle(levels=levels, step=step, angle=90, "FX", [["X", "X+YF+"], ["Y", "-FX-Y"]]);
@@ -67,4 +67,4 @@ points = hilbert_curve(levels=5, step=100/pow(2,5));
stroke(points, width=1);
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -18,10 +18,10 @@ module orient_cube(ang) {
color(axiscolors.z) back((20-1)/2+0.01) right((20-1)/2+0.01) cube([1,1,18], center=true);
for (axis=[0:2], neg=[0:1]) {
idx = axis + 3*neg;
labels = [
"RIGHT", "BACK", "UP",
"LEFT", "FWD", "DOWN"
];
labels = [
"RIGHT", "BACK", "UP",
"LEFT", "FWD", "DOWN"
];
rot(ang, from=UP, to=orientations[idx]) {
up(10) {
back(4) color("black") text3d(text=str("spin=",ang), size=2.5);
@@ -42,34 +42,34 @@ module text3d(text, h=0.01, size=3) {
module dottedline(l, d) for(y = [0:d*3:l]) up(y) sphere(d=d);
module orient_cubes() {
// X axis
color(axiscolors[0]) {
yrot( 90) cylinder(h=axislen, d=axisdiam, center=false);
right(axislbllen) rot([90,0,0]) text3d(text="X+");
yrot(-90) dottedline(l=axislen, d=axisdiam);
left(axislbllen) rot([90,0,180]) text3d(text="X-");
}
// Y axis
color(axiscolors[1]) {
xrot(-90) cylinder(h=axislen, d=axisdiam, center=false);
back(axislbllen) rot([90,0,90]) text3d(text="Y+");
xrot( 90) dottedline(l=axislen, d=axisdiam);
fwd(axislbllen) rot([90,0,-90]) text3d(text="Y-");
}
// Z axis
color(axiscolors[2]) {
cylinder(h=axislen, d=axisdiam, center=false);
up(axislbllen) rot([0,-90,90+$vpr[2]]) text3d(text="Z+");
xrot(180) dottedline(l=axislen, d=axisdiam);
down(axislbllen) rot([0,90,-90+$vpr[2]]) text3d(text="Z-");
}
// X axis
color(axiscolors[0]) {
yrot( 90) cylinder(h=axislen, d=axisdiam, center=false);
right(axislbllen) rot([90,0,0]) text3d(text="X+");
yrot(-90) dottedline(l=axislen, d=axisdiam);
left(axislbllen) rot([90,0,180]) text3d(text="X-");
}
// Y axis
color(axiscolors[1]) {
xrot(-90) cylinder(h=axislen, d=axisdiam, center=false);
back(axislbllen) rot([90,0,90]) text3d(text="Y+");
xrot( 90) dottedline(l=axislen, d=axisdiam);
fwd(axislbllen) rot([90,0,-90]) text3d(text="Y-");
}
// Z axis
color(axiscolors[2]) {
cylinder(h=axislen, d=axisdiam, center=false);
up(axislbllen) rot([0,-90,90+$vpr[2]]) text3d(text="Z+");
xrot(180) dottedline(l=axislen, d=axisdiam);
down(axislbllen) rot([0,90,-90+$vpr[2]]) text3d(text="Z-");
}
for (ang = [0:90:270]) {
off = rot(p=40*BACK,ang);
translate(off) {
orient_cube(ang);
}
}
for (ang = [0:90:270]) {
off = rot(p=40*BACK,ang);
translate(off) {
orient_cube(ang);
}
}
}
@@ -77,4 +77,4 @@ orient_cubes();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -5,4 +5,4 @@ include <BOSL2/debug.scad>
prismoid([60,40], [30,20], h=40) show_anchors();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -3,46 +3,46 @@ include <BOSL2/paths.scad>
include <BOSL2/beziers.scad>
module leaf(s) {
path = [
[0,0], [1.5,-1],
[2,1], [0,3], [-2,1],
[-1.5,-1], [0,0]
];
xrot(90)
linear_sweep_bezier(
path * s/2,
height=0.02
);
path = [
[0,0], [1.5,-1],
[2,1], [0,3], [-2,1],
[-1.5,-1], [0,0]
];
xrot(90)
linear_sweep_bezier(
path * s/2,
height=0.02
);
}
module branches(minsize, s1, s2){
if(s2>minsize) {
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]) {
sc = gaussian_rands(0.7,0.05)[0];
cylinder(d1=s2, d2=s2*sc, l=s1)
branches(minsize, s1*sc, s2*sc);
}
} else {
recolor("springgreen")
attach(TOP) zrot(90)
leaf(gaussian_rands(100,5)[0]);
}
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]) {
sc = gaussian_rands(0.7,0.05)[0];
cylinder(d1=s2, d2=s2*sc, l=s1)
branches(minsize, s1*sc, s2*sc);
}
} else {
recolor("springgreen")
attach(TOP) zrot(90)
leaf(gaussian_rands(100,5)[0]);
}
}
module tree(h, d, minsize) {
sc = gaussian_rands(0.7,0.05)[0];
recolor("lightgray") {
cylinder(d1=d, d2=d*sc, l=h) {
branches(minsize, h, d*sc);
}
}
sc = gaussian_rands(0.7,0.05)[0];
recolor("lightgray") {
cylinder(d1=d, d2=d*sc, l=h) {
branches(minsize, h, d*sc);
}
}
}
tree(d=300, h=1500, minsize=10);
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -10,4 +10,4 @@ metric_bolt(headtype="oval", size=10, l=15, shank=5, details=true, phillips="#2"
show_anchors(5, std=false);
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -5,4 +5,4 @@ include <BOSL2/debug.scad>
spheroid(d=30) show_anchors();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -8,13 +8,13 @@ p = s * d;
q = s * 0.55 * d;
u = s * 2.5 * UP;
patch1 = [
[p[2], p[2]+q[3], p[3]+q[2], p[3] ],
[p[2]+q[1], p[2]+q[2]+u, p[3]+q[3]+u, p[3]+q[0]],
[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] ],
[p[2], p[2]+q[3], p[3]+q[2], p[3] ],
[p[2]+q[1], p[2]+q[2]+u, p[3]+q[3]+u, p[3]+q[0]],
[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");
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -3,13 +3,13 @@ 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");
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: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap