1module translate_copies(a=[[0,0,0]]) move_copies(a) children();
 2
 3module xspread(spacing, n, l, sp) xcopies(spacing=spacing, n=n, l=l, sp=sp) children();
 4module yspread(spacing, n, l, sp) ycopies(spacing=spacing, n=n, l=l, sp=sp) children();
 5module zspread(spacing, n, l, sp) zcopies(spacing=spacing, n=n, l=l, sp=sp) children();
 6
 7module spread(p1=[0,0,0], p2=[10,0,0], spacing, l, n=2) line_copies(p1=p1, p2=p2, spacing=spacing, l=l, n=n) children();
 8module grid_of(xa=[0],ya=[0],za=[0],count,spacing) grid3d(xa=xa, ya=ya, za=za, n=count, spacing=spacing) children();
 9
10module xring(n=2,r=0,sa=0,cp=[0,0,0],rot=true) xrot_copies(n=n,r=r,sa=sa,cp=cp,subrot=rot) children();
11module yring(n=2,r=0,sa=0,cp=[0,0,0],rot=true) yrot_copies(n=n,r=r,sa=sa,cp=cp,subrot=rot) children();
12module zring(n=2,r=0,sa=0,cp=[0,0,0],rot=true) zrot_copies(n=n,r=r,sa=sa,cp=cp,subrot=rot) children();
13
14module leftcube(size) cube(size, anchor=RIGHT);
15module rightcube(size) cube(size, anchor=LEFT);
16module fwdcube(size) cube(size, anchor=BACK);
17module backcube(size) cube(size, anchor=FWD);
18module downcube(size) cube(size, anchor=TOP);
19module upcube(size) cube(size, anchor=BOT);
20
21module cube2pt(p1,p2) cuboid(p1=p1,p2=p2);
22module offsetcube(size=[1,1,1],v=[0,0,0]) cuboid(size,anchor=-v);
23module rrect(size=[1,1,1], r=0.25, center=false) cuboid(size,rounding=r,edges="Z",anchor=center?CENTER:BOT);
24module rcube(size=[1,1,1], r=0.25, center=false) cuboid(size,rounding=r,anchor=center?CENTER:BOT);
25module chamfcube(size=[1,1,1],chamfer=0.25,chamfaxes=[1,1,1],chamfcorners=false) {
26    cuboid(
27        size=size, chamfer=chamfer,
28        trimcorners=chamfcorners,
29        edges=[
30            if (chamfaxes.x) "X",
31            if (chamfaxes.y) "Y",
32            if (chamfaxes.z) "Z",
33        ]
34    );
35}
36
37module trapezoid(size1=[1,1], size2=[1,1], h=1, shift=[0,0], align=CTR, orient=0, center)
38    prismoid(size1=size1, size2=size2, h=h, shift=shift, spin=orient, anchor=center==undef? -align : center?CENTER:BOT);
39
40module pyramid(n=4, h=1, l=1, r, d, circum=false) {
41    radius = get_radius(r=r, d=d, dflt=l/2/sin(180/n));
42    cyl(r1=radius, r2=0, l=h, circum=circum, $fn=n, realign=true, anchor=BOT);
43}
44
45module prism(n=3, h=1, l=1, r, d, circum=false, center=false) {
46    radius = get_radius(r=r, d=d, dflt=l/2/sin(180/n));
47    cyl(r=radius, l=h, circum=circum, $fn=n, realign=true, anchor=center?CENTER:BOT);
48}
49
50module chamferred_cylinder(h,r,d,chamfer=0.25,chamfedge,angle=45,top=true,bottom=true,center=false) {
51    chamf = chamfedge!=undef? chamfedge*sin(angle) : chamfer;
52    cyl(h=h, r=r, d=d, chamfer1=(bottom?chamf:0), chamfer2=(top?chamf:0), chamfang=angle, anchor=center?CENTER:BOT);
53}
54
55module chamf_cyl(h=1, r, d, chamfer=0.25, chamfedge, angle=45, center=false, top=true, bottom=true) {
56    chamf = chamfedge!=undef? chamfedge*sin(angle) : chamfer;
57    cyl(h=h, r=r, d=d, chamfer1=(bottom?chamf:0), chamfer2=(top?chamf:0), chamfang=angle, anchor=center?CENTER:BOT);
58}
59
60module filleted_cylinder(h=1, r, d, r1, r2, d1, d2, fillet=0.25, center=false)
61    cyl(l=h, r=r, d=d, r1=r1, r2=r2, d1=d1, d2=d2, rounding=fillet, anchor=center?CENTER:BOT);
62
63module rcylinder(h=1, r=1, r1, r2, d, d1, d2, fillet=0.25, center=false)
64    cyl(l=h, r=r, d=d, r1=r1, r2=r2, d1=d1, d2=d2, rounding=fillet, anchor=center?CENTER:BOT);
65
66module thinning_brace(h=50, l=100, thick=5, ang=30, strut=5, wall=3, center=true)
67    thinning_triangle(h=h, l=l, thick=thick, ang=ang, strut=strut, wall=wall, diagonly=true, center=center);
68
69
70// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
71