[
  {
    "path": ".gitmodules",
    "content": "[submodule \"SolidPython\"]\n\tpath = SolidPython\n\turl = git://github.com/SolidCode/SolidPython.git\n[submodule \"ThingDoc\"]\n\tpath = ThingDoc\n\turl = git://github.com/SolidCode/ThingDoc.git\n"
  },
  {
    "path": "2Dshapes.scad",
    "content": "/*\n *  OpenSCAD 2D Shapes Library (www.openscad.org)\n *  Copyright (C) 2012 Peter Uithoven\n *\n *  License: LGPL 2.1 or later\n*/\n\n// 2D Shapes\n//ngon(sides, radius, center=false);\n//complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true)\n//roundedSquare(pos=[10,10],r=2)\n//ellipsePart(width,height,numQuarters)\n//donutSlice(innerSize,outerSize, start_angle, end_angle) \n//pieSlice(size, start_angle, end_angle) //size in radius(es)\n//ellipse(width, height) {\n\n// Examples\n/*use <layouts.scad>;\ngrid(105,105,true,4)\n{\n\t// ellipse\n\tellipse(50,75);\n\n\t// part of ellipse (a number of quarters)\n\tellipsePart(50,75,3);\n\tellipsePart(50,75,2);\n\tellipsePart(50,75,1);\n\n\t// complexRoundSquare examples\n\tcomplexRoundSquare([75,100],[20,10],[20,10],[20,10],[20,10]);\n\tcomplexRoundSquare([75,100],[0,0],[0,0],[30,50],[20,10]);\n\tcomplexRoundSquare([50,50],[10,20],[10,20],[10,20],[10,20],false);\n\tcomplexRoundSquare([100,100]);\n\tcomplexRoundSquare([100,100],rads1=[20,20],rads3=[20,20]);\n\n\t// pie slice\n\tpieSlice(50,0,10);\n\tpieSlice(50,45,190);\n\tpieSlice([50,20],180,270);\n\n\t// donut slice\n\tdonutSlice(20,50,0,350);\n\tdonutSlice(30,50,190,270);\n\tdonutSlice([40,22],[50,30],180,270);\n\tdonutSlice([50,20],50,180,270);\n\tdonutSlice([20,30],[50,40],0,270);\n}*/\n//----------------------\n\n// size, top left radius, top right radius, bottom right radius, bottom left radius, center\nmodule complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true)\n{\n\twidth = size[0];\n\theight = size[1];\n\t//%square(size=[width, height],center=true);\n\tx1 = 0-width/2+rads1[0];\n\ty1 = 0-height/2+rads1[1];\n\tx2 = width/2-rads2[0];\n\ty2 = 0-height/2+rads2[1];\n\tx3 = width/2-rads3[0];\n\ty3 = height/2-rads3[1];\n\tx4 = 0-width/2+rads4[0];\n\ty4 = height/2-rads4[1];\n\n\tscs = 0.1; //straight corner size\n\n\tx = (center)? 0: width/2;\n\ty = (center)? 0: height/2;\n\n\ttranslate([x,y,0])\n\t{\n\t\thull() {\n\t\t\t// top left\n\t\t\tif(rads1[0] > 0 && rads1[1] > 0)\n\t\t\t\ttranslate([x1,y1]) mirror([1,0])\t\tellipsePart(rads1[0]*2,rads1[1]*2,1);\n\t\t\telse \n\t\t\t\ttranslate([x1,y1]) \t\t\t\t\t\tsquare(size=[scs, scs]);\n\t\t\t\n\t\t\t// top right\n\t\t\tif(rads2[0] > 0 && rads2[1] > 0)\n\t\t\t\ttranslate([x2,y2]) \t\t\t\t\t\tellipsePart(rads2[0]*2,rads2[1]*2,1);\t\n\t\t\telse \n\t\t\t\ttranslate([width/2-scs,0-height/2]) \tsquare(size=[scs, scs]);\n\n\t\t\t// bottom right\n\t\t\tif(rads3[0] > 0 && rads3[1] > 0)\n\t\t\t\ttranslate([x3,y3]) mirror([0,1]) \t\tellipsePart(rads3[0]*2,rads3[1]*2,1);\n\t\t\telse \n\t\t\t\ttranslate([width/2-scs,height/2-scs]) \tsquare(size=[scs, scs]);\n\t\t\t\n\t\t\t// bottom left\n\t\t\tif(rads4[0] > 0 && rads4[1] > 0)\n\t\t\t\ttranslate([x4,y4]) rotate([0,0,-180]) \tellipsePart(rads4[0]*2,rads4[1]*2,1);\n\t\t\telse \n\t\t\t\t#translate([x4,height/2-scs]) \tsquare(size=[scs, scs]);\n\t\t}\n\t}\n}\nmodule roundedSquare(pos=[10,10],r=2) {\n\tminkowski() {\n\t\tsquare([pos[0]-r*2,pos[1]-r*2],center=true);\n\t\tcircle(r=r);\n\t}\n}\n// round shapes\n// The orientation might change with the implementation of circle...\nmodule ngon(sides, radius, center=false){\n    rotate([0, 0, 360/sides/2]) circle(r=radius, $fn=sides, center=center);\n}\nmodule ellipsePart(width,height,numQuarters)\n{\n    o = 1; //slight overlap to fix a bug\n\tdifference()\n\t{\n\t\tellipse(width,height);\n\t\tif(numQuarters <= 3)\n\t\t\ttranslate([0-width/2-o,0-height/2-o,0]) square([width/2+o,height/2+o]);\n\t\tif(numQuarters <= 2)\n\t\t\ttranslate([0-width/2-o,-o,0]) square([width/2+o,height/2+o*2]);\n\t\tif(numQuarters < 2)\n\t\t\ttranslate([-o,0,0]) square([width/2+o*2,height/2+o]);\n\t}\n}\nmodule donutSlice(innerSize,outerSize, start_angle, end_angle) \n{   \n    difference()\n    {\n        pieSlice(outerSize, start_angle, end_angle);\n        if(len(innerSize) > 1) ellipse(innerSize[0]*2,innerSize[1]*2);\n        else circle(innerSize);\n    }\n}\nmodule pieSlice(size, start_angle, end_angle) //size in radius(es)\n{\t\n    rx = ((len(size) > 1)? size[0] : size);\n    ry = ((len(size) > 1)? size[1] : size);\n    trx = rx* sqrt(2) + 1;\n    try = ry* sqrt(2) + 1;\n    a0 = (4 * start_angle + 0 * end_angle) / 4;\n    a1 = (3 * start_angle + 1 * end_angle) / 4;\n    a2 = (2 * start_angle + 2 * end_angle) / 4;\n    a3 = (1 * start_angle + 3 * end_angle) / 4;\n    a4 = (0 * start_angle + 4 * end_angle) / 4;\n    if(end_angle > start_angle)\n        intersection() {\n\t\tif(len(size) > 1)\n        \tellipse(rx*2,ry*2);\n\t\telse\n\t\t\tcircle(rx);\n        polygon([\n            [0,0],\n            [trx * cos(a0), try * sin(a0)],\n            [trx * cos(a1), try * sin(a1)],\n            [trx * cos(a2), try * sin(a2)],\n            [trx * cos(a3), try * sin(a3)],\n            [trx * cos(a4), try * sin(a4)],\n            [0,0]\n       ]);\n    }\n}\nmodule ellipse(width, height) {\n  scale([1, height/width, 1]) circle(r=width/2);\n}"
  },
  {
    "path": "3d_triangle.scad",
    "content": "//    Enhancement of OpenSCAD Primitives Solid with Trinagles \n//    Copyright (C) 2011  Rene BAUMANN, Switzerland\n//\n//    This library is free software; you can redistribute it and/or\n//    modify it under the terms of the GNU Lesser General Public\n//    License as published by the Free Software Foundation; either\n//    version 2.1 of the License, or (at your option) any later version.\n//\n//    This library is distributed in the hope that it will be useful,\n//    but WITHOUT ANY WARRANTY; without even the implied warranty of\n//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n//    Lesser General Public License for more details.\n//\n//    You should have received a copy of the GNU Lesser General Public\n//    License along with this library; If not, see <http://www.gnu.org/licenses/>\n//    or write to the Free Software Foundation, Inc., \n//    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n// ================================================================\n//\n//\tFile providing functions and modules to draw 3D - triangles \n//\tcreated in the X-Y plane with hight h, using various triangle \n//\tspecification methods. \n//\tStandard traingle geometrical definition  is used. Vertices are named A,B,C, \n//\tside a is opposite vertex A a.s.o. the angle at vertex A is named alpha, \n//\tB(beta), C(gamma).\n//\n//\tThis SW is a contribution to the Free Software Community doing a marvelous\n//\tjob of giving anyone access to knowledge and tools to educate himselfe.\n//\n//\tAuthor:\t\tRene Baumann\n//\tDate:\t\t11.09.2011\n//\tEdition:\t0.3\t11.09.2011 For review by Marius\n//\tEdition:\t0.4\t11.11.2011 Ref to GPL2.1 added\n//\n// --------------------------------------------------------------------------------------\n//\n// ===========================================\n//\n//\tFUNCTION: \t\t3dtri_sides2coord\n//\tDESCRIPTION:\n//\t\tEnter triangle sides a,b,c and to get the A,B,C - corner\n// \t\tco-ordinates. The trinagle's c-side lies on the x-axis\n// \t\tand A-corner in the co-ordinates center [0,0,0]. Geometry rules\n//\t\trequired that a + b is greater then c.  The traingle's vertices are\n//\t\tcomputed such that it is located in the X-Y plane,  side c is on the \n//\t\tpositive x-axis. \n//\tPARAMETER:\n//\t\ta\t: real\t\tlength of side a\n//\t\tb\t: real\t\tlength of side b\n//\t\tc\t: real\t\tlength of side c\n//\tRETURNS:\n//\t\tvertices : [Acord,Bcord,Ccord] Array of vertices coordinates\n//\n//\tCOMMENT:\n//\t\tvertices = 3dtri_sides2coord (3,4,5);\n//\t\tvertices[0] : Acord\tvertex A cordinates the like [x,y,z] \n// -------------------------------------------------------------------------------------\t\n//\nfunction 3dtri_sides2coord (a,b,c) = [\n\t\t[0,0,0],\n\t\t[c,0,0], \n\t\t[(pow(c,2)+pow(a,2)-pow(b,2))/(2*c),sqrt ( pow(a,2) - \n\t\t   pow((pow(c,2)+pow(a,2)-pow(b,2))/(2*c),2)),0]];\n//\n//\n// ===========================================\n//\n//\tFUNCTION: \t\t3dtri_centerOfGravityCoord\n//\tDESCRIPTION:\n//\t\tEnter triangle  A,B,C - corner coordinates to get the\n//\t\ttriangles Center of Gravity coordinates. It is assumed\n//\t\tthe triangle is parallel to the  X-Y plane. The function \n//\t\treturns always zero for the z-coordinate\n//\tPARAMETER:\n//\t\tAcord\t: [x,y,z] \tCoordinates of vertex A\n//\t\tBcord\t: [x,y,z] \tCoordinates of vertex B\n//\t\tCcord\t: [x,y,z] \tCoordinates of vertex C\n//\tRETURNS:\n//\t\tCG : [x,y,0] \tCenter of gravity coordinate in X-Y-plane\n//\n//\tCOMMENT:\n//\t\tvertices = 3dtri_sides2coord (3,4,5);\n//\t\tcg = 3dtri_centerOfGravityCoord(vertices[0],vertices[1],vertices[2]);\n// -------------------------------------------------------------------------------------\t\n//\nfunction 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [\n\t\t(Acord[0]+Bcord[0]+Ccord[0])/3,(Acord[1]+Bcord[1]+Ccord[1])/3,0];\n//\n//\n// ===========================================\n//\n//\tFUNCTION: \t\t3dtri_centerOfcircumcircle\n//\tDESCRIPTION:\n//\t\tEnter triangle  A,B,C - corner coordinates to get the\n//\t\tcircum circle coordinates. It is assumed\n//\t\tthe triangle is parallel to the  X-Y plane. The function \n//\t\treturns always zero for the z-coordinate\n//\tPARAMETER:\n//\t\tAcord\t: [x,y,z] \tCoordinates of vertex A\n//\t\tBcord\t: [x,y,z] \tCoordinates of vertex B\n//\t\tCcord\t: [x,y,z] \tCoordinates of vertex C\n//\tRETURNS:\n//\t\tcc\t: [x,y,0] \tCircumcircle center\n//\n//\tCOMMENT:\n//\t\tvertices = 3dtri_sides2coord (3,4,5);\n//\t\tcc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]);\n// -------------------------------------------------------------------------------------\t\n//\nfunction 3dtri_centerOfcircumcircle (Acord,Bcord,Ccord) = \n\t\t[0.5*Bcord[0],\n\t\t 0.5*((pow(Ccord[1],2)+pow(Ccord[0],2)-Bcord[0]*Ccord[0])/Ccord[1]),\n\t\t 0];\n//\n// \n//\n// ===========================================\n//\n//\tFUNCTION: \t\t3dtri_radiusOfcircumcircle\n//\tDESCRIPTION:\n//\t\t Provides the triangle's radius from circumcircle  to the vertices.\n//\t\tIt is assumed the triangle is parallel to the  X-Y plane. The function \n//\t\treturns always zero for the z-coordinate\n//\tPARAMETER:\n//\t\tVcord\t:   [x,y,z] \tCoordinates of a vertex A or B,C\n//\t\tCCcord : [x,y,z] \tCoordinates of circumcircle\n//\t\tr\t: Radius at vertices if round corner triangle used,\n//\t\t\t  else enter \"0\"\n//\tRETURNS:\n//\t\tcr\t: Circumcircle radius\n//\n//\tCOMMENT:  Calculate circumcircle radius of trinagle with round vertices having\n//\t\t\tradius R = 2\n//\t\tvertices = 3dtri_sides2coord (3,4,5);\n//\t\tcc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]);\n//\t\tcr = 3dtri_radiusOfcircumcircle (vertices[0],cc,2); \n// -------------------------------------------------------------------------------------\t\n//\nfunction 3dtri_radiusOfcircumcircle (Vcord,CCcord,R) = \n\t\tsqrt(pow(CCcord[0]-Vcord[0],2)+pow(CCcord[1]-Vcord[1],2))+ R;\n//\n//\n//\n// ===========================================\n//\n//\tFUNCTION: \t\t3dtri_radiusOfIn_circle\n//\tDESCRIPTION:\n//\t\tEnter triangle  A,B,C - corner coordinates to get the\n//\t\tin-circle radius. It is assumed the triangle is parallel to the  \n//\t\tX-Y plane. The function always returns zero for the z-coordinate. \n//\t\tFormula used for inner circle radius: r = 2A /(a+b+c)\n//\tPARAMETER:\n//\t\tAcord\t: [x,y,z] \tCoordinates of vertex A\n//\t\tBcord\t: [x,y,z] \tCoordinates of vertex B\n//\t\tCcord\t: [x,y,z] \tCoordinates of vertex C\n//\t\t\n//\tRETURNS:\n//\t\tir\t: real\t\tradius of in-circle\n//\n//\tCOMMENT:\n//\t\tvertices = 3dtri_sides2coord (3,4,5);\n//\t\tir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]);\n// -------------------------------------------------------------------------------------\t\n//\nfunction 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = \n\tBcord[0]*Ccord[1]/(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+\n\tsqrt(pow(Ccord[0],2)+pow(Ccord[1],2)));\n//\n// \n//\n// ===========================================\n//\n//\tFUNCTION: \t\t3dtri_centerOfIn_circle\n//\tDESCRIPTION:\n//\t\tEnter triangle  A,B,C - corner coordinates to get the\n//\t\tin-circle coordinates. It is assumed\n//\t\tthe triangle is parallel to the  X-Y plane. The function \n//\t\treturns always zero for the z-coordinate\n//\tPARAMETER:\n//\t\tAcord\t: [x,y,z] \tCoordinates of vertex A\n//\t\tBcord\t: [x,y,z] \tCoordinates of vertex B\n//\t\tCcord\t: [x,y,z] \tCoordinates of vertex C\n//\t\tr\t: real\t\tradius of in-circle\n//\tRETURNS:\n//\t\tic\t: [x,y,0] \tIn-circle center co-ordinates\n//\n//\tCOMMENT:\n//\t\tvertices = 3dtri_sides2coord (3,4,5);\n//\t\tir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]);\n//\t\tic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir);\n// -------------------------------------------------------------------------------------\t\n//\nfunction 3dtri_centerOfIn_circle (Acord,Bcord,Ccord,r) = \n\t\t[(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+\n\tsqrt(pow(Ccord[0],2)+pow(Ccord[1],2)))/2-sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2)),r,0];\n//\n//\n// ============================================\n//\n//\tMODULE: \t\t3dtri_draw\n//\tDESCRIPTION:\n//\t\t Draw a standard solid triangle with A,B,C - vertices specified by its \n// \t\tco-ordinates and height \"h\", as given by the  input parameters. \n//\tPARAMETER:\n//\t\tAcord\t: [x,y,z] \tCoordinates of vertex A\n//\t\tBcord\t: [x,y,z] \tCoordinates of vertex B\n//\t\tCcord\t: [x,y,z] \tCoordinates of vertex C\n//\t\th\t: real\t\tHight of the triangle\n//\tRETURNS:\n//\t\tnone\n//\n//\tCOMMENT:\n//\t\tYou might use the result from function 3dtri_sides2coord\n//\t\tto call module 3dtri_draw ( vertices[0],vertices[1],vertices[2], h) \n// -------------------------------------------------------------------------------------\t\n//\nmodule 3dtri_draw ( Acord, Bcord, Ccord, h) {\npolyhedron (points=[Acord,Bcord,Ccord,\n\t\t\t\t\tAcord+[0,0,h],Bcord+[0,0,h],Ccord+[0,0,h]],\n\t\t\ttriangles=[\t[0,1,2],[0,2,3],[3,2,5],\n\t\t\t\t\t[3,5,4],[1,5,2],[4,5,1],\n\t\t\t\t\t[4,1,0],[0,3,4]]);\n\n};\n//\n//\n// ==============================================\n//\n//\tMODULE: \t\t3dtri_rnd_draw\n//\tDESCRIPTION:\n//\t\tDraw a round corner triangle with A,B,C - vertices specified by its \n// \t\tco-ordinates, height h and round vertices having radius \"r\".\n//\t\tAs specified by the input parameters.\n//\t\tPlease note, the tringles side lenght gets extended by \"2 * r\",\n//\t\tand the vertices coordinates define the centers of the \n//\t\tcircles with radius \"r\". \n//\tPARAMETER:\n//\t\tAcord\t: [x,y,z] \tCoordinates of vertex A\n//\t\tBcord\t: [x,y,z] \tCoordinates of vertex B\n//\t\tCcord\t: [x,y,z] \tCoordinates of vertex C\n//\t\th\t: real\t\tHight of the triangle\n//\t\tr\t: real\t\tRadius from vertices coordinates\n//\tRETURNS:\n//\t\tnone\n//\n//\tCOMMENT:\n//\t\tYou might use the result from function 3dtri_sides2coord\n//\t\tto call module 3dtri_rnd_draw ( vertices[0],vertices[1],vertices[2], h, r) \n// -------------------------------------------------------------------------------------\t\n//\nmodule 3dtri_rnd_draw ( Acord, Bcord, Ccord, h, r) {\nAvect=Ccord-Bcord;\t// vector pointing from vertex B to vertex C\np0=Acord + [0,-r,0];\np1=Bcord + [0,-r,0];\np2=Bcord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), \n                    -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0];\np3=Ccord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), \n                     -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0];\np4=Ccord +[- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), \n                     r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0];\np5=Acord + [- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), \n                     r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0];\nbottom_triangles = [[0,1,2],[0,2,3],[0,3,4],[0,4,5]];\nc_side_triangles = [[7,1,0],[0,6,7]];\na_side_triangles = [[2,8,3],[8,9,3]];\nb_side_triangles = [[4,10,5],[10,11,5]];\nA_edge_triangles = [[0,5,11],[0,11,6]];\nB_edge_triangles = [[1,7,2],[2,7,8]];\nC_edge_triangles = [[3,9,4],[9,10,4]];\ntop_triangles = [[11,7,6],[11,8,7],[11,10,8],[8,10,9]];\nunion () { \n\tpolyhedron (points=[p0,p1,p2,p3,p4,p5,\n\t\t\t\t\tp0+[0,0,h],p1+[0,0,h],p2+[0,0,h],p3+[0,0,h],p4+[0,0,h],p5+[0,0,h]],\n\t\t\ttriangles=[\tbottom_triangles[0],bottom_triangles[1],bottom_triangles[2],bottom_triangles[3],\n\t\t\t\t\t\tA_edge_triangles[0],A_edge_triangles[1],\n\t\t\t\t\t\tc_side_triangles[0],c_side_triangles[1],\n\t\t\t\t\t\tB_edge_triangles[0],B_edge_triangles[1],\n\t\t\t\t\t\ta_side_triangles[0],a_side_triangles[1],\n\t\t\t\t\t\tC_edge_triangles[0],C_edge_triangles[1],\n\t\t\t\t\t\tb_side_triangles[0],b_side_triangles[1],\n\t\t\t\t\t\ttop_triangles[0],top_triangles[1],top_triangles[2],top_triangles[3]]);\n\ttranslate(Acord) cylinder(r1=r,r2=r,h=h,center=false);\n\ttranslate(Bcord) cylinder(r1=r,r2=r,h=h,center=false);\n\ttranslate(Ccord) cylinder(r1=r,r2=r,h=h,center=false);\n};\n}\n//\n// ==============================================\n//\n// Demo Application - copy into new file and uncomment or uncomment here but\n// without uncommenting the use <...> statement, then press F6 - Key \n//\n// use <MCAD/3d_triangle.scad>;\n//$fn=50;\n//  h =4;\n//  r=2;\n//  echo (\"Draws a right angle triangle with its circumcircle and in-circle\");\n//  echo (\"The calculated co-ordinates and radius are show in this console window\");\n//  echo (\"Geometry rules for a right angle triangle say, that the circumcircle is the\");\n//  echo (\"Thales Circle which center must be in the middle of the triangle's c - side\");\n//  echo (\"===========================================\");\n//  vertices  =  3dtri_sides2coord (30,40,50);\n//  echo(\"A = \",vertices[0],\"  B = \",vertices[1],\"  C = \",vertices[2]);\n//  cg = 3dtri_centerOfGravityCoord (vertices[0],vertices[1],vertices[2]);\n//  echo (\" Center of gravity = \",cg);\n//  cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]);\n//  echo (\" Center of circumcircle = \",cc);\n//  cr = 3dtri_radiusOfcircumcircle (vertices[0],cc,r); \n//  echo(\" Radius of circumcircle \",cr);\n//  ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]);\n//  echo (\" Radius of in-circle = \",ir);\n//  ic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir);\n//  echo (\" Center of in-circle = \",ic);\n//   translate(cc+[0,0,5*h/2]) difference () {\n//  \t\tcylinder (h=5*h,r1=cr+4,r2=cr+4,center=true);\n//  \t\tcylinder (h=6*h,r1=cr,r2=cr,center=true);}\n//  difference () {\n//  \tunion () {\n//  \t     difference () {\n//   \t\t3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r);\n//  \t\tscale([0.8,0.8,1]) translate([6,2,4*h])  3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r);\n//  \t     }\n//  \t     translate (ic+[0,0,5*h]) cylinder(h=10*h,r1=ir+r,r2=ir+r,center=true);\n//  \t}\n//  \ttranslate (ic+[0,0,5*h]) cylinder(h=12*h,r1=0.5*ir,r2=0.5*ir,center=true);\n//  }\n\n"
  },
  {
    "path": "README.markdown",
    "content": "OpenSCAD MCAD Library\n=====================\n\nThis library contains components commonly used in designing and moching up\nmechanical designs. Looking for active co-maintainers: https://github.com/SolidCode/MCAD/issues/22\n\nThis library is licensed under the LGPL 2.1\nSee http://creativecommons.org/licenses/LGPL/2.1/ or the included file, lgpl-2.1.txt.\n\n## Usage ##\n\nYou can import these files in your scripts with `use <MCAD/filename.scad>`, \nwhere 'filename' is one of the files listed below like 'motors' or \n'servos'. Some files include useful constants which will be available \nwith `include <MCAD/filename.scad>`, which should be safe to use on all \nincluded files (ie. no top level code should create geometry). (There is \na bug/feature that prevents including constants from files that \n\"include\" other files - see the openscad mailing list archives for more \ndetails. Since the maintainers aren't very responsive, may have to work \naround this somehow)\n\nIf you host your project in git, you can do `git submodule add URL PATH` in your\nrepo to import this library as a git submodule for easy usage. Then you need to do\na `git submodule update --init` after cloning. When you want to update the submodule,\ndo `cd PATH; git checkout master; git pull`. See `git help submodule` for more info.\n\"./get_submodules.py\" is shortcut that initializes and updates submodules.\n\nCurrently Provided Tools:\n\n* regular_shapes.scad\n    - regular polygons, ie. 2D\n    - regular polyhedrons, ie. 3D\n\n* involute_gears.scad (http://www.thingiverse.com/thing:3575):\n    - gear()\n    - bevel_gear()\n    - bevel_gear_pair()\n\n* gears.scad (Old version):\n    - gear(number_of_teeth, circular_pitch OR diametrial_pitch, pressure_angle OPTIONAL, clearance OPTIONAL)\n\n* motors.scad:\n    - stepper_motor_mount(nema_standard, slide_distance OPTIONAL, mochup OPTIONAL)\n\nOther tools (alpha and beta quality):\n\n* nuts_and_bolts.scad: for creating metric and imperial bolt/nut holes\n* bearing.scad: standard/custom bearings\n* screw.scad: screws and augers\n* materials.scad: color definitions for different materials\n* stepper.scad: NEMA standard stepper outlines\n* servos.scad: servo outlines\n* boxes.scad: box with rounded corners\n* triangles.scad: simple triangles\n* 3d_triangle.scad: more advanced triangles\n\nVery generally useful functions and constants:\n\n* math.scad: general math functions\n* constants.scad: mathematical constants\n* curves.scad: mathematical functions defining curves\n* units.scad: easy metric units\n* utilities.scad: geometric funtions and misc. useful stuff\n* teardrop.scad (http://www.thingiverse.com/thing:3457): parametric teardrop module\n* shapes.scad: DEPRECATED simple shapes by Catarina Mota\n* polyholes.scad: holes that should come out well when printed\n\nExternal utils that generate and and process openscad code:\n\n* openscad_testing.py: testing code, see below\n* openscad_utils.py: code for scraping function names etc.\n* SolidPython: An external Python library for solid cad\n\n## Development ##\n\nYou are welcome to fork this project in github and request pulls. I will try to\naccomodate the community as much as possible in this. If for any reason you\nwant collaborator access, just ask. Looking for new co-maintainers, there are\nlots of fixes and additions spread in different forks, would be nice to have\nhave the best of them consolidated here. See: https://github.com/SolidCode/MCAD/issues/22\n\nGithub is fun (and easy), but I can include code submissions and other\nimprovements directly, and have already included code from various sources\n(thingiverse is great :)\n\n### Code style ###\nI'd prefer to have all included code nicely indented, at least at the block\nlevel, and no extraneous whitespace. I'm used to indent with four spaces as\nopposed to tabs or other mixes of whitespace, but at least try to choose a style\nand stick to it.\n\n### Testing ###\nI've started a minimal testing infrastucture for OpenSCAD code. It's written in\npython and uses py.test (might be compatible with Nose also). Just type `py.test`\ninside the lib dir in a terminal and you should see a part of the tests passing\nand tracebacks for failing tests. It's very simplistic still, but it should test\nthat no syntax errors occur at least.\n\nThe code is included in openscad_testing.py, and can be imported to be\nused in other codebases.\n"
  },
  {
    "path": "TODO",
    "content": "Code that could be integrated:\n* http://github.com/l0b0/qr2scad\n* http://github.com/l0b0/img2scad\n* http://github.com/l0b0/OpenSCAD-Minimizer\n* http://www.thingiverse.com/thing:4656\n* http://www.thingiverse.com/thing:4758\n* http://www.thingiverse.com/thing:6021\n* Color library: http://www.thingiverse.com/thing:6717\n* http://www.thingiverse.com/thing:6465\n\nIntegrate these better:\n* bitmap\n\nTesting:\n* add tests for openscad functions\n* motors.scad\n* tests for 2D stuff\n\nCode style:\n* motors.scad\n* nuts_and_bolts.scad\n"
  },
  {
    "path": "__init__.py",
    "content": ""
  },
  {
    "path": "bearing.scad",
    "content": "/*\n * Bearing model.\n *\n * Originally by Hans Häggström, 2010.\n * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later\n */\n\ninclude <units.scad>\ninclude <materials.scad>\n\n// Example, uncomment to view\n//test_bearing();\n//test_bearing_hole();\n\nmodule test_bearing(){\n    bearing();\n    bearing(pos=[5*cm, 0,0], angle=[90,0,0]);\n    bearing(pos=[-2.5*cm, 0,0], model=688);\n}\n\nmodule test_bearing_hole(){\n    difference(){\n      translate([0, 0, 3.5]) cube(size=[30, 30, 7-10*epsilon], center=true);\n      bearing(outline=true);\n    }\n}\n\nBEARING_INNER_DIAMETER = 0;\nBEARING_OUTER_DIAMETER = 1;\nBEARING_WIDTH = 2;\n\n// Common bearing names\nSkateBearing = 608;\n\n// Bearing dimensions\n// model == XXX ? [inner dia, outer dia, width]:\nfunction bearingDimensions(model) =\n  model == 608 ? [8*mm, 22*mm, 7*mm]:\n  model == 623 ? [3*mm, 10*mm, 4*mm]:\n  model == 624 ? [4*mm, 13*mm, 5*mm]:\n  model == 627 ? [7*mm, 22*mm, 7*mm]:\n  model == 688 ? [8*mm, 16*mm, 4*mm]:\n  model == 698 ? [8*mm, 19*mm, 6*mm]:\n  [8*mm, 22*mm, 7*mm]; // this is the default\n\n\nfunction bearingWidth(model) = bearingDimensions(model)[BEARING_WIDTH];\nfunction bearingInnerDiameter(model) = bearingDimensions(model)[BEARING_INNER_DIAMETER];\nfunction bearingOuterDiameter(model) = bearingDimensions(model)[BEARING_OUTER_DIAMETER];\n\nmodule bearing(pos=[0,0,0], angle=[0,0,0], model=SkateBearing, outline=false,\n                material=Steel, sideMaterial=Brass) {\n  // Common bearing names\n  model =\n    model == \"Skate\" ? 608 :\n    model;\n\n  w = bearingWidth(model);\n  innerD = outline==false ? bearingInnerDiameter(model) : 0;\n  outerD = bearingOuterDiameter(model);\n\n  innerRim = innerD + (outerD - innerD) * 0.2;\n  outerRim = outerD - (outerD - innerD) * 0.2;\n  midSink = w * 0.1;\n\n  translate(pos) rotate(angle) union() {\n    color(material)\n      difference() {\n        // Basic ring\n        Ring([0,0,0], outerD, innerD, w, material, material);\n\n        if (outline==false) {\n          // Side shields\n          Ring([0,0,-epsilon], outerRim, innerRim, epsilon+midSink, sideMaterial, material);\n          Ring([0,0,w-midSink], outerRim, innerRim, epsilon+midSink, sideMaterial, material);\n        }\n      }\n  }\n\n  module Ring(pos, od, id, h, material, holeMaterial) {\n    color(material) {\n      translate(pos)\n        difference() {\n          cylinder(r=od/2, h=h,  $fs = 0.01);\n          color(holeMaterial)\n            translate([0,0,-10*epsilon])\n              cylinder(r=id/2, h=h+20*epsilon,  $fs = 0.01);\n        }\n    }\n  }\n\n}\n\n\n"
  },
  {
    "path": "bitmap/README",
    "content": "This is an OpenSCAD module that let's you easily (well kinda) create 3D text. I've emulated the Atari 8-Bit fonts A-Z, a-z, 0-9, and most punctuation. You can create them a letter at a time or pass an array of characters. (OpenSCAD doesn't have any real string manipulation)\n\nIt also has a bitmap module that you can use to define your own fonts. It's pretty simple, you pass it an array of numbers, then tell it how many bits per row and it creates cubes (of configurable width and height) in a grid and combines them into a single shape.  The number in the array sets the pixel height modifier.  So if you set height to 5 and the array value is 2, then the height of that pixel will be 10mm.\n\nBe careful when defining your own bitmaps in that you can't have two bits only connected diagonally. Otherwise OpenSCAD will say it's not manifold. For instance you can't have:\n\n0 0 0\n0 1 0\n0 0 1\n\nBut you can have:\n\n0 0 0\n0 1 1\n0 0 1\n\nFor more info see: http://www.thingiverse.com/thing:2054\n"
  },
  {
    "path": "bitmap/alphabet_block.scad",
    "content": "/*\nParametric Alphabet Block \nTony Buser <tbuser@gmail.com>\nhttp://tonybuser.com\nhttp://creativecommons.org/licenses/by/3.0/\n*/\n\nuse <bitmap.scad>\n\n// change to any letter\nletter = \"A\";\n\nunion() {\n\tdifference() {\n\t\tcube(size = 20);\n\t\ttranslate(v = [2, 2, 17]) {\n\t\t\tcube(size = [16, 16, 5]);\n\t\t}\n\t}\n\n\ttranslate(v = [10, 10, 15]) {\n\t\t8bit_char(letter, 2, 5);\n\t}\n}\n"
  },
  {
    "path": "bitmap/bitmap.scad",
    "content": "/*\nBitmap and 8Bit Font Module\nTony Buser <tbuser@gmail.com>\nhttp://tonybuser.com\nhttp://creativecommons.org/licenses/by/3.0/\n*/\n\nmodule bitmap(bitmap, block_size, height, row_size) {\n\twidth = block_size * row_size;\n\tbitmap_size = row_size * row_size;\n\t\n\tfunction loc_x(loc) = floor(loc / row_size) * block_size;\n\tfunction loc_y(loc) = loc % row_size * block_size;\n\tfunction loc_z(loc) = (bitmap[loc]*height-height)/2;\n\n\ttranslate(v = [-width/2+block_size/2,-width/2+block_size/2,height/2]) {\n\t\tfor (loc = [0:bitmap_size - 1]) {\n\t\t\tif (bitmap[loc] != 0) {\n\t\t\t\tunion() {\n\t\t\t\t\ttranslate(v = [loc_x(loc), loc_y(loc), loc_z(loc)]) {\n\t\t\t\t\t\tcube(size = [block_size, block_size, height * bitmap[loc]], center = true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nmodule 8bit_char(char, block_size, height, include_base) {\n\tif (char == \"0\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,1,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"1\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"2\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"3\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"4\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,1,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"5\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"6\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"7\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"8\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"9\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"A\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"B\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"C\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"D\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,0,0,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"E\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"F\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"G\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"H\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"I\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"J\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,1,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"K\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,1,1,0,0,0,\n\t\t\t0,1,1,1,1,0,0,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"L\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"M\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,1,1,1,0,1,1,1,\n\t\t\t0,1,1,1,1,1,1,1,\n\t\t\t0,1,1,0,1,0,1,1,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"N\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,0,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"O\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"P\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"Q\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,0,1,1,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"R\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"S\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"T\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"U\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"V\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"W\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,1,1,0,1,0,1,1,\n\t\t\t0,1,1,1,1,1,1,1,\n\t\t\t0,1,1,1,0,1,1,1,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"X\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"Y\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"Z\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"OE\") {\n\t\tbitmap([\n\t\t\t0,0,1,0,0,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"a\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"b\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"c\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"d\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"e\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"f\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,1,1,1,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"g\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"h\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"i\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"j\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"k\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,1,1,0,0,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"l\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"m\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,1,1,\n\t\t\t0,1,1,1,1,1,1,1,\n\t\t\t0,1,1,0,1,0,1,1,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"n\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"o\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"p\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"q\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,1,1,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"r\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"s\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"t\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"u\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"v\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"w\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,1,1,\n\t\t\t0,1,1,0,1,0,1,1,\n\t\t\t0,1,1,1,1,1,1,1,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,1,1,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"x\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"y\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,1,1,1,1,0,0,0\n\t\t], block_size, height, 8);\n\t} else if (char == \"z\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"+\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"-\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \":\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \".\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \",\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"?\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"=\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"*\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t1,1,1,1,1,1,1,1,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"!\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"''\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"#\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t1,1,1,1,1,1,1,1,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t1,1,1,1,1,1,1,1,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"$\") {\n\t\tbitmap([\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,1,1,1,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"%\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,1,1,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"&\") {\n\t\tbitmap([\n\t\t\t0,0,0,1,1,1,0,0,\n\t\t\t0,0,1,1,0,1,1,0,\n\t\t\t0,0,0,1,1,1,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,1,1,0,1,1,1,1,\n\t\t\t0,1,1,0,1,1,1,0,\n\t\t\t0,0,1,1,1,0,1,1,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"@\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,1,1,0,0,1,1,0,\n\t\t\t0,1,1,0,1,1,1,0,\n\t\t\t0,1,1,0,1,1,1,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"'\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"(\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,1,1,1,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,0,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \")\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,0,1,1,1,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,1,0,0,\n\t\t\t0,0,1,1,1,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"<\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \">\") {\n\t\tbitmap([\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"[\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"]\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,1,1,1,1,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"/\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,1,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"\\\\\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,1,1,0,0,0,0,0,\n\t\t\t0,0,1,1,0,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,0,1,1,0,0,\n\t\t\t0,0,0,0,0,1,1,0,\n\t\t\t0,0,0,0,0,0,1,0,\n\t\t\t0,0,0,0,0,0,0,0\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"_\") {\n\t\tbitmap([\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t0,0,0,0,0,0,0,0,\n\t\t\t1,1,1,1,1,1,1,1\n\t\t], block_size, height, 8);\n\t} else \tif (char == \"|\") {\n\t\tbitmap([\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0,\n\t\t\t0,0,0,1,1,0,0,0\n\t\t], block_size, height, 8);\n\t} else {\n\t\techo(\"Invalid Character: \", char);\n\t}\n\n}\n\nmodule 8bit_str(chars, char_count, block_size, height) {\n\techo(str(\"Total Width: \", block_size * 8 * char_count, \"mm\"));\n\tunion() {\n\t\tfor (count = [0:char_count-1]) {\n\t\t\ttranslate(v = [0, count * block_size * 8, 0]) {\n\t\t\t\t8bit_char(chars[count], block_size, height);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n<bitmap.scad>\n\nblock_size = 5;\nheight = 10;\n\nunion() {\n\ttranslate(v = [0,0,5]) {\n\t\t8bit_char(\"A\", block_size, height);\n\n\t\t//bitmap([\n\t\t//\t1,1,1,1,1,1,1,1,\n\t\t//\t1,0,0,1,1,0,0,1,\n\t\t//\t1,0,1,1,1,1,0,1,\n\t\t//\t1,1,1,0,0,1,1,1,\n\t\t//\t1,1,1,0,0,1,1,1,\n\t\t//\t1,0,1,1,1,1,0,1,\n\t\t//\t1,0,0,1,1,0,0,1,\n\t\t//\t1,1,1,1,1,1,1,1\n\t\t//], block_size, height, 8);\n\n\t\t//bitmap([\n\t\t//\t1,1,1,1, \n\t\t//\t1,0,0,1, \n\t\t//\t1,0,0,1, \n\t\t//\t1,1,1,1 \n\t\t//], block_size, height, 4);\n\t}\n\ttranslate(v = [0,0,5/2]) {\n\t\tcolor([0,0,1,1]) {\n\t\t\tcube(size = [block_size * 8, block_size * 8, 5], center = true);\n\t\t}\n\t}\n}\n\n<bitmap.scad>\n\nchars = [\"T\",\"O\",\"N\",\"Y\",\"\",\"B\",\"U\",\"S\",\"E\",\"R\"];\nchar_count = 10;\nblock_size = 1;\nheight = 5;\n\nunion() {\n\ttranslate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) {\n\t\t8bit_str(chars, char_count, block_size, height);\n\t}\n\ttranslate(v = [0,0,5/2]) {\n\t\tcolor([0,0,1,1]) {\n\t\t\tcube(size = [block_size * 8, block_size * 8 * char_count, 5], center = true);\n\t\t}\n\t}\n}\n*/\n"
  },
  {
    "path": "bitmap/height_map.scad",
    "content": "/*\nHeight Map Example\nTony Buser <tbuser@gmail.com>\nhttp://tonybuser.com\nhttp://creativecommons.org/licenses/by/3.0/\n\nCan also dynamically run this by passing an array on the command line:\n\n/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad\n*/\n\nuse <bitmap.scad>\n\nblock_size = 5;\nheight = 5;\n\nrow_size = 10; // 10x10 pixels\nbitmap = [\n\t1,1,0,0,1,1,0,0,1,1,\n\t1,1,1,1,1,1,1,1,1,1,\n\t0,1,2,2,1,1,2,2,1,0,\n\t0,1,2,1,1,1,1,2,1,0,\n\t1,1,1,1,3,3,1,1,1,1,\n\t1,1,1,1,3,3,1,1,1,1,\n\t0,1,2,1,1,1,1,2,1,0,\n\t0,1,2,2,1,1,2,2,1,0,\n\t1,1,1,1,1,1,1,1,1,1,\n\t1,1,0,0,1,1,0,0,1,1\n];\n\nbitmap(bitmap, block_size, height, row_size);\n"
  },
  {
    "path": "bitmap/letter_necklace.scad",
    "content": "/*\nParametric letters for for a necklace\nElmo Mäntynen <elmo.mantynen@iki.fi>\nLGPL 2.1\n*/\n\nuse <bitmap.scad>\n\n// change chars array and char_count\n// OpenSCAD has no string or length methods :(\nchars = [\"M\",\"a\",\"k\",\"e\",\"r\",\"B\",\"o\",\"t\"];\nchar_count = 8;\n\n// block size 1 will result in 8mm per letter\nblock_size = 2;\n// height is the Z height of each letter\nheight = 3;\n\n//Hole for the necklace\nhole_diameter = 5;\n\nmodule 8bit_str(chars, char_count, block_size, height) {\n\techo(str(\"Total Width: \", block_size * 8 * char_count, \"mm\"));\n\tunion() {\n\t\tfor (count = [0:char_count-1]) {\n\t\t\ttranslate(v = [0, count * block_size * 8, 0]) {\n\t\t\t\t8bit_char(chars[count], block_size, height);\n\t\t\t}\n\t\t}\n\t}\n}\n\nmodule letter(char, block_size, height, hole_diameter) {\n\tunion() {\n\t\ttranslate(v = [0,0, hole_diameter*1.3]) {\n\t\t\t8bit_char(char, block_size, height);\n\t\t}\n\t\ttranslate(v = [0,0,(hole_diameter*1.3)/2]) {\n\t\t\tcolor([0,0,1,1]) {\n\t\t\t\tdifference() {\n\t\t\t\t\tcube(size = [block_size * 8, block_size * 8, hole_diameter+2], center = true);\n\t\t\t\t\trotate([90, 0, 0]) cylinder(h = block_size * 8 + 1, r = hole_diameter/2, center = true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nmatrix = [[\"O\",  \"L\", \"E\", \"N\", \"S\"], \n\t\t[ \"Y\", \"OE\", \"N\", \"Y\", \"T\"]];\n\nunion() {\n\tfor (column = [0:1]) {\n\t\tfor (row = [0:4]) {\n\t\t\ttranslate(v=[column*(block_size*1.1)*8, row*(block_size*1.1)*8, 0])\n\t\t\t\tletter(matrix[column][row], block_size, height, hole_diameter);\n\t\t}\n\t}\t\n}\n"
  },
  {
    "path": "bitmap/name_tag.scad",
    "content": "/*\nParametric Name Tag \nTony Buser <tbuser@gmail.com>\nhttp://tonybuser.com\nhttp://creativecommons.org/licenses/by/3.0/\n*/\n\nuse <bitmap.scad>\n\n// change chars array and char_count\n// OpenSCAD has no string or length methods :(\nchars = [\"R\", \"E\", \"P\", \"R\", \"A\", \"P\"];\nchar_count = 6;\n\n\n// block size 1 will result in 8mm per letter\nblock_size = 2;\n// height is the Z height of each letter\nheight = 3;\n// Append a hole fo a keyring, necklace etc. ?\nkey_ring_hole = true;\n\nunion() {\n\ttranslate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) {\n\t\t8bit_str(chars, char_count, block_size, height);\n\t}\n\ttranslate(v = [0,0,3/2]) {\n\t\tcolor([0,0,1,1]) {\n\t\t\tcube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true);\n\t\t}\n\t}\n\tif (key_ring_hole == true){\n\t\ttranslate([0, block_size * 8 * (char_count+1)/2, 3/2])\t\n\t\tdifference(){\n\t\t\tcube(size = [block_size * 8, block_size * 8 , 3], center = true);\n\t\t\tcube(size = [block_size * 4, block_size * 4 , 5], center = true);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "boxes.scad",
    "content": "// Library: boxes.scad\n// Version: 1.0\n// Author: Marius Kintel\n// Copyright: 2010\n// License: BSD\n\n// roundedBox([width, height, depth], float radius, bool sidesonly);\n\n// EXAMPLE USAGE:\n// roundedBox([20, 30, 40], 5, true);\n\n// size is a vector [w, h, d]\nmodule roundedBox(size, radius, sidesonly)\n{\n  rot = [ [0,0,0], [90,0,90], [90,90,0] ];\n  if (sidesonly) {\n    cube(size - [2*radius,0,0], true);\n    cube(size - [0,2*radius,0], true);\n    for (x = [radius-size[0]/2, -radius+size[0]/2],\n           y = [radius-size[1]/2, -radius+size[1]/2]) {\n      translate([x,y,0]) cylinder(r=radius, h=size[2], center=true);\n    }\n  }\n  else {\n    cube([size[0], size[1]-radius*2, size[2]-radius*2], center=true);\n    cube([size[0]-radius*2, size[1], size[2]-radius*2], center=true);\n    cube([size[0]-radius*2, size[1]-radius*2, size[2]], center=true);\n\n    for (axis = [0:2]) {\n      for (x = [radius-size[axis]/2, -radius+size[axis]/2],\n             y = [radius-size[(axis+1)%3]/2, -radius+size[(axis+1)%3]/2]) {\n        rotate(rot[axis])\n          translate([x,y,0])\n          cylinder(h=size[(axis+2)%3]-2*radius, r=radius, center=true);\n      }\n    }\n    for (x = [radius-size[0]/2, -radius+size[0]/2],\n           y = [radius-size[1]/2, -radius+size[1]/2],\n           z = [radius-size[2]/2, -radius+size[2]/2]) {\n      translate([x,y,z]) sphere(radius);\n    }\n  }\n}\n"
  },
  {
    "path": "constants.scad",
    "content": "// MIT license\n\n\nTAU = 6.2831853071; //2*PI, see http://tauday.com/\nPI = TAU/2;\n\n// translates a imperial measurement in inches to meters\nmm_per_inch = 25.4;\n\n"
  },
  {
    "path": "curves.scad",
    "content": "// Parametric curves, to be used as paths\n// Licensed under the MIT license.\n// © 2010 by Elmo Mäntynen\nuse <math.scad>\ninclude <constants.scad>\n\n\n\n/* A circular helix of radius a and pitch 2πb is described by the following parametrisation:\nx(t) = a*cos(t),\ny(t) = a*sin(t),\nz(t) = b*t\n*/\n\n\nfunction b(pitch) = pitch/(TAU);\nfunction t(pitch, z) = z/b(pitch);\n\nfunction helix_curve(pitch, radius, z) =\n    [radius*cos(deg(t(pitch, z))), radius*sin(deg(t(pitch, z))), z];\n\n"
  },
  {
    "path": "fonts.scad",
    "content": "// Font Functions\n// Encoding from http://en.wikipedia.org/wiki/ASCII\n\nmodule outline_2d(outline,points,paths,width=0.1,resolution=8) {\n  if(outline && resolution > 4) {\n    for(j=[0:len(paths)-1]) union() {\n      for(i=[1:len(paths[j])-1]) hull() {\n            translate(points[paths[j][i-1]]) circle($fn=resolution,r=width/2);\n            translate(points[paths[j][i]]) circle($fn=resolution,r=width/2);\n      }\n      hull() {\n            translate(points[paths[j][len(paths[j])-1]]) circle($fn=resolution,r=width/2);\n            translate(points[paths[j][0]]) circle($fn=resolution,r=width/2);\n      }\n    }\n  } else {\n      polygon(points=points,paths=paths);\n  }\n}\n\nmodule bold_2d(bold,width=0.2,resolution=8) {\n  for(j=[0:$children-1]) {\n    if(bold) {\n      union() {\n            child(j);\n        for(i=[0:resolution-1]) assign(dx=width*cos(360*i/resolution),dy=width*sin(360*i/resolution))\n              translate([dx,dy]) child(j);\n      }\n    } else {\n      child(j);\n    }\n  }\n}\n\nfunction 8bit_polyfont(dx=0.1,dy=0.1) = [\n  [8,8,0,\"fixed\"],[\"Decimal Byte\",\"Caret Notation\",\"Character Escape Code\",\"Abbreviation\",\"Name\",\"Bound Box\",\"[points,paths]\"]\n  ,[\n   [  0,\"^@\",\"\\0\",\"NUL\",\"Null character\",[[0,0],[8,8]],[]]\n  ,[  1,\"^A\",\"\",  \"SOH\",\"Start of Header\",[[0,0],[8,8]],[]]\n  ,[  2,\"^B\",\"\",  \"STX\",\"Start of Text\",[[0,0],[8,8]],[]]\n  ,[  3,\"^C\",\"\",  \"ETX\",\"End of Text\",[[0,0],[8,8]],[]]\n  ,[  4,\"^D\",\"\",  \"EOT\",\"End of Transmission\",[[0,0],[8,8]],[]]\n  ,[  5,\"^E\",\"\",  \"ENQ\",\"Enquiry\",[[0,0],[8,8]],[]]\n  ,[  6,\"^F\",\"\",  \"ACK\",\"Acknowledgment\",[[0,0],[8,8]],[]]\n  ,[  7,\"^G\",\"\\a\",\"BEL\",\"Bell\",[[0,0],[8,8]],[]]\n  ,[  8,\"^H\",\"\\b\",\"BS\", \"Backspace\",[[0,0],[8,8]],[]]\n  ,[  9,\"^I\",\"\\t\",\"HT\", \"Horizontal Tab\",[[0,0],[8,8]],[]]\n  ,[ 10,\"^J\",\"\\n\",\"LF\", \"Line Feed\",[[0,0],[8,8]],[]]\n  ,[ 11,\"^K\",\"\\v\",\"VT\", \"Vertical Tab\",[[0,0],[8,8]],[]]\n  ,[ 12,\"^L\",\"\\f\",\"FF\", \"Form feed\",[[0,0],[8,8]],[]]\n  ,[ 13,\"^M\",\"\\r\",\"CR\", \"Carriage return\",[[0,0],[8,8]],[]]\n  ,[ 14,\"^N\",\"\",  \"SO\", \"Shift Out\",[[0,0],[8,8]],[]]\n  ,[ 15,\"^O\",\"\",  \"SI\", \"Shift In\",[[0,0],[8,8]],[]]\n  ,[ 16,\"^P\",\"\",  \"DLE\",\"Data Link Escape\",[[0,0],[8,8]],[]]\n  ,[ 17,\"^Q\",\"\",  \"DC1\",\"Device Control 1\",[[0,0],[8,8]],[]]\n  ,[ 18,\"^R\",\"\",  \"DC2\",\"Device Control 2\",[[0,0],[8,8]],[]]\n  ,[ 19,\"^S\",\"\",  \"DC3\",\"Device Control 3\",[[0,0],[8,8]],[]]\n  ,[ 20,\"^T\",\"\",  \"DC4\",\"Device Control 4\",[[0,0],[8,8]],[]]\n  ,[ 21,\"^U\",\"\",  \"NAK\",\"Negative Acknowledgement\",[[0,0],[8,8]],[]]\n  ,[ 22,\"^V\",\"\",  \"SYN\",\"Synchronous Idle\",[[0,0],[8,8]],[]]\n  ,[ 23,\"^W\",\"\",  \"ETB\",\"End of Transmission Block\",[[0,0],[8,8]],[]]\n  ,[ 24,\"^X\",\"\",  \"CAN\",\"Cancel\",[[0,0],[8,8]],[]]\n  ,[ 25,\"^Y\",\"\",  \"EM\", \"End of Medium\",[[0,0],[8,8]],[]]\n  ,[ 26,\"^Z\",\"\",  \"SUB\",\"Substitute\",[[0,0],[8,8]],[]]\n  ,[ 27,\"^[\",\"\\e\",\"ESC\",\"Escape\",[[0,0],[8,8]],[]]\n  ,[ 28,\"^\\\\\",\"\", \"FS\", \"File Separator\",[[0,0],[8,8]],[]]\n  ,[ 29,\"^]\",\"\",  \"GS\", \"Group Separator\",[[0,0],[8,8]],[]]\n  ,[ 30,\"^^\",\"\",  \"RS\", \"Record Separator\",[[0,0],[8,8]],[]]\n  ,[ 31,\"^_\",\"\",  \"US\", \"Unit Separator\",[[0,0],[8,8]],[]]\n  ,[ 32,\" \",\" \",  \"\", \"Space\",[[0,0],[2,8]],[]]\n  ,[ 33,\"!\",\"!\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,2],[5,2],[5,1]\n\t,[3,3],[3,7],[5,7],[5,3]]\n\t,[[0,1,2,3],[4,5,6,7]]\n\t]]\n  ,[ 34,\"\\\"\",\"\\\"\",\"\", \"\",[[0,0],[8,8]],[\n\t[[1,4],[1,7],[3,7],[3,4]\n\t,[5,4],[5,7],[7,7],[7,4]]\n\t,[[0,1,2,3],[4,5,6,7]]\n\t]]\n  ,[ 35,\"#\",\"#\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[0,2],[0,3],[1,3],[1,5],[0,5],[0,6],[1,6],[1,7],[3,7],[3,6],[5,6],[5,7],[7,7]\n\t\t,[7,6],[8,6],[8,5],[7,5],[7,3],[8,3],[8,2],[7,2],[7,1],[5,1],[5,2],[3,2],[3,1]\n\t,[3,3],[3,5],[5,5],[5,3]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27],[28,29,30,31]]\n\t]]\n  ,[ 36,\"$\",\"$\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,2],[1,2],[1,3],[5,3],[5,4],[2,4],[2,5],[1,5],[1,6],[2,6],[2,7],[3,7],[3,8],[5,8],[5,7],[7,7],[7,6]\n\t\t,[3,6],[3,5],[6,5],[6,4],[7,4],[7,3],[6,3],[6,2],[5,2],[5,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]]\n\t]]\n  ,[ 37,\"%\",\"%\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,3],[2,3],[2,5],[1,5],[1,7],[3,7],[3,5],[4,5],[4,6],[5,6],[5,7],[7,7]\n\t\t,[7,6],[6,6],[6,5],[5,5],[5,4],[4,4],[4,3],[3,3],[3,2],[2,2],[2,1]\n\t,[5,1],[5,3],[7,3],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],[24,25,26,27]]\n\t]]\n  ,[ 38,\"&\",\"&\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,4],[2,4],[2,5],[3,5],[3,6],[2,6],[2,7],[3,7],[3,8],[6,8],[6,7],[7,7],[7,6],[6,6],[6,5],[5,5],[5,4]\n\t\t,[8,4],[8,3],[7,3],[7,2],[8,2],[8,1],[6,1],[6,2],[5,2],[5,1]\n\t,[3,2],[3,4],[4,4],[4,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],[30,31,32,33]]\n\t]]\n  ,[ 39,\"'\",\"'\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,4],[3,7],[5,7],[5,4]]\n\t,[[0,1,2,3]]\n\t]]\n  ,[ 40,\"(\",\"(\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,2],[2,2],[2,6],[3,6],[3,7],[6,7],[6,6],[5,6],[5,5],[4,5],[4,3],[5,3],[5,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[ 41,\")\",\")\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[3,2],[3,3],[4,3],[4,5],[3,5],[3,6],[2,6],[2,7],[5,7],[5,6],[6,6],[6,2],[5,2],[5,1],[4,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]]\n\t]]\n  ,[ 42,\"*\",\"*\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,2],[1,3],[2,3],[2,4],[0,4],[0,5],[2,5],[2,6],[1,6],[1,7],[3,7],[3,6],[5,6],[5,7],[7,7],[7,6],[6,6]\n\t\t,[6,5],[8,5],[8,4],[6,4],[6,3],[7,3],[7,2],[5,2],[5,3],[3,3],[3,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]]\n\t]]\n  ,[ 43,\"+\",\"+\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,3],[1,3],[1,5],[3,5],[3,7],[5,7],[5,5],[7,5],[7,3],[5,3],[5,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11]]\n\t]]\n  ,[ 44,\",\",\",\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,0],[2,1],[3,1],[3,3],[5,3],[5,1],[4,1],[4,0]]\n\t,[[0,1,2,3,4,5,6,7]]\n\t]]\n  ,[ 45,\"-\",\"-\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,3],[1,5],[7,5],[7,3]]\n\t,[[0,1,2,3]]\n\t]]\n  ,[ 46,\".\",\".\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,3],[5,3],[5,1]]\n\t,[[0,1,2,3]]\n\t]]\n  ,[ 47,\"/\",\"/\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,3],[2,3],[2,4],[3,4],[3,5],[4,5],[4,6],[5,6],[5,7],[7,7],[7,6],[6,6],[6,5],[5,5],[5,4],[4,4],[4,3],[3,3],[3,2],[2,2],[2,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]]\n\t]]\n  ,[ 48,\"0\",\"0\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,2],[6,2],[6,1]\n\t,[3,2],[3,3],[5,3],[5,2]\n\t,[3,4],[3,6],[5,6],[5,5],[4,5],[4,4]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11],[12,13,14,15],[16,17,18,19,20,21]]\n\t]]\n  ,[ 49,\"1\",\"1\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[3,2],[3,5],[2,5],[2,6],[3,6],[3,7],[5,7],[5,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11]]\n\t]]\n  ,[ 50,\"2\",\"2\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[2,2],[2,3],[3,3],[3,4],[4,4],[4,5],[5,5],[5,6],[3,6],[3,5],[1,5],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,5],[6,5],[6,4],[5,4],[5,3],[4,3],[4,2],[3,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]]\n\t]]\n  ,[ 51,\"3\",\"3\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,3],[3,3],[3,2],[5,2],[5,3],[4,3],[4,4],[3,4],[3,5],[4,5],[4,6],[1,6],[1,7],[7,7],[7,6],[6,6],[6,5],[5,5],[5,4],[6,4],[6,3],[7,3],[7,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]]\n\t]]\n  ,[ 52,\"4\",\"4\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[4,1],[4,2],[1,2],[1,4],[2,4],[2,5],[3,5],[3,6],[4,6],[4,7],[6,7],[6,3],[7,3],[7,2],[6,2],[6,1]\n\t,[3,3],[3,4],[4,4],[4,3]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[16,17,18,19]]\n\t]]\n  ,[ 53,\"5\",\"5\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,3],[3,3],[3,2],[5,2],[5,4],[1,4],[1,7],[7,7],[7,6],[3,6],[3,5],[6,5],[6,4],[7,4],[7,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[ 54,\"6\",\"6\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[2,6],[2,7],[6,7],[6,6],[3,6],[3,5],[6,5],[6,4],[7,4],[7,2],[6,2],[6,1]\n\t,[3,2],[3,4],[5,4],[5,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[16,17,18,19]]\n\t]]\n  ,[ 55,\"7\",\"7\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,3],[3,3],[3,4],[4,4],[4,5],[5,5],[5,6],[1,6],[1,7],[7,7],[7,5],[6,5],[6,4],[5,4],[5,3],[4,3],[4,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]]\n\t]]\n  ,[ 56,\"8\",\"8\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,4],[2,4],[2,5],[1,5],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,5],[6,5],[6,4],[7,4],[7,2],[6,2],[6,1]\n\t,[3,2],[3,4],[5,4],[5,2]\n\t,[3,5],[3,6],[5,6],[5,5]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],[20,21,22,23],[24,25,26,27]]\n\t]]\n  ,[ 57,\"9\",\"9\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[4,2],[4,3],[5,3],[5,4],[2,4],[2,5],[1,5],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,3],[6,3],[6,2],[5,2],[5,1]\n\t,[3,5],[3,6],[5,6],[5,5]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],[20,21,22,23]]\n\t]]\n  ,[ 58,\":\",\":\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,3],[5,3],[5,1]\n\t,[3,4],[3,6],[5,6],[5,4]]\n\t,[[0,1,2,3],[4,5,6,7]]\n\t]]\n  ,[ 59,\";\",\";\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,0],[2,1],[3,1],[3,3],[5,3],[5,1],[4,1],[4,0]\n\t,[3,4],[3,6],[5,6],[5,4]]\n\t,[[0,1,2,3,4,5,6,7],[8,9,10,11]]\n\t]]\n  ,[ 60,\"<\",\"<\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[5,1],[5,2],[4,2],[4,3],[3,3],[3,4],[2,4],[2,5],[3,5],[3,6],[4,6],[4,7],[5,7],[5,8],[7,8],[7,7],[6,7],[6,6],[5,6],[5,5],[4,5],[4,4],[5,4],[5,3],[6,3],[6,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]]\n\t]]\n  ,[ 61,\"=\",\"=\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,2],[1,3],[7,3],[7,2]\n\t,[1,5],[1,6],[7,6],[7,5]]\n\t,[[0,1,2,3],[4,5,6,7]]\n\t]]\n  ,[ 62,\">\",\">\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[2,2],[2,3],[3,3],[3,4],[4,4],[4,5],[3,5],[3,6],[2,6],[2,7],[1,7],[1,8],[3,8],[3,7],[4,7],[4,6],[5,6],[5,5],[6,5],[6,4],[5,4],[5,3],[4,3],[4,2],[3,2],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]]\n\t]]\n  ,[ 63,\"?\",\"?\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,2],[5,2],[5,1]\n\t,[3,3],[3,4],[4,4],[4,5],[5,5],[5,6],[3,6],[3,5],[1,5],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,5],[6,5],[6,4],[5,4],[5,3]]\n\t,[[0,1,2,3],[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]]\n\t]]\n  ,[ 64,\"@\",\"@\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,3],[4,3],[4,5],[5,5],[5,6],[3,6],[3,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]]\n\t]]\n  ,[ 65,\"A\",\"A\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,5],[2,5],[2,6],[3,6],[3,7],[5,7],[5,6],[6,6],[6,5],[7,5],[7,1],[5,1],[5,2],[3,2],[3,1]\n\t,[3,3],[3,5],[5,5],[5,3]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[16,17,18,19]]\n\t]]\n  ,[ 66,\"B\",\"B\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[6,7],[6,6],[7,6],[7,5],[6,5],[6,4],[7,4],[7,2],[6,2],[6,1]\n\t,[3,5],[3,6],[5,6],[5,5]\n\t,[3,2],[3,4],[5,4],[5,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11],[12,13,14,15],[16,17,18,19]]\n\t]]\n  ,[ 67,\"C\",\"C\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,5],[5,5],[5,6],[3,6],[3,2],[5,2],[5,3],[7,3],[7,2],[6,2],[6,1]]\t    ,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[ 68,\"D\",\"D\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[5,7],[5,6],[6,6],[6,5],[7,5],[7,3],[6,3],[6,2],[5,2],[5,1]\n\t,[3,2],[3,6],[4,6],[4,5],[5,5],[5,3],[4,3],[4,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11],[12,13,14,15,16,17,18,19]]\n\t]]\n  ,[ 69,\"E\",\"E\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[7,7],[7,6],[3,6],[3,5],[6,5],[6,4],[3,4],[3,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11]]\n\t]]\n  ,[ 70,\"F\",\"F\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[7,7],[7,6],[3,6],[3,5],[6,5],[6,4],[3,4],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9]]\n\t]]\n  ,[ 71,\"G\",\"G\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[2,6],[2,7],[7,7],[7,6],[3,6],[3,2],[5,2],[5,3],[4,3],[4,4],[7,4],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[ 72,\"H\",\"H\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,5],[5,5],[5,7],[7,7],[7,1],[5,1],[5,4],[3,4],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11]]\n\t]]\n  ,[ 73,\"I\",\"I\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[3,2],[3,6],[1,6],[1,7],[7,7],[7,6],[5,6],[5,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11]]\n\t]]\n  ,[ 74,\"J\",\"J\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,3],[3,3],[3,2],[5,2],[5,6],[4,6],[4,7],[7,7],[7,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13]]\n\t]]\n  ,[ 75,\"K\",\"K\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,5],[4,5],[4,6],[5,6],[5,7],[7,7],[7,6],[6,6],[6,5],[5,5],[5,3],[6,3],[6,2],[7,2],[7,1],[5,1],[5,2],[4,2],[4,3],[3,3],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]]\n\t]]\n  ,[ 76,\"L\",\"L\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5]]\n\t]]\n  ,[ 77,\"M\",\"M\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,6],[4,6],[4,5],[5,5],[5,6],[6,6],[6,7],[8,7],[8,1],[6,1],[6,4],[5,4],[5,3],[4,3],[4,4],[3,4],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[ 78,\"N\",\"N\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,6],[4,6],[4,5],[5,5],[5,7],[7,7],[7,1],[5,1],[5,2],[4,2],[4,3],[3,3],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[ 79,\"O\",\"O\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,2],[6,2],[6,1]\n\t,[3,2],[3,6],[5,6],[5,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11],[12,13,14,15]]\n\t]]\n  ,[ 80,\"P\",\"P\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[6,7],[6,6],[7,6],[7,4],[6,4],[6,3],[3,3],[3,1]\n\t,[3,4],[3,6],[5,6],[5,4]]\n\t,[[0,1,2,3,4,5,6,7,8,9],[10,11,12,13]]\n\t]]\n  ,[ 81,\"Q\",\"Q\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[2,6],[2,7],[6,7],[6,6],[7,6],[7,3],[6,3],[6,2],[7,2],[7,1],[5,1],[5,2],[4,2],[4,1]\n\t,[3,3],[3,6],[5,6],[5,3]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],[18,19,20,21]]\n\t]]\n  ,[ 82,\"R\",\"R\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[6,7],[6,6],[7,6],[7,4],[6,4],[6,2],[7,2],[7,1],[5,1],[5,2],[4,2],[4,3],[3,3],[3,1]\n\t,[3,4],[3,6],[5,6],[5,4]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[16,17,18,19]]\n\t]]\n  ,[ 83,\"S\",\"S\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[5,2],[5,4],[2,4],[2,5],[1,5],[1,6],[2,6],[2,7],[6,7],[6,6],[3,6],[3,5],[6,5],[6,4],[7,4],[7,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[ 84,\"T\",\"T\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,6],[1,6],[1,7],[7,7],[7,6],[5,6],[5,1]]\n\t,[[0,1,2,3,4,5,6,7]]\n\t]]\n  ,[ 85,\"U\",\"U\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,2],[5,2],[5,7],[7,7],[7,1]]\n\t,[[0,1,2,3,4,5,6,7]]\n\t]]\n  ,[ 86,\"V\",\"V\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,2],[2,2],[2,3],[1,3],[1,7],[3,7],[3,3],[5,3],[5,7],[7,7],[7,3],[6,3],[6,2],[5,2],[5,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[ 87,\"W\",\"W\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,4],[4,4],[4,5],[5,5],[5,4],[6,4],[6,7],[8,7],[8,1],[6,1],[6,2],[5,2],[5,3],[4,3],[4,2],[3,2],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[ 88,\"X\",\"X\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,3],[2,3],[2,5],[1,5],[1,7],[3,7],[3,5],[5,5],[5,7],[7,7],[7,5],[6,5],[6,3],[7,3],[7,1],[5,1],[5,3],[3,3],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[ 89,\"Y\",\"Y\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,4],[2,4],[2,5],[1,5],[1,7],[3,7],[3,5],[5,5],[5,7],[7,7],[7,5],[6,5],[6,4],[5,4],[5,1],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]]\n\t]]\n  ,[ 90,\"Z\",\"Z\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,3],[2,3],[2,4],[3,4],[3,5],[4,5],[4,6],[1,6],[1,7],[7,7],[7,6],[6,6],[6,5],[5,5],[5,4],[4,4],[4,3],[3,3],[3,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]]\n\t]]\n  ,[ 91,\"[\",\"[\",  \"\", \"\",[[0,0],[8,8]],[ // ] ]\n\t[[2,1],[2,7],[6,7],[6,6],[4,6],[4,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7]]\n\t]]\n  ,[ 92,\"\\\\\",\"\\\\\",\"\", \"\",[[0,0],[8,8]],[\n\t[[6,1],[6,2],[5,2],[5,3],[4,3],[4,4],[3,4],[3,5],[2,5],[2,6],[1,6],[1,7],[3,7],[3,6],[4,6],[4,5],[5,5],[5,4],[6,4],[6,3],[7,3],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]]\n\t]] \n  ,[ 93,\"]\",\"]\",  \"\", \"\",[[0,0],[8,8]],[  // [ [ \n\t[[2,1],[2,2],[4,2],[4,6],[2,6],[2,7],[6,7],[6,1]]\n\t,[[0,1,2,3,4,5,6,7]]\n\t]]\n  ,[ 94,\"^\",\"^\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,4],[2,5]\n\t\t,[3-dx,5],[3,5+dy]\n\t,[3,6]\n\t\t,[4-dx,6],[4,6+dy]\n\t,[4,7],[5,7]\n\t\t,[5,6+dy],[5+dx,6]\n\t,[6,6]\n\t\t,[6,5+dy],[6+dx,5]\n\t,[7,5],[7,4],[6,4]\n\t\t,[6,5-dy],[6-dx,5]\n\t,[5,5]\n\t\t,[5,6-dy],[5-dx,6],[4+dx,6],[4,6-dy]\n\t,[4,5]\n\t\t,[3+dx,5],[3,5-dy]\n\t,[3,4]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]]\n\t]]\n  ,[ 95,\"_\",\"_\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[0,0],[0,1],[8,1],[8,0]]\n\t,[[0,1,2,3]]\n\t]]\n  ,[ 96,\"`\",\"`\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,6],[2,7],[3,7]\n\t\t,[3,6+dy],[3+dx,6]\n\t,[4,6]\n\t\t,[4,5+dy],[4+dx,5]\n\t,[5,5],[5,4],[4,4]\n\t\t,[4,5-dy],[4-dx,5]\n\t,[3,5]\n\t\t,[3,6-dy],[3-dx,6]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[ 97,\"a\",\"a\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,3],[2,3],[2,4],[5,4],[5,5],[2,5],[2,6],[6,6],[6,5],[7,5],[7,1]\n\t,[3,2],[3,3],[5,3],[5,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13],[14,15,16,17]]\n\t]]\n  ,[ 98,\"b\",\"b\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,5],[6,5],[6,4],[7,4],[7,2],[6,2],[6,1]\n\t,[3,2],[3,4],[5,4],[5,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9],[10,11,12,13]]\n\t]]\n  ,[ 99,\"c\",\"c\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,5],[2,5],[2,6],[6,6],[6,5],[3,5],[3,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11]]\n\t]]\n  ,[100,\"d\",\"d\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,4],[2,4],[2,5],[5,5],[5,7],[7,7],[7,1]\n\t,[3,2],[3,4],[5,4],[5,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9],[10,11,12,13]]\n\t]]\n  ,[101,\"e\",\"e\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,5],[2,5],[2,6],[6,6],[6,5],[7,5],[7,3],[3,3],[3,2],[6,2],[6,1]\n\t,[3,4],[3,5],[5,5],[5,4]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13],[14,15,16,17]]\n\t]]\n  ,[102,\"f\",\"f\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,4],[2,4],[2,5],[3,5],[3,6],[4,6],[4,7],[7,7],[7,6],[5,6],[5,5],[7,5],[7,4],[5,4],[5,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[103,\"g\",\"g\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,0],[1,1],[5,1],[5,2],[2,2],[2,3],[1,3],[1,5],[2,5],[2,6],[6,6],[6,5],[7,5],[7,1],[6,1],[6,0]\n\t,[3,3],[3,5],[5,5],[5,3]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[16,17,18,19]]\n\t]]\n  ,[104,\"h\",\"h\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,5],[6,5],[6,4],[7,4],[7,1],[5,1],[5,4],[3,4],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11]]\n\t]]\n  ,[105,\"i\",\"i\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[3,2],[3,4],[2,4],[2,5],[5,5],[5,2],[6,2],[6,1]\n\t,[3,6],[3,7],[5,7],[5,6]]\n\t,[[0,1,2,3,4,5,6,7,8,9],[10,11,12,13]]\n\t]]\n  ,[106,\"j\",\"j\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,0],[2,1],[5,1],[5,5],[7,5],[7,1],[6,1],[6,0]\n\t,[5,6],[5,7],[7,7],[7,6]]\n\t,[[0,1,2,3,4,5,6,7],[8,9,10,11]]\n\t]]\n  ,[107,\"k\",\"k\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,7],[3,7],[3,4],[4,4],[4,5],[6,5],[6,4],[5,4],[5,3],[6,3],[6,2],[7,2],[7,1],[5,1],[5,2],[4,2],[4,3],[3,3],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[108,\"l\",\"l\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[3,2],[3,6],[2,6],[2,7],[5,7],[5,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9]]\n\t]]\n  ,[109,\"m\",\"m\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,6],[3,6],[3,5],[5,5],[5,6],[7,6],[7,5],[8,5],[8,1],[6,1],[6,3],[5,3],[5,2],[4,2],[4,3],[3,3],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]]\n\t]]\n  ,[110,\"n\",\"n\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,6],[6,6],[6,5],[7,5],[7,1],[5,1],[5,5],[3,5],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9]]\n\t]]\n  ,[111,\"o\",\"o\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,5],[2,5],[2,6],[6,6],[6,5],[7,5],[7,2],[6,2],[6,1]\n\t,[3,2],[3,5],[5,5],[5,2]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11],[12,13,14,15]]\n\t]]\n  ,[112,\"p\",\"p\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,0],[1,6],[6,6],[6,5],[7,5],[7,3],[6,3],[6,2],[3,2],[3,0]\n\t,[3,3],[3,5],[5,5],[5,3]]\n\t,[[0,1,2,3,4,5,6,7,8,9],[10,11,12,13]]\n\t]]\n  ,[113,\"q\",\"q\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[5,0],[5,2],[2,2],[2,3],[1,3],[1,5],[2,5],[2,6],[7,6],[7,0]\n\t,[3,3],[3,5],[5,5],[5,3]]\n\t,[[0,1,2,3,4,5,6,7,8,9],[10,11,12,13]]\n\t]]\n  ,[114,\"r\",\"r\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,6],[6,6],[6,5],[7,5],[7,4],[5,4],[5,5],[3,5],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9]]\n\t]]\n  ,[115,\"s\",\"s\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[5,2],[5,3],[2,3],[2,4],[1,4],[1,5],[2,5],[2,6],[7,6],[7,5],[3,5],[3,4],[6,4],[6,3],[7,3],[7,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[116,\"t\",\"t\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[4,1],[4,2],[3,2],[3,5],[1,5],[1,6],[3,6],[3,7],[5,7],[5,6],[7,6],[7,5],[5,5],[5,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[117,\"u\",\"u\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[1,2],[1,6],[3,6],[3,2],[5,2],[5,6],[7,6],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9]]\n\t]]\n  ,[118,\"v\",\"v\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,1],[3,2],[2,2],[2,3],[1,3],[1,6],[3,6],[3,3],[5,3],[5,6],[7,6],[7,3],[6,3],[6,2],[5,2],[5,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]\n\t]]\n  ,[119,\"w\",\"w\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,3],[1,3],[1,6],[3,6],[3,4],[4,4],[4,5],[5,5],[5,4],[6,4],[6,6],[8,6],[8,3],[7,3],[7,1],[5,1],[5,2],[4,2],[4,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[120,\"x\",\"x\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[2,2],[2,3],[3,3],[3,4],[2,4],[2,5],[1,5],[1,6],[3,6],[3,5],[5,5],[5,6],[7,6],[7,5],[6,5],[6,4],[5,4],[5,3],[6,3],[6,2],[7,2],[7,1],[5,1],[5,2],[3,2],[3,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]]\n\t]]\n  ,[121,\"y\",\"y\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,0],[1,1],[4,1],[4,2],[2,2],[2,3],[1,3],[1,6],[3,6],[3,3],[5,3],[5,6],[7,6],[7,2],[6,2],[6,1],[5,1],[5,0]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]]\n\t]]\n  ,[122,\"z\",\"z\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[1,1],[1,2],[2,2],[2,3],[3,3],[3,4],[4,4],[4,5],[1,5],[1,6],[7,6],[7,5],[6,5],[6,4],[5,4],[5,3],[4,3],[4,2],[7,2],[7,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[123,\"{\",\"{\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[4,1],[4,2],[3,2],[3,4],[2,4],[2,5],[3,5],[3,7],[4,7],[4,8],[6,8],[6,7],[5,7],[5,5],[4,5],[4,4],[5,4],[5,2],[6,2],[6,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[124,\"|\",\"|\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[3,0],[3,8],[5,8],[5,0]]\n\t,[[0,1,2,3]]\n\t]]\n  ,[125,\"}\",\"}\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,1],[2,2],[3,2],[3,4],[4,4],[4,5],[3,5],[3,7],[2,7],[2,8],[4,8],[4,7],[5,7],[5,5],[6,5],[6,4],[5,4],[5,2],[4,2],[4,1]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[126,\"~\",\"~\",  \"\", \"\",[[0,0],[8,8]],[\n\t[[2,5],[2,6]\n\t\t,[3-dx,6],[3,6+dy]\n\t,[3,7],[5,7],[5,6]\n\t\t,[6-dx,6],[6,6+dy]\n\t,[6,7],[7,7],[7,6]\n\t\t,[6+dx,6],[6,6-dy]\n\t,[6,5],[4,5],[4,6]\n\t\t,[3+dx,6],[3,6-dy]\n\t,[3,5]]\n\t,[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]]\n\t]]\n  ,[127,\"^?\",\"\",  \"DEL\",\"Delete\",[[0,0],[8,8]],[]]\n  ] ];\n\n"
  },
  {
    "path": "gears.scad",
    "content": "// Copyright 2010 D1plo1d\n// LGPL 2.1\n\n\n//test_involute_curve();\n//test_gears();\n//demo_3d_gears();\n\n// Geometry Sources:\n//\thttp://www.cartertools.com/involute.html\n//\tgears.py (inkscape extension: /usr/share/inkscape/extensions/gears.py)\n// Usage:\n//\tDiametral pitch: Number of teeth per unit length.\n//\tCircular pitch: Length of the arc from one tooth to the next\n//\tClearance: Radial distance between top of tooth on one gear to bottom of gap on another.\n\nmodule gear(number_of_teeth,\n\t\tcircular_pitch=false, diametral_pitch=false,\n\t\tpressure_angle=20, clearance = 0)\n{\n\tif (circular_pitch==false && diametral_pitch==false) echo(\"MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch\");\n\n\t//Convert diametrial pitch to our native circular pitch\n\tcircular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch);\n\n\t// Pitch diameter: Diameter of pitch circle.\n\tpitch_diameter  =  number_of_teeth * circular_pitch / 180;\n\tpitch_radius = pitch_diameter/2;\n\n\t// Base Circle\n\tbase_diameter = pitch_diameter*cos(pressure_angle);\n\tbase_radius = base_diameter/2;\n\n\t// Diametrial pitch: Number of teeth per unit length.\n\tpitch_diametrial = number_of_teeth / pitch_diameter;\n\n\t// Addendum: Radial distance from pitch circle to outside circle.\n\taddendum = 1/pitch_diametrial;\n\n\t//Outer Circle\n\touter_radius = pitch_radius+addendum;\n\touter_diameter = outer_radius*2;\n\n\t// Dedendum: Radial distance from pitch circle to root diameter\n\tdedendum = addendum + clearance;\n\n\t// Root diameter: Diameter of bottom of tooth spaces.\n\troot_radius = pitch_radius-dedendum;\n\troot_diameter = root_radius * 2;\n\n\thalf_thick_angle = 360 / (4 * number_of_teeth);\n\n\tunion()\n\t{\n\t\trotate(half_thick_angle) circle($fn=number_of_teeth*2, r=root_radius*1.001);\n\n\t\tfor (i= [1:number_of_teeth])\n\t\t//for (i = [0])\n\t\t{\n\t\t\trotate([0,0,i*360/number_of_teeth])\n\t\t\t{\n\t\t\t\tinvolute_gear_tooth(\n\t\t\t\t\tpitch_radius = pitch_radius,\n\t\t\t\t\troot_radius = root_radius,\n\t\t\t\t\tbase_radius = base_radius,\n\t\t\t\t\touter_radius = outer_radius,\n\t\t\t\t\thalf_thick_angle = half_thick_angle);\n\t\t\t}\n\t\t}\n\t}\n}\n\n\nmodule involute_gear_tooth(\n\t\t\t\t\tpitch_radius,\n\t\t\t\t\troot_radius,\n\t\t\t\t\tbase_radius,\n\t\t\t\t\touter_radius,\n\t\t\t\t\thalf_thick_angle\n\t\t\t\t\t)\n{\n\tpitch_to_base_angle  = involute_intersect_angle( base_radius, pitch_radius );\n\n\touter_to_base_angle = involute_intersect_angle( base_radius, outer_radius );\n\n\tbase1 = 0 - pitch_to_base_angle - half_thick_angle;\n\tpitch1 = 0 - half_thick_angle;\n\touter1 = outer_to_base_angle - pitch_to_base_angle - half_thick_angle;\n\n\tb1 = polar_to_cartesian([ base1, base_radius ]);\n\tp1 = polar_to_cartesian([ pitch1, pitch_radius ]);\n\to1 = polar_to_cartesian([ outer1, outer_radius ]);\n\n\tb2 = polar_to_cartesian([ -base1, base_radius ]);\n\tp2 = polar_to_cartesian([ -pitch1, pitch_radius ]);\n\to2 = polar_to_cartesian([ -outer1, outer_radius ]);\n\n\t// ( root_radius > base_radius variables )\n\t\tpitch_to_root_angle = pitch_to_base_angle - involute_intersect_angle(base_radius, root_radius );\n\t\troot1 = pitch1 - pitch_to_root_angle;\n\t\troot2 = -pitch1 + pitch_to_root_angle;\n\t\tr1_t =  polar_to_cartesian([ root1, root_radius ]);\n\t\tr2_t =  polar_to_cartesian([ -root1, root_radius ]);\n\n\t// ( else )\n\t\tr1_f =  polar_to_cartesian([ base1, root_radius ]);\n\t\tr2_f =  polar_to_cartesian([ -base1, root_radius ]);\n\n\tif (root_radius > base_radius)\n\t{\n\t\t//echo(\"true\");\n\t\tpolygon( points = [\n\t\t\tr1_t,p1,o1,o2,p2,r2_t\n\t\t], convexity = 3);\n\t}\n\telse\n\t{\n\t\tpolygon( points = [\n\t\t\tr1_f, b1,p1,o1,o2,p2,b2,r2_f\n\t\t], convexity = 3);\n\t}\n\n}\n\n// Mathematical Functions\n//===============\n\n// Finds the angle of the involute about the base radius at the given distance (radius) from it's center.\n//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html\n\nfunction involute_intersect_angle(base_radius, radius) = sqrt( pow(radius/base_radius,2) - 1);\n\n\n\n// Polar coord [angle, radius] to cartesian coord [x,y]\n\nfunction polar_to_cartesian(polar) = [\n\tpolar[1]*cos(polar[0]),\n\tpolar[1]*sin(polar[0])\n];\n\n\n// Test Cases\n//===============\n\nmodule test_gears()\n{\n\tgear(number_of_teeth=51,circular_pitch=200);\n\ttranslate([0, 50])gear(number_of_teeth=17,circular_pitch=200);\n\ttranslate([-50,0]) gear(number_of_teeth=17,diametral_pitch=1);\n}\n\nmodule demo_3d_gears()\n{\n\t//double helical gear\n\t// (helics don't line up perfectly - for display purposes only ;)\n\ttranslate([50,0])\n\t{\n\tlinear_extrude(height = 10, center = true, convexity = 10, twist = -45)\n\t gear(number_of_teeth=17,diametral_pitch=1);\n\ttranslate([0,0,10]) linear_extrude(height = 10, center = true, convexity = 10, twist = 45)\n\t gear(number_of_teeth=17,diametral_pitch=1);\n\t}\n\n\t//spur gear\n\ttranslate([0,-50]) linear_extrude(height = 10, center = true, convexity = 10, twist = 0)\n\t gear(number_of_teeth=17,diametral_pitch=1);\n\n}\n\nmodule test_involute_curve()\n{\n\tfor (i=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])\n\t{\n\t\ttranslate(polar_to_cartesian([involute_intersect_angle( 0.1,i) , i ])) circle($fn=15, r=0.5);\n\t}\n}\n"
  },
  {
    "path": "get_submodules.py",
    "content": "#!/usr/bin/python\n\nimport os\n\nos.system(\"git submodule update --init\")\n"
  },
  {
    "path": "gridbeam.scad",
    "content": "/*********************************\n* OpenSCAD GridBeam Library      *\n* (c) Timothy Schmidt 2013       *\n* http://www.github.com/gridbeam *\n* License: LGPL 2.1 or later     *\n*********************************/\n\n/* Todo:\n - implement \"dxf\" mode\n - implement hole cutout pattern - interference based on hole size, compatible with two sizes above and below the currently set size.\n*/\n\n// zBeam(segments) - create a vertical gridbeam strut 'segments' long\n// xBeam(segments) - create a horizontal gridbeam strut along the X axis\n// yBeam(segments) - create a horizontal gridbeam strut along the Y axis\n// zBolt(segments) - create a bolt 'segments' in length\n// xBolt(segments)\n// yBolt(segments)\n// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam structures width and depth in 'segments', corners == 1 notches corners\n// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to underside of beams\n// backBoard(width, height, corners) - create a backing board suitable for use in gridbeam structures width and height in 'segments', corners == 1 notches corners\n// frontBoard(width, height, corners) - like backBoard, but aligns board to front side of beams\n// translateBeam([x, y, z]) - translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments'\n\n// To render the DXF file from the command line:\n// openscad -x connector.dxf -D'mode=\"dxf\"' connector.scad\nmode = \"model\";\n//mode = \"dxf\";\n\ninclude <units.scad>\n\nbeam_width = inch * 1.5;\nbeam_hole_diameter = inch * 5/16;\nbeam_hole_radius = beam_hole_diameter / 2;\nbeam_is_hollow = 1;\nbeam_wall_thickness = inch * 1/8;\nbeam_shelf_thickness = inch * 1/4;\n\nmodule zBeam(segments) {\nif (mode == \"model\") {\n\tdifference() {\n\t\tcube([beam_width, beam_width, beam_width * segments]);\n\t\tfor(i = [0 : segments - 1]) {\n\t\t\ttranslate([beam_width / 2, beam_width + 1, beam_width * i + beam_width / 2])\n\t\t\trotate([90,0,0])\n\t\t\tcylinder(r=beam_hole_radius, h=beam_width + 2);\n\n\t\t\ttranslate([-1, beam_width / 2, beam_width * i + beam_width / 2])\n\t\t\trotate([0,90,0])\n\t\t\tcylinder(r=beam_hole_radius, h=beam_width + 2);\n\t\t}\n\tif (beam_is_hollow == 1) {\n\t\ttranslate([beam_wall_thickness, beam_wall_thickness, -1])\n\t\tcube([beam_width - beam_wall_thickness * 2, beam_width - beam_wall_thickness * 2, beam_width * segments + 2]);\n\t}\n}\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule xBeam(segments) {\nif (mode == \"model\") {\n\ttranslate([0,0,beam_width])\n\trotate([0,90,0])\n\tzBeam(segments);\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule yBeam(segments) {\nif (mode == \"model\") {\n\ttranslate([0,0,beam_width])\n\trotate([-90,0,0])\n\tzBeam(segments);\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule zBolt(segments) {\nif (mode == \"model\") {\n\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule xBolt(segments) {\nif (mode == \"model\") {\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule yBolt(segments) {\nif (mode == \"model\") {\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule translateBeam(v) {\n\tfor (i = [0 : $children - 1]) {\n\t\ttranslate(v * beam_width) child(i);\n\t}\n}\n\nmodule topShelf(width, depth, corners) {\nif (mode == \"model\") {\n\tdifference() {\n\t\tcube([width * beam_width, depth * beam_width, beam_shelf_thickness]);\n\n\t\tif (corners == 1) {\n\t\ttranslate([-1,  -1,  -1])\n\t\tcube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]);\n\t\ttranslate([-1, (depth - 1) * beam_width, -1])\n\t\tcube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]);\n\t\ttranslate([(width - 1) * beam_width, -1, -1])\n\t\tcube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]);\n\t\ttranslate([(width - 1) * beam_width, (depth - 1) * beam_width, -1])\n\t\tcube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]);\n\t\t}\n\t}\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule bottomShelf(width, depth, corners) {\nif (mode == \"model\") {\n\ttranslate([0,0,-beam_shelf_thickness])\n\ttopShelf(width, depth, corners);\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule  backBoard(width, height, corners) {\nif (mode == \"model\") {\n\ttranslate([beam_width, 0, 0])\n\tdifference() {\n\t\tcube([beam_shelf_thickness, width * beam_width, height * beam_width]);\n\n\t\tif (corners == 1) {\n\t\ttranslate([-1,  -1,  -1])\n\t\tcube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]);\n\t\ttranslate([-1, -1, (height - 1) * beam_width])\n\t\tcube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]);\n\t\ttranslate([-1, (width - 1) * beam_width, -1])\n\t\tcube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]);\n\t\ttranslate([-1, (width - 1) * beam_width, (height - 1) * beam_width])\n\t\tcube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]);\n\t\t}\n\t}\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n\nmodule frontBoard(width, height, corners) {\nif (mode == \"model\") {\n\ttranslate([-beam_width - beam_shelf_thickness, 0, 0])\n\tbackBoard(width, height, corners);\n}\n\nif (mode == \"dxf\") {\n\n}\n}\n"
  },
  {
    "path": "hardware.scad",
    "content": "// License: LGPL 2.1\n\nrodsize = 6;\t//threaded/smooth rod diameter in mm\nxaxis = 182.5;\t//width of base in mm\nyaxis = 266.5;\t//length of base in mm\n\n\nscrewsize = 3;\t//bearing bore/screw diameter in mm\nbearingsize = 10;\t//outer diameter of bearings in mm\nbearingwidth = 4;\t//width of bearings in mm\n\n\nrodpitch = rodsize / 6;\nrodnutsize = 0.8 * rodsize;\nrodnutdiameter = 1.9 * rodsize;\nrodwashersize = 0.2 * rodsize;\nrodwasherdiameter = 2 * rodsize;\nscrewpitch = screwsize / 6;\nnutsize = 0.8 * screwsize;\nnutdiameter = 1.9 * screwsize;\nwashersize = 0.2 * screwsize;\nwasherdiameter = 2 * screwsize;\npartthick = 2 * rodsize;\nvertexrodspace = 2 * rodsize;\n\n\nc = [0.3, 0.3, 0.3];\nrodendoffset = rodnutsize + rodwashersize * 2 + partthick / 2;\nvertexoffset = vertexrodspace + rodendoffset;\n\n\nrenderrodthreads = false;\nrenderscrewthreads = false;\nfn = 36;\n\n\n\nmodule rod(length, threaded) if (threaded && renderrodthreads) {\n\tlinear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / rodpitch, $fn = fn)\n\t\ttranslate([rodsize * 0.1 / 2, 0, 0])\n\t\t\tcircle(r = rodsize * 0.9 / 2, $fn = fn);\n} else cylinder(h = length, r = rodsize / 2, center = true, $fn = fn);\n\n\nmodule screw(length, nutpos, washer, bearingpos = -1) union(){\n\ttranslate([0, 0, -length / 2]) if (renderscrewthreads) {\n\t\tlinear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / screwpitch, $fn = fn)\n\t\t\ttranslate([screwsize * 0.1 / 2, 0, 0])\n\t\t\t\tcircle(r = screwsize * 0.9 / 2, $fn = fn);\n\t} else cylinder(h = length, r = screwsize / 2, center = true, $fn = fn);\n\trender() difference() {\n\t\ttranslate([0, 0, screwsize / 2]) cylinder(h = screwsize, r = screwsize, center = true, $fn = fn);\n\t\ttranslate([0, 0, screwsize]) cylinder(h = screwsize, r = screwsize / 2, center = true, $fn = 6);\n\t}\n\tif (washer > 0 && nutpos > 0) {\n\t\twasher(nutpos);\n\t\tnut(nutpos + washersize);\n\t} else if (nutpos > 0) nut(nutpos);\n\tif (bearingpos >= 0) bearing(bearingpos);\n}\n\n\nmodule bearing(position) render() translate([0, 0, -position - bearingwidth / 2]) union() {\n\tdifference() {\n\t\tcylinder(h = bearingwidth, r = bearingsize / 2, center = true, $fn = fn);\n\t\tcylinder(h = bearingwidth * 2, r = bearingsize / 2 - 1, center = true, $fn = fn);\n\t}\n\tdifference() {\n\t\tcylinder(h = bearingwidth - 0.5, r = bearingsize / 2 - 0.5, center = true, $fn = fn);\n\t\tcylinder(h = bearingwidth * 2, r = screwsize / 2 + 0.5, center = true, $fn = fn);\n\t}\n\tdifference() {\n\t\tcylinder(h = bearingwidth, r = screwsize / 2 + 1, center = true, $fn = fn);\n\t\tcylinder(h = bearingwidth + 0.1, r = screwsize / 2, center = true, $fn = fn);\n\t}\n}\n\n\nmodule nut(position, washer) render() translate([0, 0, -position - nutsize / 2]) {\n\tintersection() {\n\t\tscale([1, 1, 0.5]) sphere(r = 1.05 * screwsize, center = true);\n\t\tdifference() {\n\t\t\tcylinder (h = nutsize, r = nutdiameter / 2, center = true, $fn = 6);\n\t\t\tcylinder(r = screwsize / 2, h = nutsize + 0.1, center = true, $fn = fn);\n\t\t}\n\t}\n\tif (washer > 0) washer(0);\n}\n\n\nmodule washer(position) render() translate ([0, 0, -position - washersize / 2]) difference() {\n\tcylinder(r = washerdiameter / 2, h = washersize, center = true, $fn = fn);\n\tcylinder(r = screwsize / 2, h = washersize + 0.1, center = true, $fn = fn);\n}\n\nmodule rodnut(position, washer) render() translate([0, 0, position]) {\n\tintersection() {\n\t\tscale([1, 1, 0.5]) sphere(r = 1.05 * rodsize, center = true);\n\t\tdifference() {\n\t\t\tcylinder (h = rodnutsize, r = rodnutdiameter / 2, center = true, $fn = 6);\n\t\t\trod(rodnutsize + 0.1);\n\t\t}\n\t}\n\tif (washer == 1 || washer == 4) rodwasher(((position > 0) ? -1 : 1) * (rodnutsize + rodwashersize) / 2);\n\tif (washer == 2 || washer == 4) rodwasher(((position > 0) ? 1 : -1) * (rodnutsize + rodwashersize) / 2);\n}\n\n\nmodule rodwasher(position) render() translate ([0, 0, position]) difference() {\n\tcylinder(r = rodwasherdiameter / 2, h = rodwashersize, center = true, $fn = fn);\n\trod(rodwashersize + 0.1);\n}\n\n\nrod(20);\ntranslate([rodsize * 2.5, 0, 0]) rod(20, true);\ntranslate([rodsize * 5, 0, 0]) screw(10, true);\ntranslate([rodsize * 7.5, 0, 0]) bearing();\ntranslate([rodsize * 10, 0, 0]) rodnut();\ntranslate([rodsize * 12.5, 0, 0]) rodwasher();\ntranslate([rodsize * 15, 0, 0]) nut();\ntranslate([rodsize * 17.5, 0, 0]) washer();"
  },
  {
    "path": "involute_gears.scad",
    "content": "// Parametric Involute Bevel and Spur Gears by GregFrost\n// It is licensed under the Creative Commons - GNU LGPL 2.1 license.\n// © 2010 by GregFrost, thingiverse.com/Amp\n// http://www.thingiverse.com/thing:3575 and http://www.thingiverse.com/thing:3752\n\n// Simple Test:\n//gear (circular_pitch=700,\n//\tgear_thickness = 12,\n//\trim_thickness = 15,\n//\thub_thickness = 17,\n//\tcircles=8);\n\n//Complex Spur Gear Test:\n//test_gears ();\n\n// Meshing Double Helix:\n//test_meshing_double_helix ();\n\nmodule test_meshing_double_helix(){\n    meshing_double_helix ();\n}\n\n// Demonstrate the backlash option for Spur gears.\n//test_backlash ();\n\n// Demonstrate how to make meshing bevel gears.\n//test_bevel_gear_pair();\n\nmodule test_bevel_gear_pair(){\n    bevel_gear_pair ();\n}\n\nmodule test_bevel_gear(){bevel_gear();}\n\n//bevel_gear();\n\npi=3.1415926535897932384626433832795;\n\n//==================================================\n// Bevel Gears:\n// Two gears with the same cone distance, circular pitch (measured at the cone distance)\n// and pressure angle will mesh.\n\nmodule bevel_gear_pair (\n\tgear1_teeth = 41,\n\tgear2_teeth = 7,\n\taxis_angle = 90,\n\toutside_circular_pitch=1000)\n{\n\toutside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360;\n\toutside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360;\n\tpitch_apex1=outside_pitch_radius2 * sin (axis_angle) +\n\t\t(outside_pitch_radius2 * cos (axis_angle) + outside_pitch_radius1) / tan (axis_angle);\n\tcone_distance = sqrt (pow (pitch_apex1, 2) + pow (outside_pitch_radius1, 2));\n\tpitch_apex2 = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius2, 2));\n\techo (\"cone_distance\", cone_distance);\n\tpitch_angle1 = asin (outside_pitch_radius1 / cone_distance);\n\tpitch_angle2 = asin (outside_pitch_radius2 / cone_distance);\n\techo (\"pitch_angle1, pitch_angle2\", pitch_angle1, pitch_angle2);\n\techo (\"pitch_angle1 + pitch_angle2\", pitch_angle1 + pitch_angle2);\n\n\trotate([0,0,90])\n\ttranslate ([0,0,pitch_apex1+20])\n\t{\n\t\ttranslate([0,0,-pitch_apex1])\n\t\tbevel_gear (\n\t\t\tnumber_of_teeth=gear1_teeth,\n\t\t\tcone_distance=cone_distance,\n\t\t\tpressure_angle=30,\n\t\t\toutside_circular_pitch=outside_circular_pitch);\n\n\t\trotate([0,-(pitch_angle1+pitch_angle2),0])\n\t\ttranslate([0,0,-pitch_apex2])\n\t\tbevel_gear (\n\t\t\tnumber_of_teeth=gear2_teeth,\n\t\t\tcone_distance=cone_distance,\n\t\t\tpressure_angle=30,\n\t\t\toutside_circular_pitch=outside_circular_pitch);\n\t}\n}\n\n//Bevel Gear Finishing Options:\nbevel_gear_flat = 0;\nbevel_gear_back_cone = 1;\n\nmodule bevel_gear (\n\tnumber_of_teeth=11,\n\tcone_distance=100,\n\tface_width=20,\n\toutside_circular_pitch=1000,\n\tpressure_angle=30,\n\tclearance = 0.2,\n\tbore_diameter=5,\n\tgear_thickness = 15,\n\tbacklash = 0,\n\tinvolute_facets=0,\n\tfinish = -1)\n{\n\techo (\"bevel_gear\",\n\t\t\"teeth\", number_of_teeth,\n\t\t\"cone distance\", cone_distance,\n\t\tface_width,\n\t\toutside_circular_pitch,\n\t\tpressure_angle,\n\t\tclearance,\n\t\tbore_diameter,\n\t\tinvolute_facets,\n\t\tfinish);\n\n\t// Pitch diameter: Diameter of pitch circle at the fat end of the gear.\n\toutside_pitch_diameter  =  number_of_teeth * outside_circular_pitch / 180;\n\toutside_pitch_radius = outside_pitch_diameter / 2;\n\n\t// The height of the pitch apex.\n\tpitch_apex = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius, 2));\n\tpitch_angle = asin (outside_pitch_radius/cone_distance);\n\n\techo (\"Num Teeth:\", number_of_teeth, \" Pitch Angle:\", pitch_angle);\n\n\tfinish = (finish != -1) ? finish : (pitch_angle < 45) ? bevel_gear_flat : bevel_gear_back_cone;\n\n\tapex_to_apex=cone_distance / cos (pitch_angle);\n\tback_cone_radius = apex_to_apex * sin (pitch_angle);\n\n\t// Calculate and display the pitch angle. This is needed to determine the angle to mount two meshing cone gears.\n\n\t// Base Circle for forming the involute teeth shape.\n\tbase_radius = back_cone_radius * cos (pressure_angle);\n\n\t// Diametrial pitch: Number of teeth per unit length.\n\tpitch_diametrial = number_of_teeth / outside_pitch_diameter;\n\n\t// Addendum: Radial distance from pitch circle to outside circle.\n\taddendum = 1 / pitch_diametrial;\n\t// Outer Circle\n\touter_radius = back_cone_radius + addendum;\n\n\t// Dedendum: Radial distance from pitch circle to root diameter\n\tdedendum = addendum + clearance;\n\tdedendum_angle = atan (dedendum / cone_distance);\n\troot_angle = pitch_angle - dedendum_angle;\n\n\troot_cone_full_radius = tan (root_angle)*apex_to_apex;\n\tback_cone_full_radius=apex_to_apex / tan (pitch_angle);\n\n\tback_cone_end_radius =\n\t\toutside_pitch_radius -\n\t\tdedendum * cos (pitch_angle) -\n\t\tgear_thickness / tan (pitch_angle);\n\tback_cone_descent = dedendum * sin (pitch_angle) + gear_thickness;\n\n\t// Root diameter: Diameter of bottom of tooth spaces.\n\troot_radius = back_cone_radius - dedendum;\n\n\thalf_tooth_thickness = outside_pitch_radius * sin (360 / (4 * number_of_teeth)) - backlash / 4;\n\thalf_thick_angle = asin (half_tooth_thickness / back_cone_radius);\n\n\tface_cone_height = apex_to_apex-face_width / cos (pitch_angle);\n\tface_cone_full_radius = face_cone_height / tan (pitch_angle);\n\tface_cone_descent = dedendum * sin (pitch_angle);\n\tface_cone_end_radius =\n\t\toutside_pitch_radius -\n\t\tface_width / sin (pitch_angle) -\n\t\tface_cone_descent / tan (pitch_angle);\n\n\t// For the bevel_gear_flat finish option, calculate the height of a cube to select the portion of the gear that includes the full pitch face.\n\tbevel_gear_flat_height = pitch_apex - (cone_distance - face_width) * cos (pitch_angle);\n\n//\ttranslate([0,0,-pitch_apex])\n\tdifference ()\n\t{\n\t\tintersection ()\n\t\t{\n\t\t\tunion()\n\t\t\t{\n\t\t\t\trotate (half_thick_angle)\n\t\t\t\ttranslate ([0,0,pitch_apex-apex_to_apex])\n\t\t\t\tcylinder ($fn=number_of_teeth*2, r1=root_cone_full_radius,r2=0,h=apex_to_apex);\n\t\t\t\tfor (i = [1:number_of_teeth])\n//\t\t\t\tfor (i = [1:1])\n\t\t\t\t{\n\t\t\t\t\trotate ([0,0,i*360/number_of_teeth])\n\t\t\t\t\t{\n\t\t\t\t\t\tinvolute_bevel_gear_tooth (\n\t\t\t\t\t\t\tback_cone_radius = back_cone_radius,\n\t\t\t\t\t\t\troot_radius = root_radius,\n\t\t\t\t\t\t\tbase_radius = base_radius,\n\t\t\t\t\t\t\touter_radius = outer_radius,\n\t\t\t\t\t\t\tpitch_apex = pitch_apex,\n\t\t\t\t\t\t\tcone_distance = cone_distance,\n\t\t\t\t\t\t\thalf_thick_angle = half_thick_angle,\n\t\t\t\t\t\t\tinvolute_facets = involute_facets);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (finish == bevel_gear_back_cone)\n\t\t\t{\n\t\t\t\ttranslate ([0,0,-back_cone_descent])\n\t\t\t\tcylinder (\n\t\t\t\t\t$fn=number_of_teeth*2,\n\t\t\t\t\tr1=back_cone_end_radius,\n\t\t\t\t\tr2=back_cone_full_radius*2,\n\t\t\t\t\th=apex_to_apex + back_cone_descent);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttranslate ([-1.5*outside_pitch_radius,-1.5*outside_pitch_radius,0])\n\t\t\t\tcube ([3*outside_pitch_radius,\n\t\t\t\t\t3*outside_pitch_radius,\n\t\t\t\t\tbevel_gear_flat_height]);\n\t\t\t}\n\t\t}\n\n\t\tif (finish == bevel_gear_back_cone)\n\t\t{\n\t\t\ttranslate ([0,0,-face_cone_descent])\n\t\t\tcylinder (\n\t\t\t\tr1=face_cone_end_radius,\n\t\t\t\tr2=face_cone_full_radius * 2,\n\t\t\t\th=face_cone_height + face_cone_descent+pitch_apex);\n\t\t}\n\n\t\ttranslate ([0,0,pitch_apex - apex_to_apex])\n\t\tcylinder (r=bore_diameter/2,h=apex_to_apex);\n\t}\n}\n\nmodule involute_bevel_gear_tooth (\n\tback_cone_radius,\n\troot_radius,\n\tbase_radius,\n\touter_radius,\n\tpitch_apex,\n\tcone_distance,\n\thalf_thick_angle,\n\tinvolute_facets)\n{\n//\techo (\"involute_bevel_gear_tooth\",\n//\t\tback_cone_radius,\n//\t\troot_radius,\n//\t\tbase_radius,\n//\t\touter_radius,\n//\t\tpitch_apex,\n//\t\tcone_distance,\n//\t\thalf_thick_angle);\n\n\tmin_radius = max (base_radius*2,root_radius*2);\n\n\tpitch_point =\n\t\tinvolute (\n\t\t\tbase_radius*2,\n\t\t\tinvolute_intersect_angle (base_radius*2, back_cone_radius*2));\n\tpitch_angle = atan2 (pitch_point[1], pitch_point[0]);\n\tcentre_angle = pitch_angle + half_thick_angle;\n\n\tstart_angle = involute_intersect_angle (base_radius*2, min_radius);\n\tstop_angle = involute_intersect_angle (base_radius*2, outer_radius*2);\n\n\tres=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4;\n\n\ttranslate ([0,0,pitch_apex])\n\trotate ([0,-atan(back_cone_radius/cone_distance),0])\n\ttranslate ([-back_cone_radius*2,0,-cone_distance*2])\n\tunion ()\n\t{\n\t\tfor (i=[1:res])\n\t\t{\n\t\t\tassign (\n\t\t\t\tpoint1=\n\t\t\t\t\tinvolute (base_radius*2,start_angle+(stop_angle - start_angle)*(i-1)/res),\n\t\t\t\tpoint2=\n\t\t\t\t\tinvolute (base_radius*2,start_angle+(stop_angle - start_angle)*(i)/res))\n\t\t\t{\n\t\t\t\tassign (\n\t\t\t\t\tside1_point1 = rotate_point (centre_angle, point1),\n\t\t\t\t\tside1_point2 = rotate_point (centre_angle, point2),\n\t\t\t\t\tside2_point1 = mirror_point (rotate_point (centre_angle, point1)),\n\t\t\t\t\tside2_point2 = mirror_point (rotate_point (centre_angle, point2)))\n\t\t\t\t{\n\t\t\t\t\tpolyhedron (\n\t\t\t\t\t\tpoints=[\n\t\t\t\t\t\t\t[back_cone_radius*2+0.1,0,cone_distance*2],\n\t\t\t\t\t\t\t[side1_point1[0],side1_point1[1],0],\n\t\t\t\t\t\t\t[side1_point2[0],side1_point2[1],0],\n\t\t\t\t\t\t\t[side2_point2[0],side2_point2[1],0],\n\t\t\t\t\t\t\t[side2_point1[0],side2_point1[1],0],\n\t\t\t\t\t\t\t[0.1,0,0]],\n\t\t\t\t\t\ttriangles=[[0,2,1],[0,3,2],[0,4,3],[0,1,5],[1,2,5],[2,3,5],[3,4,5],[0,5,4]]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nmodule gear (\n\tnumber_of_teeth=15,\n\tcircular_pitch=false, diametral_pitch=false,\n\tpressure_angle=28,\n\tclearance = 0.2,\n\tgear_thickness=5,\n\trim_thickness=8,\n\trim_width=5,\n\thub_thickness=10,\n\thub_diameter=15,\n\tbore_diameter=5,\n\tcircles=0,\n\tbacklash=0,\n\ttwist=0,\n\tinvolute_facets=0,\n\tflat=false)\n{\n\tif (circular_pitch==false && diametral_pitch==false)\n\t\techo(\"MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch\");\n\n\t//Convert diametrial pitch to our native circular pitch\n\tcircular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch);\n\n\t// Pitch diameter: Diameter of pitch circle.\n\tpitch_diameter  =  number_of_teeth * circular_pitch / 180;\n\tpitch_radius = pitch_diameter/2;\n\techo (\"Teeth:\", number_of_teeth, \" Pitch radius:\", pitch_radius);\n\n\t// Base Circle\n\tbase_radius = pitch_radius*cos(pressure_angle);\n\n\t// Diametrial pitch: Number of teeth per unit length.\n\tpitch_diametrial = number_of_teeth / pitch_diameter;\n\n\t// Addendum: Radial distance from pitch circle to outside circle.\n\taddendum = 1/pitch_diametrial;\n\n\t//Outer Circle\n\touter_radius = pitch_radius+addendum;\n\n\t// Dedendum: Radial distance from pitch circle to root diameter\n\tdedendum = addendum + clearance;\n\n\t// Root diameter: Diameter of bottom of tooth spaces.\n\troot_radius = pitch_radius-dedendum;\n\tbacklash_angle = backlash / pitch_radius * 180 / pi;\n\thalf_thick_angle = (360 / number_of_teeth - backlash_angle) / 4;\n\n\t// Variables controlling the rim.\n\trim_radius = root_radius - rim_width;\n\n\t// Variables controlling the circular holes in the gear.\n\tcircle_orbit_diameter=hub_diameter/2+rim_radius;\n\tcircle_orbit_curcumference=pi*circle_orbit_diameter;\n\n\t// Limit the circle size to 90% of the gear face.\n\tcircle_diameter=\n\t\tmin (\n\t\t\t0.70*circle_orbit_curcumference/circles,\n\t\t\t(rim_radius-hub_diameter/2)*0.9);\n\n\tdifference()\n\t{\n\t\tunion ()\n\t\t{\n\t\t\tdifference ()\n\t\t\t{\n\t\t\t\tlinear_extrude_flat_option(flat=flat, height=rim_thickness, convexity=10, twist=twist)\n\t\t\t\tgear_shape (\n\t\t\t\t\tnumber_of_teeth,\n\t\t\t\t\tpitch_radius = pitch_radius,\n\t\t\t\t\troot_radius = root_radius,\n\t\t\t\t\tbase_radius = base_radius,\n\t\t\t\t\touter_radius = outer_radius,\n\t\t\t\t\thalf_thick_angle = half_thick_angle,\n\t\t\t\t\tinvolute_facets=involute_facets);\n\n\t\t\t\tif (gear_thickness < rim_thickness)\n\t\t\t\t\ttranslate ([0,0,gear_thickness])\n\t\t\t\t\tcylinder (r=rim_radius,h=rim_thickness-gear_thickness+1);\n\t\t\t}\n\t\t\tif (gear_thickness > rim_thickness)\n\t\t\t\tlinear_extrude_flat_option(flat=flat, height=gear_thickness)\n\t\t\t\tcircle (r=rim_radius);\n\t\t\tif (flat == false && hub_thickness > gear_thickness)\n\t\t\t\ttranslate ([0,0,gear_thickness])\n\t\t\t\tlinear_extrude_flat_option(flat=flat, height=hub_thickness-gear_thickness)\n\t\t\t\tcircle (r=hub_diameter/2);\n\t\t}\n\t\ttranslate ([0,0,-1])\n\t\tlinear_extrude_flat_option(flat =flat, height=2+max(rim_thickness,hub_thickness,gear_thickness))\n\t\tcircle (r=bore_diameter/2);\n\t\tif (circles>0)\n\t\t{\n\t\t\tfor(i=[0:circles-1])\n\t\t\t\trotate([0,0,i*360/circles])\n\t\t\t\ttranslate([circle_orbit_diameter/2,0,-1])\n\t\t\t\tlinear_extrude_flat_option(flat =flat, height=max(gear_thickness,rim_thickness)+3)\n\t\t\t\tcircle(r=circle_diameter/2);\n\t\t}\n\t}\n}\n\nmodule linear_extrude_flat_option(flat =false, height = 10, center = false, convexity = 2, twist = 0)\n{\n\tif(flat==false)\n\t{\n\t\tlinear_extrude(height = height, center = center, convexity = convexity, twist= twist) child(0);\n\t}\n\telse\n\t{\n\t\tchild(0);\n\t}\n\n}\n\nmodule gear_shape (\n\tnumber_of_teeth,\n\tpitch_radius,\n\troot_radius,\n\tbase_radius,\n\touter_radius,\n\thalf_thick_angle,\n\tinvolute_facets)\n{\n\tunion()\n\t{\n\t\trotate (half_thick_angle) circle ($fn=number_of_teeth*2, r=root_radius);\n\n\t\tfor (i = [1:number_of_teeth])\n\t\t{\n\t\t\trotate ([0,0,i*360/number_of_teeth])\n\t\t\t{\n\t\t\t\tinvolute_gear_tooth (\n\t\t\t\t\tpitch_radius = pitch_radius,\n\t\t\t\t\troot_radius = root_radius,\n\t\t\t\t\tbase_radius = base_radius,\n\t\t\t\t\touter_radius = outer_radius,\n\t\t\t\t\thalf_thick_angle = half_thick_angle,\n\t\t\t\t\tinvolute_facets=involute_facets);\n\t\t\t}\n\t\t}\n\t}\n}\n\nmodule involute_gear_tooth (\n\tpitch_radius,\n\troot_radius,\n\tbase_radius,\n\touter_radius,\n\thalf_thick_angle,\n\tinvolute_facets)\n{\n\tmin_radius = max (base_radius,root_radius);\n\n\tpitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius));\n\tpitch_angle = atan2 (pitch_point[1], pitch_point[0]);\n\tcentre_angle = pitch_angle + half_thick_angle;\n\n\tstart_angle = involute_intersect_angle (base_radius, min_radius);\n\tstop_angle = involute_intersect_angle (base_radius, outer_radius);\n\n\tres=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4;\n\n\tunion ()\n\t{\n\t\tfor (i=[1:res])\n\t\tassign (\n\t\t\tpoint1=involute (base_radius,start_angle+(stop_angle - start_angle)*(i-1)/res),\n\t\t\tpoint2=involute (base_radius,start_angle+(stop_angle - start_angle)*i/res))\n\t\t{\n\t\t\tassign (\n\t\t\t\tside1_point1=rotate_point (centre_angle, point1),\n\t\t\t\tside1_point2=rotate_point (centre_angle, point2),\n\t\t\t\tside2_point1=mirror_point (rotate_point (centre_angle, point1)),\n\t\t\t\tside2_point2=mirror_point (rotate_point (centre_angle, point2)))\n\t\t\t{\n\t\t\t\tpolygon (\n\t\t\t\t\tpoints=[[0,0],side1_point1,side1_point2,side2_point2,side2_point1],\n\t\t\t\t\tpaths=[[0,1,2,3,4,0]]);\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Mathematical Functions\n//===============\n\n// Finds the angle of the involute about the base radius at the given distance (radius) from it's center.\n//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html\n\nfunction involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / pi;\n\n// Calculate the involute position for a given base radius and involute angle.\n\nfunction rotated_involute (rotate, base_radius, involute_angle) =\n[\n\tcos (rotate) * involute (base_radius, involute_angle)[0] + sin (rotate) * involute (base_radius, involute_angle)[1],\n\tcos (rotate) * involute (base_radius, involute_angle)[1] - sin (rotate) * involute (base_radius, involute_angle)[0]\n];\n\nfunction mirror_point (coord) =\n[\n\tcoord[0],\n\t-coord[1]\n];\n\nfunction rotate_point (rotate, coord) =\n[\n\tcos (rotate) * coord[0] + sin (rotate) * coord[1],\n\tcos (rotate) * coord[1] - sin (rotate) * coord[0]\n];\n\nfunction involute (base_radius, involute_angle) =\n[\n\tbase_radius*(cos (involute_angle) + involute_angle*pi/180*sin (involute_angle)),\n\tbase_radius*(sin (involute_angle) - involute_angle*pi/180*cos (involute_angle))\n];\n\n\n// Test Cases\n//===============\n\nmodule test_gears()\n{\n\ttranslate([17,-15])\n\t{\n\t\tgear (number_of_teeth=17,\n\t\t\tcircular_pitch=500,\n\t\t\tcircles=8);\n\n\t\trotate ([0,0,360*4/17])\n\t\ttranslate ([39.088888,0,0])\n\t\t{\n\t\t\tgear (number_of_teeth=11,\n\t\t\t\tcircular_pitch=500,\n\t\t\t\thub_diameter=0,\n\t\t\t\trim_width=65);\n\t\t\ttranslate ([0,0,8])\n\t\t\t{\n\t\t\t\tgear (number_of_teeth=6,\n\t\t\t\t\tcircular_pitch=300,\n\t\t\t\t\thub_diameter=0,\n\t\t\t\t\trim_width=5,\n\t\t\t\t\trim_thickness=6,\n\t\t\t\t\tpressure_angle=31);\n\t\t\t\trotate ([0,0,360*5/6])\n\t\t\t\ttranslate ([22.5,0,1])\n\t\t\t\tgear (number_of_teeth=21,\n\t\t\t\t\tcircular_pitch=300,\n\t\t\t\t\tbore_diameter=2,\n\t\t\t\t\thub_diameter=4,\n\t\t\t\t\trim_width=1,\n\t\t\t\t\thub_thickness=4,\n\t\t\t\t\trim_thickness=4,\n\t\t\t\t\tgear_thickness=3,\n\t\t\t\t\tpressure_angle=31);\n\t\t\t}\n\t\t}\n\n\t\ttranslate ([-61.1111111,0,0])\n\t\t{\n\t\t\tgear (number_of_teeth=27,\n\t\t\t\tcircular_pitch=500,\n\t\t\t\tcircles=5,\n\t\t\t\thub_diameter=2*8.88888889);\n\n\t\t\ttranslate ([0,0,10])\n\t\t\t{\n\t\t\t\tgear (\n\t\t\t\t\tnumber_of_teeth=14,\n\t\t\t\t\tcircular_pitch=200,\n\t\t\t\t\tpressure_angle=5,\n\t\t\t\t\tclearance = 0.2,\n\t\t\t\t\tgear_thickness = 10,\n\t\t\t\t\trim_thickness = 10,\n\t\t\t\t\trim_width = 15,\n\t\t\t\t\tbore_diameter=5,\n\t\t\t\t\tcircles=0);\n\t\t\t\ttranslate ([13.8888888,0,1])\n\t\t\t\tgear (\n\t\t\t\t\tnumber_of_teeth=11,\n\t\t\t\t\tcircular_pitch=200,\n\t\t\t\t\tpressure_angle=5,\n\t\t\t\t\tclearance = 0.2,\n\t\t\t\t\tgear_thickness = 10,\n\t\t\t\t\trim_thickness = 10,\n\t\t\t\t\trim_width = 15,\n\t\t\t\t\thub_thickness = 20,\n\t\t\t\t\thub_diameter=2*7.222222,\n\t\t\t\t\tbore_diameter=5,\n\t\t\t\t\tcircles=0);\n\t\t\t}\n\t\t}\n\n\t\trotate ([0,0,360*-5/17])\n\t\ttranslate ([44.444444444,0,0])\n\t\tgear (number_of_teeth=15,\n\t\t\tcircular_pitch=500,\n\t\t\thub_diameter=10,\n\t\t\trim_width=5,\n\t\t\trim_thickness=5,\n\t\t\tgear_thickness=4,\n\t\t\thub_thickness=6,\n\t\t\tcircles=9);\n\n\t\trotate ([0,0,360*-1/17])\n\t\ttranslate ([30.5555555,0,-1])\n\t\tgear (number_of_teeth=5,\n\t\t\tcircular_pitch=500,\n\t\t\thub_diameter=0,\n\t\t\trim_width=5,\n\t\t\trim_thickness=10);\n\t}\n}\n\nmodule meshing_double_helix ()\n{\n\ttest_double_helix_gear ();\n\n\tmirror ([0,1,0])\n\ttranslate ([58.33333333,0,0])\n\ttest_double_helix_gear (teeth=13,circles=6);\n}\n\nmodule test_double_helix_gear (\n\tteeth=17,\n\tcircles=8)\n{\n\t//double helical gear\n\t{\n\t\ttwist=200;\n\t\theight=20;\n\t\tpressure_angle=30;\n\n\t\tgear (number_of_teeth=teeth,\n\t\t\tcircular_pitch=700,\n\t\t\tpressure_angle=pressure_angle,\n\t\t\tclearance = 0.2,\n\t\t\tgear_thickness = height/2*0.5,\n\t\t\trim_thickness = height/2,\n\t\t\trim_width = 5,\n\t\t\thub_thickness = height/2*1.2,\n\t\t\thub_diameter=15,\n\t\t\tbore_diameter=5,\n\t\t\tcircles=circles,\n\t\t\ttwist=twist/teeth);\n\t\tmirror([0,0,1])\n\t\tgear (number_of_teeth=teeth,\n\t\t\tcircular_pitch=700,\n\t\t\tpressure_angle=pressure_angle,\n\t\t\tclearance = 0.2,\n\t\t\tgear_thickness = height/2,\n\t\t\trim_thickness = height/2,\n\t\t\trim_width = 5,\n\t\t\thub_thickness = height/2,\n\t\t\thub_diameter=15,\n\t\t\tbore_diameter=5,\n\t\t\tcircles=circles,\n\t\t\ttwist=twist/teeth);\n\t}\n}\n\nmodule test_backlash ()\n{\n\tbacklash = 2;\n\tteeth = 15;\n\n\ttranslate ([-29.166666,0,0])\n\t{\n\t\ttranslate ([58.3333333,0,0])\n\t\trotate ([0,0,-360/teeth/4])\n\t\tgear (\n\t\t\tnumber_of_teeth = teeth,\n\t\t\tcircular_pitch=700,\n\t\t\tgear_thickness = 12,\n\t\t\trim_thickness = 15,\n\t\t\trim_width = 5,\n\t\t\thub_thickness = 17,\n\t\t\thub_diameter=15,\n\t\t\tbore_diameter=5,\n\t\t\tbacklash = 2,\n\t\t\tcircles=8);\n\n\t\trotate ([0,0,360/teeth/4])\n\t\tgear (\n\t\t\tnumber_of_teeth = teeth,\n\t\t\tcircular_pitch=700,\n\t\t\tgear_thickness = 12,\n\t\t\trim_thickness = 15,\n\t\t\trim_width = 5,\n\t\t\thub_thickness = 17,\n\t\t\thub_diameter=15,\n\t\t\tbore_diameter=5,\n\t\t\tbacklash = 2,\n\t\t\tcircles=8);\n\t}\n\n\tcolor([0,0,128,0.5])\n\ttranslate([0,0,-5])\n\tcylinder ($fn=20,r=backlash / 4,h=25);\n}\n\n"
  },
  {
    "path": "layouts.scad",
    "content": "  /*\n *  OpenSCAD Layout Library (www.openscad.org)\n *  Copyright (C) 2012 Peter Uithoven\n *\n *  License: LGPL 2.1 or later\n*/\n\n//list(iHeight);\n//grid(iWidth,iHeight,inYDir = true,limit=3)\n\n// Examples:\n/*list(15)\n{\n\tsquare([25,10]);\n\tsquare([25,10]);\n    square([25,10]);\n\tsquare([25,10]);\n    square([25,10]);\n}*/\n/*grid(30,15,false,2)\n{\n\tsquare([25,10]);\n\tsquare([25,10]);\n    square([25,10]);\n\tsquare([25,10]);\n    square([25,10]);\n}*/\n\n//----------------------\n\nmodule list(iHeight)\n{\n\tfor (i = [0 : $children-1]) \n\t\ttranslate([0,i*iHeight]) child(i);\n}\nmodule grid(iWidth,iHeight,inYDir = true,limit=3)\n{\n\tfor (i = [0 : $children-1]) \n\t{\n\t\ttranslate([(inYDir)? (iWidth)*(i%limit) : (iWidth)*floor(i/limit),\n\t\t\t\t\t(inYDir)? (iHeight)*floor(i/limit) : (iHeight)*(i%limit)])\n\t\t\t\t\tchild(i);\n\t}\n}"
  },
  {
    "path": "lego_compatibility.scad",
    "content": "// This file is placed under the public domain\r\n\r\n// from: http://www.thingiverse.com/thing:9512\r\n\r\n\r\n// EXAMPLES:\r\n//   standard LEGO 2x1 tile has no pin\r\n//      block(1,2,1/3,reinforcement=false,flat_top=true);\r\n//   standard LEGO 2x1 flat has pin\r\n//      block(1,2,1/3,reinforcement=true);\r\n//   standard LEGO 2x1 brick has pin\r\n//      block(1,2,1,reinforcement=true);\r\n//   standard LEGO 2x1 brick without pin\r\n//      block(1,2,1,reinforcement=false);\r\n//   standard LEGO 2x1x5 brick has no pin and has hollow knobs\r\n//      block(1,2,5,reinforcement=false,hollow_knob=true);\r\n\r\n\r\nknob_diameter=4.8;\t\t//knobs on top of blocks\r\nknob_height=2;\r\nknob_spacing=8.0;\r\nwall_thickness=1.45;\r\nroof_thickness=1.05;\r\nblock_height=9.5;\r\npin_diameter=3;\t\t//pin for bottom blocks with width or length of 1\r\npost_diameter=6.5;\r\nreinforcing_width=1.5;\r\naxle_spline_width=2.0;\r\naxle_diameter=5;\r\ncylinder_precision=0.5;\r\n\r\n/* EXAMPLES:\r\n\r\nblock(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true);\r\n\r\ntranslate([50,-10,0])\r\n\tblock(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true);\r\n\r\ntranslate([10,0,0])\r\n\tblock(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true);\r\ntranslate([30,0,0])\r\n\tblock(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false);\r\ntranslate([50,0,0])\r\n\tblock(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false);\r\ntranslate([0,20,0])\r\n\tblock(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false);\r\ntranslate([20,20,0])\r\n\tblock(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false);\r\ntranslate([40,20,0])\r\n\tblock(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false);\r\ntranslate([0,-10,0])\r\n\tblock(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false);\r\ntranslate([0,-20,0])\r\n\tblock(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false);\r\ntranslate([0,-30,0])\r\n\tblock(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true);\r\n//*/\r\n\r\nmodule block(width,length,height,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false) {\r\n\toverall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2;\r\n\toverall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2;\r\n\tcenter= center==true ? 1 : 0;\r\n\ttranslate(center*[-overall_length/2, -overall_width/2, 0])\r\n\tunion() {\r\n\t\tdifference() {\r\n\t\t\tunion() {\r\n\t\t\t\t// body:\r\n\t\t\t\tcube([overall_length,overall_width,height*block_height]);\r\n\t\t\t\t// knobs:\r\n\t\t\t\tif (flat_top != true)\r\n\t\t\t\ttranslate([knob_diameter/2+wall_thickness,knob_diameter/2+wall_thickness,0]) \r\n\t\t\t\t\tfor (ycount=[0:width-1])\r\n\t\t\t\t\t\tfor (xcount=[0:length-1]) {\r\n\t\t\t\t\t\t\ttranslate([xcount*knob_spacing,ycount*knob_spacing,0])\r\n\t\t\t\t\t\t\t\tdifference() {\r\n\t\t\t\t\t\t\t\t\tcylinder(r=knob_diameter/2,h=block_height*height+knob_height,$fs=cylinder_precision);\r\n\t\t\t\t\t\t\t\t\tif (hollow_knob==true)\r\n\t\t\t\t\t\t\t\t\t\ttranslate([0,0,-roof_thickness])\r\n\t\t\t\t\t\t\t\t\t\t\tcylinder(r=pin_diameter/2,h=block_height*height+knob_height+2*roof_thickness,$fs=cylinder_precision);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// hollow bottom:\r\n\t\t\tif (solid_bottom == false)\r\n\t\t\t\ttranslate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]);\r\n\t\t\t// flat_top -> groove around bottom\r\n\t\t\tif (flat_top == true) {\r\n\t\t\t\ttranslate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2])\r\n\t\t\t\t\tcube([overall_length+wall_thickness,wall_thickness,wall_thickness]);\r\n\t\t\t\ttranslate([-wall_thickness/2,overall_width-wall_thickness/3,-wall_thickness/2])\r\n\t\t\t\t\tcube([overall_length+wall_thickness,wall_thickness,wall_thickness]);\r\n\t\r\n\t\t\t\ttranslate([-wall_thickness*2/3,-wall_thickness/2,-wall_thickness/2])\r\n\t\t\t\t\tcube([wall_thickness,overall_width+wall_thickness,wall_thickness]);\r\n\t\t\t\ttranslate([overall_length-wall_thickness/3,0,-wall_thickness/2])\r\n\t\t\t\t\tcube([wall_thickness,overall_width+wall_thickness,wall_thickness]);\r\n\t\t\t}\r\n\t\t\tif (axle_hole==true)\r\n\t\t\t\tif (width>1 && length>1) for (ycount=[1:width-1])\r\n\t\t\t\t\tfor (xcount=[1:length-1])\r\n\t\t\t\t\t\ttranslate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness])  axle(height);\r\n\t\t\tif (circular_hole==true)\r\n\t\t\t\tif (width>1 && length>1) for (ycount=[1:width-1])\r\n\t\t\t\t\tfor (xcount=[1:length-1])\r\n\t\t\t\t\t\ttranslate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness])\r\n\t\t\t\t\t\t\tcylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision);\r\n\t\t}\r\n\r\n\t\tif (reinforcement==true && width>1 && length>1)\r\n\t\t\tdifference() {\r\n\t\t\t\tfor (ycount=[1:width-1])\r\n\t\t\t\t\tfor (xcount=[1:length-1])\r\n\t\t\t\t\t\ttranslate([xcount*knob_spacing,ycount*knob_spacing,0]) reinforcement(height);\r\n\t\t\t\tfor (ycount=[1:width-1])\r\n\t\t\t\t\tfor (xcount=[1:length-1])\r\n\t\t\t\t\t\ttranslate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/2]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision);\r\n\t\t\t}\r\n\t\t// posts:\r\n\t\tif (solid_bottom == false)\r\n\t\t\tif (width>1 && length>1) for (ycount=[1:width-1])\r\n\t\t\t\tfor (xcount=[1:length-1])\r\n\t\t\t\t\ttranslate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height);\r\n\r\n\t\tif (reinforcement == true && width==1 && length!=1)\r\n\t\t\tfor (xcount=[1:length-1])\r\n\t\t\t\ttranslate([xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision);\r\n\r\n\t\tif (reinforcement == true && length==1 && width!=1)\r\n\t\t\tfor (ycount=[1:width-1])\r\n\t\t\t\ttranslate([overall_length/2,ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision);\r\n\t}\r\n}\r\n\r\nmodule post(height) {\r\n\tdifference() {\r\n\t\tcylinder(r=post_diameter/2, h=height*block_height-roof_thickness/2,$fs=cylinder_precision);\r\n\t\ttranslate([0,0,-roof_thickness/2])\r\n\t\t\tcylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision);\r\n\t}\r\n}\r\n\r\nmodule reinforcement(height) {\r\n\tunion() {\r\n\t\ttranslate([0,0,height*block_height/2]) union() {\r\n\t\t\tcube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height],center=true);\r\n\t\t\trotate(v=[0,0,1],a=90) cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height], center=true);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nmodule axle(height) {\r\n\ttranslate([0,0,height*block_height/2]) union() {\r\n\t\tcube([axle_diameter,axle_spline_width,height*block_height],center=true);\r\n\t\tcube([axle_spline_width,axle_diameter,height*block_height],center=true);\r\n\t}\r\n}\r\n\t\t\t\r\n"
  },
  {
    "path": "lgpl-2.1.txt",
    "content": "                  GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n[This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.]\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations below.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\f\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it becomes\na de-facto standard.  To achieve this, non-free programs must be\nallowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\f\n                  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control compilation\nand installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n\n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\f\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\f\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\f\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at\n    least three years, to give the same user the materials\n    specified in Subsection 6a, above, for a charge no more\n    than the cost of performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\f\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\f\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under any\nparticular circumstance, the balance of the section is intended to apply,\nand the section as a whole is intended to apply in other circumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License may add\nan explicit geographical distribution limitation excluding those countries,\nso that distribution is permitted only in or among countries not thus\nexcluded.  In such case, this License incorporates the limitation as if\nwritten in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\f\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n                            NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\f\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms of the\nordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.  It is\nsafest to attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least the\n\"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the library's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the library, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James Random Hacker.\n\n  <signature of Ty Coon>, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n"
  },
  {
    "path": "libtriangles.scad",
    "content": "//Copyright (C) 2013 Alex Davies\n//License: LGPL 2.1 or later\n//todo, make library work with negative lengths by adding triangles to the inside of every surface. basicaly copy and paste the current triangles set and reverse the first and last digit of every triangle. In 4 character traingles switcht the middle ones around as well. Not sure if that' actually useful though.\n\nmodule rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) {\n\tpolyhedron ( points = [[0,0,0], \n\t\t\t[rightpyramidx, 0, 0], \n\t\t\t[0, rightpyramidy, 0], \n\t\t\t[rightpyramidx, rightpyramidy, 0],\n\t\t\t[rightpyramidx/2, rightpyramidy, rightpyramidz]], \n\n\ttriangles = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]);\n\n}\n\nmodule cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) {\n\tpolyhedron ( points = [[0,0,0], \n\t\t\t[cornerpyramidx, 0, 0], \n\t\t\t[0, cornerpyramidy, 0], \n\t\t\t[cornerpyramidx, cornerpyramidy, 0],\n\t\t\t[0, cornerpyramidy, cornerpyramidz]], \n\n\ttriangles = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]);\n\n}\n\nmodule eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) {\n\tpolyhedron ( points = [[0,0,0], \n\t\t\t[eqlpyramidx, 0, 0], \n\t\t\t[0, eqlpyramidy, 0], \n\t\t\t[eqlpyramidx, eqlpyramidy, 0],\n\t\t\t[eqlpyramidx/2, eqlpyramidy/2, eqlpyramidz]], \n\n\ttriangles = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]);\n\n}\n\n\nmodule rightprism(rightprismx,rightprismy,rightprismz){\n\tpolyhedron ( points = [[0,0,0],\n\t\t\t[rightprismx,0,0],\n\t\t\t[rightprismx,rightprismy,0],\n\t\t\t[0,rightprismy,0],\n\t\t\t[0,rightprismy,rightprismz],\n\t\t\t[0,0,rightprismz]], \n\ttriangles = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]);\n}\n\n\n\nmodule eqlprism(rightprismx,rightprismy,rightprismz){\n\tpolyhedron ( points = [[0,0,0],\n\t\t\t[rightprismx,0,0],\n\t\t\t[rightprismx,rightprismy,0],\n\t\t\t[0,rightprismy,0],\n\t\t\t[rightprismx/2,rightprismy,rightprismz],\n\t\t\t[rightprismx/2,0,rightprismz]], \n\ttriangles = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]);\n}\n\n"
  },
  {
    "path": "linear_bearing.scad",
    "content": "//By Glen Chung, 2013.\n//Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later\n\ninclude <MCAD/units.scad>\ninclude <MCAD/materials.scad>\n\nLINEAR_BEARING_dr = 0;  //Inscribed circle\nLINEAR_BEARING_D  = 1;  //Outer diameter\nLINEAR_BEARING_L  = 2;  //Length\nLINEAR_BEARING_B  = 3;  //Outer locking groove B\nLINEAR_BEARING_D1 = 4;  //Outer locking groove D1\nLINEAR_BEARING_W  = 5;  //W\n\n\n// Common bearing names\nLinearBearing = \"LM8UU\";\n\n// Linear Bearing dimensions\n//  model == \"XXXXX\"   ?   [    dr,      D,      L,        B,      D1,       W]:\nfunction linearBearingDimensions(model) =\n    model == \"LM3UU\"   ?   [  3*mm,   7*mm,  10*mm,   0.0*mm,   0.0*mm, 0.00*mm]:\n    model == \"LM4UU\"   ?   [  4*mm,   8*mm,  12*mm,   0.0*mm,   0.0*mm, 0.00*mm]:\n    model == \"LM5UU\"   ?   [  5*mm,  10*mm,  15*mm,  10.2*mm,   9.6*mm, 1.10*mm]:\n    model == \"LM6UU\"   ?   [  6*mm,  12*mm,  19*mm,  13.5*mm,  11.5*mm, 1.10*mm]:\n    model == \"LM8SUU\"  ?   [  8*mm,  15*mm,  17*mm,  11.5*mm,  14.3*mm, 1.10*mm]:\n    model == \"LM10UU\"  ?   [ 10*mm,  19*mm,  29*mm,  22.0*mm,  18.0*mm, 1.30*mm]:\n    model == \"LM12UU\"  ?   [ 12*mm,  21*mm,  30*mm,  23.0*mm,  20.0*mm, 1.30*mm]:\n    model == \"LM13UU\"  ?   [ 13*mm,  23*mm,  32*mm,  23.0*mm,  22.0*mm, 1.30*mm]:\n    model == \"LM16UU\"  ?   [ 16*mm,  28*mm,  37*mm,  26.5*mm,  27.0*mm, 1.60*mm]:\n    model == \"LM20UU\"  ?   [ 20*mm,  32*mm,  42*mm,  30.5*mm,  30.5*mm, 1.60*mm]:\n    model == \"LM25UU\"  ?   [ 25*mm,  40*mm,  59*mm,  41.0*mm,  38.0*mm, 1.85*mm]:\n    model == \"LM30UU\"  ?   [ 30*mm,  45*mm,  64*mm,  44.5*mm,  43.0*mm, 1.85*mm]:\n    model == \"LM35UU\"  ?   [ 35*mm,  52*mm,  70*mm,  49.5*mm,  49.0*mm, 2.10*mm]:\n    model == \"LM40UU\"  ?   [ 40*mm,  60*mm,  80*mm,  60.5*mm,  57.0*mm, 2.10*mm]:\n    model == \"LM50UU\"  ?   [ 50*mm,  80*mm, 100*mm,  74.0*mm,  76.5*mm, 2.60*mm]:\n    model == \"LM60UU\"  ?   [ 60*mm,  90*mm, 110*mm,  85.0*mm,  86.5*mm, 3.15*mm]:\n    model == \"LM80UU\"  ?   [ 80*mm, 120*mm, 140*mm, 105.5*mm, 116.0*mm, 4.15*mm]:\n    model == \"LM100UU\" ?   [100*mm, 150*mm, 150*mm, 125.5*mm, 145.0*mm, 4.15*mm]:\n  /*model == \"LM8UU\"   ?*/ [  8*mm,  15*mm,  24*mm,  17.5*mm,  14.3*mm, 1.10*mm];\n\n\nfunction linearBearing_dr(model) = linearBearingDimensions(model)[LINEAR_BEARING_dr];\nfunction linearBearing_D(model)  = linearBearingDimensions(model)[LINEAR_BEARING_D];\nfunction linearBearing_L(model)  = linearBearingDimensions(model)[LINEAR_BEARING_L];\nfunction linearBearing_B(model)  = linearBearingDimensions(model)[LINEAR_BEARING_B];\nfunction linearBearing_D1(model) = linearBearingDimensions(model)[LINEAR_BEARING_D1];\nfunction linearBearing_W(model)  = linearBearingDimensions(model)[LINEAR_BEARING_W];\n\nmodule linearBearing(pos=[0,0,0], angle=[0,0,0], model=LinearBearing,\n                material=Steel, sideMaterial=BlackPaint) {\n  dr = linearBearing_dr(model);\n  D  = linearBearing_D(model);\n  L  = linearBearing_L(model);\n  B  = linearBearing_B(model);\n  D1 = linearBearing_D1(model);\n  W  = linearBearing_W(model);\n\n  innerRim = dr + (D - dr) * 0.2;\n  outerRim = D - (D - dr) * 0.2;\n  midSink = W/4;\n\n  translate(pos) rotate(angle) union() {\n    color(material)\n      difference() {\n        // Basic ring\n        Ring([0,0,0], D, dr, L, material, material);\n\n        if(W) {\n          // Side shields\n          Ring([0,0,-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material);\n          Ring([0,0,L-midSink-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material);\n          //Outer locking groove\n          Ring([0,0,(L-B)/2], D+epsilon, outerRim+W/2, W, material, material);\n          Ring([0,0,L-(L-B)/2], D+epsilon, outerRim+W/2, W, material, material);\n        }\n      }\n      if(W)\n        Ring([0,0,midSink], D-L*epsilon, dr+L*epsilon, L-midSink*2, sideMaterial, sideMaterial);\n  }\n\n  module Ring(pos, od, id, h, material, holeMaterial) {\n    color(material) {\n      translate(pos)\n        difference() {\n          cylinder(r=od/2, h=h,  $fn = 100);\n          color(holeMaterial)\n            translate([0,0,-10*epsilon])\n              cylinder(r=id/2, h=h+20*epsilon,  $fn = 100);\n        }\n    }\n  }\n\n}\n\n\n//examples\n//linearBearing(model=\"LM8UU\");\n//linearBearing(model=\"LM10UU\");\n"
  },
  {
    "path": "materials.scad",
    "content": "/*\n * Material colors.\n * \n * Originally by Hans Häggström, 2010.\n * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later\n */\n\n// Material colors\nOak = [0.65, 0.5, 0.4];\nPine = [0.85, 0.7, 0.45];\nBirch = [0.9, 0.8, 0.6];\nFiberBoard = [0.7, 0.67, 0.6];\nBlackPaint = [0.2, 0.2, 0.2];\nIron = [0.36, 0.33, 0.33];\nSteel = [0.65, 0.67, 0.72];\nStainless = [0.45, 0.43, 0.5];\nAluminum = [0.77, 0.77, 0.8];\nBrass = [0.88, 0.78, 0.5];\nTransparent = [1, 1, 1, 0.2];\n\n// Example, uncomment to view\n//color_demo();\n\nmodule color_demo(){\n    // Wood\n    colorTest(Oak, 0, 0);\n    colorTest(Pine, 1, 0);\n    colorTest(Birch, 2, 0);\n\n    // Metals\n    colorTest(Iron, 0, 1);\n    colorTest(Steel, 1, 1);\n    colorTest(Stainless, 2, 1);\n    colorTest(Aluminum, 3, 1);\n\n    // Mixboards\n    colorTest(FiberBoard, 0, 2);\n\n    // Paints\n    colorTest(BlackPaint, 0, 3);\n}\n\nmodule colorTest(col, row=0, c=0) {\n  color(col) translate([row * 30,c*30,0]) sphere(r=10);\n}\n"
  },
  {
    "path": "math.scad",
    "content": "// MIT license\n\ninclude <constants.scad>\n\nfunction deg(angle) = 360*angle/TAU;\n\n"
  },
  {
    "path": "metric_fastners.scad",
    "content": "/*\n *  OpenSCAD Metric Fastners Library (www.openscad.org)\n *  Copyright (C) 2010-2011  Giles Bathgate\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 3 of the License,\n *  LGPL version 2.1, or (at your option) any later version of the GPL.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program; if not, write to the Free Software\n *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n*/\n\n$fn=50;\napply_chamfer=true;\n\nmodule cap_bolt(dia,len)\n{\n\te=1.5*dia;\n\th1=1.25*dia;\n\tcylinder(r=dia/2,h=len);\n\ttranslate([0,0,-h1]) cylinder(r=e/2,h=h1);\n}\n\nmodule csk_bolt(dia,len)\n{\n\th1=0.6*dia;\n\th2=len-h1;\n\tcylinder(r=dia/2,h=h2);\n\tcylinder(r1=dia,r2=dia/2,h=h1);\n}\n\nmodule washer(dia)\n{\n\tt=0.1*dia;\n\tdifference()\n\t{\n\t\tcylinder(r=dia,h=t);\n\t\ttranslate([0,0,-t/2])cylinder(r=dia/2,h=t*2);\n\t}\n}\n\nmodule flat_nut(dia)\n{\n\tm=0.8*dia;\n\te=1.8*dia;\n\tc=0.2*dia;\n\tdifference()\n\t{\n\t\tcylinder(r=e/2,h=m,$fn=6);\n\t\ttranslate([0,0,-m/2])cylinder(r=dia/2,h=m*2);\n\t\tif(apply_chamfer)\n\t\t    translate([0,0,c])cylinder_chamfer(e/2,c);\n\t}\n}\n\nmodule bolt(dia,len)\n{\n\te=1.8*dia;\n\tk=0.7*dia;\n\tc=0.2*dia;\n\tdifference()\n\t{\n\t\tcylinder(r=e/2,h=k,$fn=6);\n\t\tif(apply_chamfer)\n\t\t    translate([0,0,c])cylinder_chamfer(e/2,c);\n\t}\n\n\tcylinder(r=dia/2,h=len);\n\n}\n\nmodule cylinder_chamfer(r1,r2)\n{\n\tt=r1-r2;\n\tp=r2*2;\n\trotate_extrude()\n\tdifference()\n\t{\n\t\ttranslate([t,-p])square([p,p]);\n\t\ttranslate([t,0])circle(r2);\n\t}\n}\n\nmodule chamfer(len,r)\n{\n\tp=r*2;\n\tlinear_extrude(height=len)\n\tdifference()\n\t{\n\t\tsquare([p,p]);\n\t\tcircle(r);\n\t}\n}\n\nunion()\n{\n//csk_bolt(3,14);\n//washer(3);\n//flat_nut(3);\n//bolt(4,14);\n//cylinder_chamfer(8,1);\n//chamfer(10,2);\n}\n"
  },
  {
    "path": "motors.scad",
    "content": "// Copyright 2010 D1plo1d\n\n// This library is dual licensed under the GPL 3.0 and the GNU Lesser General Public License as per http://creativecommons.org/licenses/LGPL/2.1/ .\n\ninclude <math.scad>\n\n\n//generates a motor mount for the specified nema standard #.\nmodule stepper_motor_mount(nema_standard,slide_distance=0, mochup=true, tolerance=0) {\n\t//dimensions from:\n\t// http://www.numberfactory.com/NEMA%20Motor%20Dimensions.htm\n\tif (nema_standard == 17)\n\t{\n\t\t_stepper_motor_mount(\n\t\t\tmotor_shaft_diameter = 0.1968*mm_per_inch,\n\t\t\tmotor_shaft_length = 0.945*mm_per_inch,\n\t\t\tpilot_diameter = 0.866*mm_per_inch,\n\t\t\tpilot_length = 0.80*mm_per_inch,\n\t\t\tmounting_bolt_circle = 1.725*mm_per_inch,\n\t\t\tbolt_hole_size = 3.5,\n\t\t\tbolt_hole_distance = 1.220*mm_per_inch,\n\t\t\tslide_distance = slide_distance,\n\t\t\tmochup = mochup,\n\t\t\ttolerance=tolerance);\n\t}\n\tif (nema_standard == 23)\n\t{\n\t\t_stepper_motor_mount(\n\t\t\tmotor_shaft_diameter = 0.250*mm_per_inch,\n\t\t\tmotor_shaft_length = 0.81*mm_per_inch,\n\t\t\tpilot_diameter = 1.500*mm_per_inch,\n\t\t\tpilot_length = 0.062*mm_per_inch,\n\t\t\tmounting_bolt_circle = 2.625*mm_per_inch,\n\t\t\tbolt_hole_size = 0.195*mm_per_inch,\n\t\t\tbolt_hole_distance = 1.856*mm_per_inch,\n\t\t\tslide_distance = slide_distance,\n\t\t\tmochup = mochup,\n\t\t\ttolerance=tolerance);\n\t}\n\t\n}\n\n\n//inner mehod for creating a stepper motor mount of any dimensions\nmodule _stepper_motor_mount(\n\tmotor_shaft_diameter,\n\tmotor_shaft_length,\n\tpilot_diameter,\n\tpilot_length,\n\tmounting_bolt_circle,\n\tbolt_hole_size,\n\tbolt_hole_distance,\n\tslide_distance = 0,\n\tmotor_length = 40, //arbitray - not standardized\n\tmochup,\n\ttolerance = 0\n)\n{\n\tunion()\n\t{\n\t// == centered mount points ==\n\t//mounting circle inset\n\ttranslate([0,slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance);\n\tsquare([pilot_diameter,slide_distance],center=true);\n\ttranslate([0,-slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance);\n\n\t//todo: motor shaft hole\n\t\n\t//mounting screw holes\n\tfor (x = [-1,1])\n\t{\n\t\tfor (y = [-1,1])\n\t\t{\n\t\t\ttranslate([x*bolt_hole_distance/2,y*bolt_hole_distance/2,0])\n\t\t\t{\n\t\t\t\ttranslate([0,slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance);\n\t\t\t\ttranslate([0,-slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance);\n\t\t\t\tsquare([bolt_hole_size+2*tolerance,slide_distance],center=true);\n\t\t\t}\n\t\t}\n\t}\n\t// == motor mock-up ==\n\t//motor box\n\tif (mochup == true)\n\t{\n\t\t%translate([0,0,-5]) cylinder(h = 5, r = pilot_diameter/2);\n\t\t%translate(v=[0,0,-motor_length/2])\n\t\t{\n\t\t\tcube(size=[bolt_hole_distance+bolt_hole_size+5,bolt_hole_distance+bolt_hole_size+5,motor_length], center = true);\n\t\t}\n\t\t//shaft\n\t\t%translate(v=[0,0,-(motor_length-motor_shaft_length-2)/2])\n\t\t{\n\t\t\t%cylinder(r=motor_shaft_diameter/2,h=motor_length+motor_shaft_length--1, center = true);\n\t\t}\n\t}\n\t}\n}\n"
  },
  {
    "path": "multiply.scad",
    "content": "/*\n * Multiplication along certain curves\n *\n * Copyright by Elmo Mäntynen, 2012.\n * Licenced under LGPL2 or later\n */\n\ninclude <units.scad>\n\nuse <utilities.scad>\n\n// TODO check that the axis parameter works as intended\n// Duplicate everything $no of times around an $axis, for $angle/360 rounds\nmodule spin(no, angle=360, axis=Z){\n    for (i = [1:no]){\n        rotate(normalized_axis(axis)*angle*no/i) union(){\n            for (i = [0 : $children-1]) child(i);\n        }\n    }\n}\n\n//Doesn't work currently\nmodule duplicate(axis=Z) spin(no=2, axis=axis) child(0);\n\nmodule linear_multiply(no, separation, axis=Z){\n    for (i = [0:no-1]){\n        translate(i*separation*axis) child(0);\n    }\n}\n"
  },
  {
    "path": "nuts_and_bolts.scad",
    "content": "// Copyright 2010 D1plo1d\n\n// This library is dual licensed under the GPL 3.0 and the GNU Lesser General Public License as per http://creativecommons.org/licenses/LGPL/2.1/ .\n\n//testNutsAndBolts();\n\nmodule SKIPtestNutsAndBolts()\n{\n\t$fn = 360;\n\ttranslate([0,15])nutHole(3, proj=2);\n\tboltHole(3, length= 30, proj=2);\n}\n\nMM = \"mm\";\nINCH = \"inch\"; //Not yet supported\n\n//Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm\nMETRIC_NUT_AC_WIDTHS =\n[\n\t-1, //0 index is not used but reduces computation\n\t-1,\n\t-1,\n\t6.40,//m3\n\t8.10,//m4\n\t9.20,//m5\n\t11.50,//m6\n\t-1,\n\t15.00,//m8\n\t-1,\n\t19.60,//m10\n\t-1,\n\t22.10,//m12\n\t-1,\n\t-1,\n\t-1,\n\t27.70,//m16\n\t-1,\n\t-1,\n\t-1,\n\t34.60,//m20\n\t-1,\n\t-1,\n\t-1,\n\t41.60,//m24\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t53.1,//m30\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t63.5//m36\n];\nMETRIC_NUT_THICKNESS =\n[\n\t-1, //0 index is not used but reduces computation\n\t-1,\n\t-1,\n\t2.40,//m3\n\t3.20,//m4\n\t4.00,//m5\n\t5.00,//m6\n\t-1,\n\t6.50,//m8\n\t-1,\n\t8.00,//m10\n\t-1,\n\t10.00,//m12\n\t-1,\n\t-1,\n\t-1,\n\t13.00,//m16\n\t-1,\n\t-1,\n\t-1,\n\t16.00//m20\n\t-1,\n\t-1,\n\t-1,\n\t19.00,//m24\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t24.00,//m30\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t29.00//m36\n];\n\nCOURSE_METRIC_BOLT_MAJOR_THREAD_DIAMETERS =\n[//based on max values\n\t-1, //0 index is not used but reduces computation\n\t-1,\n\t-1,\n\t2.98,//m3\n\t3.978,//m4\n\t4.976,//m5\n\t5.974,//m6\n\t-1,\n\t7.972,//m8\n\t-1,\n\t9.968,//m10\n\t-1,\n\t11.966,//m12\n\t-1,\n\t-1,\n\t-1,\n\t15.962,//m16\n\t-1,\n\t-1,\n\t-1,\n\t19.958,//m20\n\t-1,\n\t-1,\n\t-1,\n\t23.952,//m24\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t29.947,//m30\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t-1,\n\t35.940//m36\n];\n\nmodule nutHole(size, units=MM, tolerance = +0.0001, proj = -1)\n{\n\t//takes a metric screw/nut size and looksup nut dimensions\n\tradius = METRIC_NUT_AC_WIDTHS[size]/2+tolerance;\n\theight = METRIC_NUT_THICKNESS[size]+tolerance;\n\tif (proj == -1)\n\t{\n\t\tcylinder(r= radius, h=height, $fn = 6, center=[0,0]);\n\t}\n\tif (proj == 1)\n\t{\n\t\tcircle(r= radius, $fn = 6);\n\t}\n\tif (proj == 2)\n\t{\n\t\ttranslate([-radius/2, 0])\n\t\t\tsquare([radius*2, height]);\n\t}\n}\n\nmodule boltHole(size, units=MM, length, tolerance = +0.0001, proj = -1)\n{\n\tradius = COURSE_METRIC_BOLT_MAJOR_THREAD_DIAMETERS[size]/2+tolerance;\n//TODO: proper screw cap values\n\tcapHeight = METRIC_NUT_THICKNESS[size]+tolerance; //METRIC_BOLT_CAP_HEIGHTS[size]+tolerance;\n\tcapRadius = METRIC_NUT_AC_WIDTHS[size]/2+tolerance; //METRIC_BOLT_CAP_RADIUS[size]+tolerance;\n\n\tif (proj == -1)\n\t{\n\ttranslate([0, 0, -capHeight])\n\t\tcylinder(r= capRadius, h=capHeight);\n\tcylinder(r = radius, h = length);\n\t}\n\tif (proj == 1)\n\t{\n\t\tcircle(r = radius);\n\t}\n\tif (proj == 2)\n\t{\n\t\ttranslate([-capRadius/2, -capHeight])\n\t\t\tsquare([capRadius*2, capHeight]);\n\t\tsquare([radius*2, length]);\n\t}\n}\n"
  },
  {
    "path": "openscad_testing.py",
    "content": "import py\nimport os.path\nfrom openscad_utils import *\n\n\ntemppath = py.test.ensuretemp('MCAD')\n\ndef pytest_generate_tests(metafunc):\n    if \"modpath\" in metafunc.funcargnames:\n        for fpath, modnames in collect_test_modules().items():\n            basename = os.path.splitext(os.path.split(str(fpath))[1])[0]\n            #os.system(\"cp %s %s/\" % (fpath, temppath))\n            if \"modname\" in metafunc.funcargnames:\n                for modname in modnames:\n                    print modname\n                    metafunc.addcall(id=basename+\"/\"+modname, funcargs=dict(modname=modname, modpath=fpath))\n            else:\n                metafunc.addcall(id=os.path.split(str(fpath))[1], funcargs=dict(modpath=fpath))\n\n\ndef test_module_compile(modname, modpath):\n    tempname = modpath.basename + '-' + modname + '.scad'\n    fpath = temppath.join(tempname)\n    stlpath = temppath.join(tempname + \".stl\")\n    f = fpath.open('w')\n    code = \"\"\"\n//generated testfile\nuse <%s>\n\n%s();\n\"\"\" % (modpath, modname)\n    print code\n    f.write(code)\n    f.flush()\n    output = call_openscad(path=fpath, stlpath=stlpath, timeout=15)\n    print output\n    assert output[0] is 0\n    for s in (\"warning\", \"error\"):\n        assert s not in output[2].strip().lower()\n    assert len(stlpath.readlines()) > 2\n\ndef test_file_compile(modpath):\n    stlpath = temppath.join(modpath.basename + \"-test.stl\")\n    output = call_openscad(path=modpath, stlpath=stlpath)\n    print output\n    assert output[0] is 0\n    for s in (\"warning\", \"error\"):\n        assert s not in output[2].strip().lower()\n    assert len(stlpath.readlines()) == 2\n\n\n"
  },
  {
    "path": "openscad_utils.py",
    "content": "import py, re, os, signal, time, commands, sys\nfrom subprocess import Popen, PIPE\n\nmod_re = (r\"\\bmodule\\s+(\", r\")\\s*\\(\\s*\")\nfunc_re = (r\"\\bfunction\\s+(\", r\")\\s*\\(\")\n\ndef extract_definitions(fpath, name_re=r\"\\w+\", def_re=\"\"):\n    regex = name_re.join(def_re)\n    matcher = re.compile(regex)\n    return (m.group(1) for m in matcher.finditer(fpath.read()))\n\ndef extract_mod_names(fpath, name_re=r\"\\w+\"):\n    return extract_definitions(fpath, name_re=name_re, def_re=mod_re)\n\ndef extract_func_names(fpath, name_re=r\"\\w+\"):\n    return extract_definitions(fpath, name_re=name_re, def_re=func_re)\n\ndef collect_test_modules(dirpath=None):\n    dirpath = dirpath or py.path.local(\"./\")\n    print \"Collecting openscad test module names\"\n\n    test_files = {}\n    for fpath in dirpath.visit('*.scad'):\n        #print fpath\n        modules = extract_mod_names(fpath, r\"test\\w*\")\n        #functions = extract_func_names(fpath, r\"test\\w*\")\n        test_files[fpath] = modules\n    return test_files\n\nclass Timeout(Exception): pass\n\ndef call_openscad(path, stlpath, timeout=5):\n    if sys.platform == 'darwin': exe = 'OpenSCAD.app/Contents/MacOS/OpenSCAD'\n    else: exe = 'openscad'\n    command = [exe, '-s', str(stlpath),  str(path)]\n    print command\n    if timeout:\n        try:\n            proc = Popen(command,\n                stdout=PIPE, stderr=PIPE, close_fds=True)\n            calltime = time.time()\n            time.sleep(0.05)\n            #print calltime\n            while True:\n                if proc.poll() is not None:\n                    break\n                time.sleep(0.5)\n                #print time.time()\n                if time.time() > calltime + timeout:\n                    raise Timeout()\n        finally:\n            try:\n                proc.terminate()\n                proc.kill()\n            except OSError:\n                pass\n\n        return (proc.returncode,) + proc.communicate()\n    else:\n        output = commands.getstatusoutput(\" \".join(command))\n        return output + ('', '')\n\ndef parse_output(text):\n    pass\n"
  },
  {
    "path": "polyholes.scad",
    "content": "// Copyright 2011 Nophead (of RepRap fame)\r\n// This file is licensed under the terms of Creative Commons Attribution 3.0 Unported.\r\n\r\n// Using this holes should come out approximately right when printed\r\nmodule polyhole(h, d) {\r\n    n = max(round(2 * d),3);\r\n    rotate([0,0,180])\r\n        cylinder(h = h, r = (d / 2) / cos (180 / n), $fn = n);\r\n}\r\n\r\nmodule test_polyhole(){\r\ndifference() {\r\n\tcube(size = [100,27,3]);\r\n    union() {\r\n    \tfor(i = [1:10]) {\r\n            translate([(i * i + i)/2 + 3 * i , 8,-1])\r\n                polyhole(h = 5, d = i);\r\n                \r\n            assign(d = i + 0.5)\r\n                translate([(d * d + d)/2 + 3 * d, 19,-1])\r\n                    polyhole(h = 5, d = d);\r\n    \t}\r\n    }\r\n}\r\n}\r\n\r\n"
  },
  {
    "path": "regular_shapes.scad",
    "content": "/*\n *  OpenSCAD Shapes Library (www.openscad.org)\n *  Copyright (C) 2010-2011  Giles Bathgate, Elmo Mäntynen\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 3 of the License,\n *  LGPL version 2.1, or (at your option) any later version of the GPL.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program; if not, write to the Free Software\n *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n*/\n\n// 2D regular shapes\n\nmodule triangle(radius)\n{\n  o=radius/2;\t\t//equivalent to radius*sin(30)\n  a=radius*sqrt(3)/2;\t//equivalent to radius*cos(30)\n  polygon(points=[[-a,-o],[0,radius],[a,-o]],paths=[[0,1,2]]);\n}\n\nmodule reg_polygon(sides,radius)\n{\n  function dia(r) = sqrt(pow(r*2,2)/2);  //sqrt((r*2^2)/2) if only we had an exponention op\n  if(sides<2) square([radius,0]);\n  if(sides==3) triangle(radius);\n  if(sides==4) square([dia(radius),dia(radius)],center=true);\n  if(sides>4) circle(r=radius,$fn=sides);\n}\n\nmodule pentagon(radius)\n{\n  reg_polygon(5,radius);\n}\n\nmodule hexagon(radius)\n{\n  reg_polygon(6,radius);\n}\n\nmodule heptagon(radius)\n{\n  reg_polygon(7,radius);\n}\n\nmodule octagon(radius)\n{\n  reg_polygon(8,radius);\n}\n\nmodule nonagon(radius)\n{\n  reg_polygon(9,radius);\n}\n\nmodule decagon(radius)\n{\n  reg_polygon(10,radius);\n}\n\nmodule hendecagon(radius)\n{\n  reg_polygon(11,radius);\n}\n\nmodule dodecagon(radius)\n{\n  reg_polygon(12,radius);\n}\n\nmodule ring(inside_diameter, thickness){\n  difference(){\n    circle(r=(inside_diameter+thickness*2)/2);\n    circle(r=inside_diameter/2);\n  }\n}\n\nmodule ellipse(width, height) {\n  scale([1, height/width, 1]) circle(r=width/2);\n}\n\n// The ratio of lenght and width is about 1.39 for a real egg\nmodule egg_outline(width, length){\n    translate([0, width/2, 0]) union(){\n        rotate([0, 0, 180]) difference(){\n            ellipse(width, 2*length-width);\n            translate([-length/2, 0, 0]) square(length);\n        }\n        circle(r=width/2);\n    }\n}\n\n//3D regular shapes\n\nmodule cone(height, radius, center = false)\n{\n  cylinder(height, radius, 0, center);\n}\n\nmodule oval_prism(height, rx, ry, center = false)\n{\n  scale([1, rx/ry, 1]) cylinder(h=height, r=ry, center=center);\n}\n\nmodule oval_tube(height, rx, ry, wall, center = false)\n{\n  difference() {\n    scale([1, ry/rx, 1]) cylinder(h=height, r=rx, center=center);\n    translate([0,0,-height/2]) scale([(rx-wall)/rx, (ry-wall)/rx, 2]) cylinder(h=height, r=rx, center=center);\n  }\n}\n\nmodule cylinder_tube(height, radius, wall, center = false)\n{\n    tubify(radius,wall)\n    cylinder(h=height, r=radius, center=center);\n}\n\n//Tubifies any regular prism\nmodule tubify(radius,wall)\n{\n  difference()\n  {\n    child(0);\n    translate([0, 0, -0.1]) scale([(radius-wall)/radius, (radius-wall)/radius, 2]) child(0);\n  }\n}\n\nmodule triangle_prism(height,radius)\n{\n  linear_extrude(height=height) triangle(radius);\n}\n\nmodule triangle_tube(height,radius,wall)\n{\n   tubify(radius,wall) triangle_prism(height,radius);\n}\n\nmodule pentagon_prism(height,radius)\n{\n  linear_extrude(height=height) pentagon(radius);\n}\n\nmodule pentagon_tube(height,radius,wall)\n{\n tubify(radius,wall) pentagon_prism(height,radius);\n}\n\nmodule hexagon_prism(height,radius)\n{\n  linear_extrude(height=height) hexagon(radius);\n}\n\nmodule hexagon_tube(height,radius,wall)\n{\n tubify(radius,wall) hexagon_prism(height,radius);\n}\n\nmodule heptagon_prism(height,radius)\n{\n  linear_extrude(height=height) heptagon(radius);\n}\n\nmodule heptagon_tube(height,radius,wall)\n{\n tubify(radius,wall) heptagon_prism(height,radius);\n}\n\nmodule octagon_prism(height,radius)\n{\n  linear_extrude(height=height) octagon(radius);\n}\n\nmodule octagon_tube(height,radius,wall)\n{\n tubify(radius,wall) octagon_prism(height,radius);\n}\n\nmodule nonagon_prism(height,radius)\n{\n  linear_extrude(height=height) nonagon(radius);\n}\n\nmodule decagon_prism(height,radius)\n{\n  linear_extrude(height=height) decagon(radius);\n}\n\nmodule hendecagon_prism(height,radius)\n{\n  linear_extrude(height=height) hendecagon(radius);\n}\n\nmodule dodecagon_prism(height,radius)\n{\n  linear_extrude(height=height) dodecagon(radius);\n}\n\nmodule torus(outerRadius, innerRadius)\n{\n  r=(outerRadius-innerRadius)/2;\n  rotate_extrude() translate([innerRadius+r,0,0]) circle(r);\n}\n\nmodule torus2(r1, r2)\n{\n  rotate_extrude() translate([r1,0,0]) circle(r2);\n}\n\nmodule oval_torus(inner_radius, thickness=[0, 0])\n{\n  rotate_extrude() translate([inner_radius+thickness[0]/2,0,0]) ellipse(width=thickness[0], height=thickness[1]);\n}\n\n\nmodule triangle_pyramid(radius)\n{\n  o=radius/2;\t\t//equivalent to radius*sin(30)\n  a=radius*sqrt(3)/2;\t//equivalent to radius*cos(30)\n  polyhedron(points=[[-a,-o,-o],[a,-o,-o],[0,radius,-o],[0,0,radius]],triangles=[[0,1,2],[1,2,3],[0,1,3],[0,2,3]]);\n}\n\nmodule square_pyramid(base_x, base_y,height)\n{\n  w=base_x/2;\n  h=base_y/2;\n  polyhedron(points=[[-w,-h,0],[-w,h,0],[w,h,0],[w,-h,0],[0,0,height]],triangles=[[0,3,2,1], [0,1,4], [1,2,4], [2,3,4], [3,0,4]]);\n}\n\nmodule egg(width, lenght){\n    rotate_extrude()\n        difference(){\n            egg_outline(width, lenght);\n            translate([-lenght, 0, 0]) cube(2*lenght, center=true);\n        }\n}\n\n// Tests:\n\nmodule test_square_pyramid(){square_pyramid(10, 20, 30);}\n"
  },
  {
    "path": "screw.scad",
    "content": "// Parametric screw-like things (ball screws, augers)\n// License: GNU LGPL 2.1 or later.\n// © 2010 by Elmo Mäntynen\n\ninclude <curves.scad>\n\n/* common screw parameter\nlength\npitch = length/rotations: the distance between the turns of the thread\noutside_diameter\ninner_diameter: thickness of the shaft\n*/\n\n//Uncomment to see examples\n//test_auger();\n//test_ball_groove();\n//test_ball_groove2();\n//test_ball_screw();\n\nmodule helix(pitch, length, slices=500){\n    rotations = length/pitch;\n    linear_extrude(height=length, center=false, convexity=10, twist=360*rotations, slices=slices, $fn=100)\n        child(0);\n}\n\nmodule auger(pitch, length, outside_radius, inner_radius, taper_ratio = 0.25) {\n    union(){\n        helix(pitch, length)\n        polygon(points=[[0,inner_radius],[outside_radius,(inner_radius * taper_ratio)],[outside_radius,(inner_radius * -1 * taper_ratio)],[0,(-1 * inner_radius)]], paths=[[0,1,2,3]]);\n        cylinder(h=length, r=inner_radius);\n    }\n}\n\nmodule test_auger(){translate([50, 0, 0]) auger(40, 80, 25, 5);}\n\n\nmodule ball_groove(pitch, length, diameter, ball_radius=10) {\n    helix(pitch, length, slices=100)\n        translate([diameter, 0, 0])\n        circle(r = ball_radius);\n}\n\nmodule test_ball_groove(){ translate([0, 300, 0]) ball_groove(100, 300, 10);}\n\nmodule ball_groove2(pitch, length, diameter, ball_radius, slices=200){\n    rotations = length/pitch;\n    radius=diameter/2;\n    offset = length/slices;\n    union(){\n        for (i = [0:slices]) {\n            assign (z = i*offset){\n                translate(helix_curve(pitch, radius, z)) sphere(ball_radius, $fa=5, $fs=1);\n            }\n        }\n    }\n}\n\nmodule test_ball_groove2(){translate([0, 0, 0]) ball_groove2(100, 300, 100, 10);}\n\nmodule ball_screw(pitch, length, bearing_radius=2) {\n\n}\n\nmodule test_ball_screw(){}\n"
  },
  {
    "path": "servos.scad",
    "content": "/**\n * Servo outline library\n *\n * Authors:\n *   - Eero 'rambo' af Heurlin 2010-\n *\n * License: LGPL 2.1\n */\n\nuse <triangles.scad>\n\n/**\n * Align DS420 digital servo\n *\n * @param vector position The position vector\n * @param vector rotation The rotation vector\n * @param boolean screws If defined then \"screws\" will be added and when the module is differenced() from something if will have holes for the screws\n * @param number axle_lenght If defined this will draw \"backgound\" indicator for the main axle\n */\nmodule alignds420(position, rotation, screws = 0, axle_lenght = 0)\n{\n\ttranslate(position)\n\t{\n\t\trotate(rotation)\n\t    {\n\t\t\tunion()\n\t\t\t{\n\t\t\t\t// Main axle\n\t\t\t\ttranslate([0,0,17])\n\t\t\t\t{\n\t\t\t\t\tcylinder(r=6, h=8, $fn=30);\n\t\t\t\t\tcylinder(r=2.5, h=10.5, $fn=20);\n\t\t\t\t}\n\t\t\t\t// Box and ears\n\t\t\t\ttranslate([-6,-6,0])\n\t\t\t\t{\n\t\t\t\t\tcube([12, 22.8,19.5], false);\n\t\t\t\t\ttranslate([0,-5, 17])\n\t\t\t\t\t{\n\t\t\t\t\t\tcube([12, 7, 2.5]);\n\t\t\t\t\t}\n\t\t\t\t\ttranslate([0, 20.8, 17])\n\t\t\t\t\t{\n\t\t\t\t\t\tcube([12, 7, 2.5]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (screws > 0)\n\t\t\t\t{\n\t\t\t\t\ttranslate([0,(-10.2 + 1.8),11.5])\n\t\t\t\t\t{\n\t\t\t\t\t\t# cylinder(r=1.8/2, h=6, $fn=6);\n\t\t\t\t\t}\n\t\t\t\t\ttranslate([0,(21.0 - 1.8),11.5])\n\t\t\t\t\t{\n\t\t\t\t\t\t# cylinder(r=1.8/2, h=6, $fn=6);\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t// The large slope\n\t\t\t\ttranslate([-6,0,19])\n\t\t\t\t{\n\t\t\t\t\trotate([90,0,90])\n\t\t\t\t\t{\n\t\t\t\t\t\ttriangle(4, 18, 12);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * This seems to get too complex fast\n\t\t\t\t// Small additional axes\n\t\t\t\ttranslate([0,6,17])\n\t\t\t\t{\n\t\t\t\t\tcylinder(r=2.5, h=6, $fn=10);\n\t\t\t\t\tcylinder(r=1.25, h=8, $fn=10);\n\t\t\t\t}\n\t\t\t\t// Small slope\n\t\t\t\tdifference()\n\t\t\t\t{\n\t\t\t\t\ttranslate([-6,-6,19.0])\n\t\t\t\t\t{\n\t\t\t\t\t\tcube([12,6.5,4]);\n\t\t\t\t\t}\n\t\t\t\t\ttranslate([7,-7,24.0])\n\t\t\t\t\t{\n\t\t\t\t\t\trotate([-90,0,90])\n\t\t\t\t\t\t{\n\t\t\t\t            triangle(3, 8, 14);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t*/\n\t\t\t\t// So we render a cube instead of the small slope on a cube\n\t\t\t\ttranslate([-6,-6,19.0])\n\t\t\t\t{\n\t\t\t\t\tcube([12,6.5,4]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (axle_lenght > 0)\n\t\t\t{\n\t\t\t\t% cylinder(r=0.9, h=axle_lenght, center=true, $fn=8);\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Tests:\nmodule test_alignds420(){alignds420(screws=1);}\n"
  },
  {
    "path": "shapes.scad",
    "content": "/*\n *  OpenSCAD Shapes Library (www.openscad.org)\n *  Copyright (C) 2009  Catarina Mota\n *  Copyright (C) 2010  Elmo Mäntynen\n *\n *  License: LGPL 2.1 or later\n*/\n\n// 2D Shapes\n//ngon(sides, radius, center=false);\n\n// 3D Shapes\n//box(width, height, depth);\n//roundedBox(width, height, depth, radius);\n//cone(height, radius);\n//ellipticalCylinder(width, height, depth);\n//ellipsoid(width, height);\n//tube(height, radius, wall, center = false);\n//tube2(height, ID, OD, center = false);\n//ovalTube(width, height, depth, wall, center = false);\n//hexagon(height, depth);\n//octagon(height, depth);\n//dodecagon(height, depth);\n//hexagram(height, depth);\n//rightTriangle(adjacent, opposite, depth);\n//equiTriangle(side, depth);\n//12ptStar(height, depth);\n\n//----------------------\n\n// size is a vector [w, h, d]\nmodule box(width, height, depth) {\n  cube([width, height, depth], true);\n}\n\n// size is a vector [w, h, d]\nmodule roundedBox(width, height, depth, radius) {\n  size=[width, height, depth];\n  cube(size - [2*radius,0,0], true);\n  cube(size - [0,2*radius,0], true);\n  for (x = [radius-size[0]/2, -radius+size[0]/2],\n       y = [radius-size[1]/2, -radius+size[1]/2]) {\n    translate([x,y,0]) cylinder(r=radius, h=size[2], center=true);\n  }\n}\n\nmodule cone(height, radius, center = false) {\n  cylinder(height, radius, 0, center);\n}\n\nmodule ellipticalCylinder(w,h, height, center = false) {\n  scale([1, h/w, 1]) cylinder(h=height, r=w, center=center);\n}\n\nmodule ellipsoid(w, h, center = false) {\n  scale([1, h/w, 1]) sphere(r=w/2, center=center);\n}\n\n// wall is wall thickness\nmodule tube(height, radius, wall, center = false) {\n  difference() {\n    cylinder(h=height, r=radius, center=center);\n    cylinder(h=height, r=radius-wall, center=center);\n  }\n}\n\n// wall is wall thickness\nmodule tube2(height, ID, OD, center = false) {\n  difference() {\n    cylinder(h=height, r=OD/2, center=center);\n    cylinder(h=height, r=ID/2, center=center);\n  }\n}\n\n// wall is wall thickness\nmodule ovalTube(height, rx, ry, wall, center = false) {\n  difference() {\n    scale([1, ry/rx, 1]) cylinder(h=height, r=rx, center=center);\n    scale([(rx-wall)/rx, (ry-wall)/rx, 1]) cylinder(h=height, r=rx, center=center);\n  }\n}\n\n// size is the XY plane size, height in Z\nmodule hexagon(size, height) {\n  boxWidth = size/1.75;\n  for (r = [-60, 0, 60]) rotate([0,0,r]) cube([boxWidth, size, height], true);\n}\n\n// size is the XY plane size, height in Z\nmodule octagon(size, height) {\n  intersection() {\n    cube([size, size, height], true);\n    rotate([0,0,45]) cube([size, size, height], true);\n  }\n}\n\n// size is the XY plane size, height in Z\nmodule dodecagon(size, height) {\n  intersection() {\n    hexagon(size, height);\n    rotate([0,0,90]) hexagon(size, height);\n  }\n}\n\n// size is the XY plane size, height in Z\nmodule hexagram(size, height) {\n  boxWidth=size/1.75;\n  for (v = [[0,1],[0,-1],[1,-1]]) {\n    intersection() {\n      rotate([0,0,60*v[0]]) cube([size, boxWidth, height], true);\n      rotate([0,0,60*v[1]]) cube([size, boxWidth, height], true);\n    }\n  }\n}\n\nmodule rightTriangle(adjacent, opposite, height) {\n  difference() {\n    translate([-adjacent/2,opposite/2,0]) cube([adjacent, opposite, height], true);\n    translate([-adjacent,0,0]) {\n      rotate([0,0,atan(opposite/adjacent)]) dislocateBox(adjacent*2, opposite, height+2);\n    }\n  }\n}\n\nmodule equiTriangle(side, height) {\n  difference() {\n    translate([-side/2,side/2,0]) cube([side, side, height], true);\n    rotate([0,0,30]) dislocateBox(side*2, side, height);\n    translate([-side,0,0]) {\n      rotate([0,0,60]) dislocateBox(side*2, side, height);\n    }\n  }\n}\n\nmodule 12ptStar(size, height) {\n  starNum = 3;\n  starAngle = 360/starNum;\n  for (s = [1:starNum]) {\n    rotate([0, 0, s*starAngle]) cube([size, size, height], true);\n  }\n}\n\n//-----------------------\n//MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER\nmodule dislocateBox(w, h, d) {\n  translate([0,0,-d/2]) cube([w,h,d]);\n}\n\n//-----------------------\n// Tests\n//module test2D_ellipse(){ellipse(10, 5);}\nmodule test_ellipsoid(){ellipsoid(10, 5);}\n\n//module test2D_egg_outline(){egg_outline();}\n"
  },
  {
    "path": "stepper.scad",
    "content": "/*\n * A nema standard stepper motor module.\n * \n * Originally by Hans Häggström, 2010.\n * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later\n */\n\ninclude <units.scad>\ninclude <materials.scad>\n\n\n// Demo, uncomment to show:\n//nema_demo();\n\nmodule nema_demo(){\n    for (size = [NemaShort, NemaMedium, NemaLong]) {  \n      translate([-100,size*100,0]) motor(Nema34, size, dualAxis=true);\n      translate([0,size*100,0])    motor(Nema23, size, dualAxis=true);\n      translate([100,size*100,0])  motor(Nema17, size, dualAxis=true);\n      translate([200,size*100,0])  motor(Nema14, size, dualAxis=true);\n      translate([300,size*100,0])  motor(Nema11, size, dualAxis=true);\n      translate([400,size*100,0])  motor(Nema08, size, dualAxis=true);\n    }\n}\n\n\n// Parameters: \nNemaModel = 0;\nNemaLengthShort = 1;\nNemaLengthMedium = 2;\nNemaLengthLong = 3;\nNemaSideSize = 4;\nNemaDistanceBetweenMountingHoles = 5;\nNemaMountingHoleDiameter = 6;\nNemaMountingHoleDepth = 7;\nNemaMountingHoleLip = 8;\nNemaMountingHoleCutoutRadius = 9;\nNemaEdgeRoundingRadius = 10;\nNemaRoundExtrusionDiameter = 11;\nNemaRoundExtrusionHeight = 12;\nNemaAxleDiameter = 13;\nNemaFrontAxleLength = 14;\nNemaBackAxleLength = 15;\nNemaAxleFlatDepth = 16;\nNemaAxleFlatLengthFront = 17;\nNemaAxleFlatLengthBack = 18;\n\nNemaA = 1;\nNemaB = 2;\nNemaC = 3;\n\nNemaShort = NemaA;\nNemaMedium = NemaB;\nNemaLong = NemaC;\n\n// TODO: The small motors seem to be a bit too long, I picked the size specs from all over the place, is there some canonical reference?\nNema08 = [\n                [NemaModel, 8],\n                [NemaLengthShort, 33*mm],\n                [NemaLengthMedium, 43*mm],\n                [NemaLengthLong, 43*mm],\n                [NemaSideSize, 20*mm], \n                [NemaDistanceBetweenMountingHoles, 15.4*mm], \n                [NemaMountingHoleDiameter, 2*mm], \n                [NemaMountingHoleDepth, 1.75*mm], \n                [NemaMountingHoleLip, -1*mm], \n                [NemaMountingHoleCutoutRadius, 0*mm], \n                [NemaEdgeRoundingRadius, 2*mm], \n                [NemaRoundExtrusionDiameter, 16*mm], \n                [NemaRoundExtrusionHeight, 1.5*mm], \n                [NemaAxleDiameter, 4*mm], \n                [NemaFrontAxleLength, 13.5*mm], \n                [NemaBackAxleLength, 9.9*mm],\n                [NemaAxleFlatDepth, -1*mm],\n                [NemaAxleFlatLengthFront, 0*mm],\n                [NemaAxleFlatLengthBack, 0*mm]\n         ];\n\nNema11 = [\n                [NemaModel, 11],\n                [NemaLengthShort, 32*mm],\n                [NemaLengthMedium, 40*mm],\n                [NemaLengthLong, 52*mm],\n                [NemaSideSize, 28*mm], \n                [NemaDistanceBetweenMountingHoles, 23*mm], \n                [NemaMountingHoleDiameter, 2.5*mm], \n                [NemaMountingHoleDepth, 2*mm], \n                [NemaMountingHoleLip, -1*mm], \n                [NemaMountingHoleCutoutRadius, 0*mm], \n                [NemaEdgeRoundingRadius, 2.5*mm], \n                [NemaRoundExtrusionDiameter, 22*mm], \n                [NemaRoundExtrusionHeight, 1.8*mm], \n                [NemaAxleDiameter, 5*mm], \n                [NemaFrontAxleLength, 13.7*mm], \n                [NemaBackAxleLength, 10*mm],\n                [NemaAxleFlatDepth, 0.5*mm],\n                [NemaAxleFlatLengthFront, 10*mm],\n                [NemaAxleFlatLengthBack, 9*mm]\n         ];\n\nNema14 = [\n                [NemaModel, 14],\n                [NemaLengthShort, 26*mm], \n                [NemaLengthMedium, 28*mm], \n                [NemaLengthLong, 34*mm], \n                [NemaSideSize, 35.3*mm], \n                [NemaDistanceBetweenMountingHoles, 26*mm], \n                [NemaMountingHoleDiameter, 3*mm], \n                [NemaMountingHoleDepth, 3.5*mm], \n                [NemaMountingHoleLip, -1*mm], \n                [NemaMountingHoleCutoutRadius, 0*mm], \n                [NemaEdgeRoundingRadius, 5*mm], \n                [NemaRoundExtrusionDiameter, 22*mm], \n                [NemaRoundExtrusionHeight, 1.9*mm], \n                [NemaAxleDiameter, 5*mm], \n                [NemaFrontAxleLength, 18*mm], \n                [NemaBackAxleLength, 10*mm],\n                [NemaAxleFlatDepth, 0.5*mm],\n                [NemaAxleFlatLengthFront, 15*mm],\n                [NemaAxleFlatLengthBack, 9*mm]\n         ];\n\nNema17 = [\n                [NemaModel, 17],\n                [NemaLengthShort, 33*mm],\n                [NemaLengthMedium, 39*mm],\n                [NemaLengthLong, 47*mm],\n                [NemaSideSize, 42.20*mm], \n                [NemaDistanceBetweenMountingHoles, 31.04*mm], \n                [NemaMountingHoleDiameter, 4*mm], \n                [NemaMountingHoleDepth, 4.5*mm], \n                [NemaMountingHoleLip, -1*mm], \n                [NemaMountingHoleCutoutRadius, 0*mm], \n                [NemaEdgeRoundingRadius, 7*mm], \n                [NemaRoundExtrusionDiameter, 22*mm], \n                [NemaRoundExtrusionHeight, 1.9*mm], \n                [NemaAxleDiameter, 5*mm], \n                [NemaFrontAxleLength, 18*mm], \n                [NemaBackAxleLength, 15*mm],\n                [NemaAxleFlatDepth, 0.5*mm],\n                [NemaAxleFlatLengthFront, 15*mm],\n                [NemaAxleFlatLengthBack, 14*mm]\n         ];\n\nNema23 = [\n                [NemaModel, 23],\n                [NemaLengthShort, 39*mm],\n                [NemaLengthMedium, 54*mm],\n                [NemaLengthLong, 76*mm],\n                [NemaSideSize, 56.4*mm], \n                [NemaDistanceBetweenMountingHoles, 47.14*mm], \n                [NemaMountingHoleDiameter, 4.75*mm], \n                [NemaMountingHoleDepth, 5*mm], \n                [NemaMountingHoleLip, 4.95*mm], \n                [NemaMountingHoleCutoutRadius, 9.5*mm], \n                [NemaEdgeRoundingRadius, 2.5*mm], \n                [NemaRoundExtrusionDiameter, 38.10*mm], \n                [NemaRoundExtrusionHeight, 1.52*mm], \n                [NemaAxleDiameter, 6.36*mm], \n                [NemaFrontAxleLength, 18.80*mm], \n                [NemaBackAxleLength, 15.60*mm],\n                [NemaAxleFlatDepth, 0.5*mm],\n                [NemaAxleFlatLengthFront, 16*mm],\n                [NemaAxleFlatLengthBack, 14*mm]\n         ];\n\nNema34 = [\n                [NemaModel, 34],\n                [NemaLengthShort, 66*mm],\n                [NemaLengthMedium, 96*mm],\n                [NemaLengthLong, 126*mm],\n                [NemaSideSize, 85*mm], \n                [NemaDistanceBetweenMountingHoles, 69.58*mm], \n                [NemaMountingHoleDiameter, 6.5*mm], \n                [NemaMountingHoleDepth, 5.5*mm], \n                [NemaMountingHoleLip, 5*mm], \n                [NemaMountingHoleCutoutRadius, 17*mm], \n                [NemaEdgeRoundingRadius, 3*mm], \n                [NemaRoundExtrusionDiameter, 73.03*mm], \n                [NemaRoundExtrusionHeight, 1.9*mm], \n                [NemaAxleDiameter, 0.5*inch], \n                [NemaFrontAxleLength, 37*mm], \n                [NemaBackAxleLength, 34*mm],\n                [NemaAxleFlatDepth, 1.20*mm],\n                [NemaAxleFlatLengthFront, 25*mm],\n                [NemaAxleFlatLengthBack, 25*mm]\n         ];\n\n\n\nfunction motorWidth(model=Nema23) = lookup(NemaSideSize, model);\nfunction motorLength(model=Nema23, size=NemaMedium) = lookup(size, model);\n\n\nmodule motor(model=Nema23, size=NemaMedium, dualAxis=false, pos=[0,0,0], orientation = [0,0,0]) {\n\n  length = lookup(size, model);\n\n  echo(str(\"  Motor: Nema\",lookup(NemaModel, model),\", length= \",length,\"mm, dual axis=\",dualAxis));\n\n  stepperBlack    = BlackPaint;\n  stepperAluminum = Aluminum;\n\n  side = lookup(NemaSideSize, model);\n\n  cutR = lookup(NemaMountingHoleCutoutRadius, model);\n  lip = lookup(NemaMountingHoleLip, model);\n  holeDepth = lookup(NemaMountingHoleDepth, model);\n\n  axleLengthFront = lookup(NemaFrontAxleLength, model);\n  axleLengthBack = lookup(NemaBackAxleLength, model);\n  axleRadius = lookup(NemaAxleDiameter, model) * 0.5;\n\n  extrSize = lookup(NemaRoundExtrusionHeight, model);\n  extrRad = lookup(NemaRoundExtrusionDiameter, model) * 0.5;\n\n  holeDist = lookup(NemaDistanceBetweenMountingHoles, model) * 0.5;\n  holeRadius = lookup(NemaMountingHoleDiameter, model) * 0.5;\n\n  mid = side / 2;\n\n  roundR = lookup(NemaEdgeRoundingRadius, model);\n\n  axleFlatDepth = lookup(NemaAxleFlatDepth, model);\n  axleFlatLengthFront = lookup(NemaAxleFlatLengthFront, model);\n  axleFlatLengthBack = lookup(NemaAxleFlatLengthBack, model);\n\n  color(stepperBlack){\n    translate(pos) rotate(orientation) {\n      translate([-mid, -mid, 0]) \n        difference() {          \n          cube(size=[side, side, length + extrSize]);\n \n          // Corner cutouts\n          if (lip > 0) {\n            translate([0,    0,    lip]) cylinder(h=length, r=cutR);\n            translate([side, 0,    lip]) cylinder(h=length, r=cutR);\n            translate([0,    side, lip]) cylinder(h=length, r=cutR);\n            translate([side, side, lip]) cylinder(h=length, r=cutR);\n\n          }\n\n          // Rounded edges\n          if (roundR > 0) {\n                translate([mid+mid, mid+mid, length/2])\n                  rotate([0,0,45])\n                    cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true);\n                translate([mid-(mid), mid+(mid), length/2])\n                  rotate([0,0,45])\n                    cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true);\n                translate([mid+mid, mid-mid, length/2])\n                  rotate([0,0,45])\n                    cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true);\n                translate([mid-mid, mid-mid, length/2])\n                  rotate([0,0,45])\n                    cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true);\n\n          }\n\n          // Bolt holes\n          color(stepperAluminum, $fs=holeRadius/8) {\n            translate([mid+holeDist,mid+holeDist]) cylinder(h=holeDepth+1*mm, r=holeRadius);\n            translate([mid-holeDist,mid+holeDist]) cylinder(h=holeDepth+1*mm, r=holeRadius);\n            translate([mid+holeDist,mid-holeDist]) cylinder(h=holeDepth+1*mm, r=holeRadius);\n            translate([mid-holeDist,mid-holeDist]) cylinder(h=holeDepth+1*mm, r=holeRadius);\n\n          } \n\n          // Grinded flat\n          color(stepperAluminum) {\n            difference() {\n              translate([-1*mm, -1*mm, -extrSize]) \n                cube(size=[side+2*mm, side+2*mm, extrSize + 1*mm]);\n              translate([side/2, side/2, -extrSize - 1*mm]) \n                cylinder(h=4*mm, r=extrRad);\n            }\n          }\n\n        }\n\n      // Axle\n      translate([0, 0, extrSize-axleLengthFront]) color(stepperAluminum) \n        difference() {\n                     \n          cylinder(h=axleLengthFront + 1*mm , r=axleRadius, $fs=axleRadius/10);\n\n          // Flat\n          if (axleFlatDepth > 0)\n            translate([axleRadius - axleFlatDepth,-5*mm,-extrSize*mm -(axleLengthFront-axleFlatLengthFront)] ) cube(size=[5*mm, 10*mm, axleLengthFront]);\n        }\n\n        if (dualAxis) {\n          translate([0, 0, length+extrSize]) color(stepperAluminum) \n            difference() {\n                     \n              cylinder(h=axleLengthBack + 0*mm, r=axleRadius, $fs=axleRadius/10);\n\n              // Flat\n              if (axleFlatDepth > 0)\n                translate([axleRadius - axleFlatDepth,-5*mm,(axleLengthBack-axleFlatLengthBack)]) cube(size=[5*mm, 10*mm, axleLengthBack]);\n          }\n\n        }\n\n    }\n  }\n}\n\nmodule roundedBox(size, edgeRadius) {\n    cube(size);\n\n}\n\n"
  },
  {
    "path": "teardrop.scad",
    "content": "/* From http://www.thingiverse.com/thing:3457\n   © 2010 whosawhatsis\n\n   This program is free software: you can redistribute it and/or modify\n   it under the terms of the GNU Lesser General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n   GNU Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public License\n   along with this program. If not, see <http://www.gnu.org/licenses/>.\n*/\n\n\n/*\nThis script generates a teardrop shape at the appropriate angle to prevent overhangs greater than 45 degrees. The angle is in degrees, and is a rotation around the Y axis. You can then rotate around Z to point it in any direction. Rotation around X or Y will cause the angle to be wrong.\n*/\n\nmodule teardrop(radius, length, angle) {\n\trotate([0, angle, 0]) union() {\n\t\tlinear_extrude(height = length, center = true, convexity = radius, twist = 0)\n\t\t\tcircle(r = radius, center = true, $fn = 30);\n\t\tlinear_extrude(height = length, center = true, convexity = radius, twist = 0)\n\t\t\tprojection(cut = false) rotate([0, -angle, 0]) translate([0, 0, radius * sin(45) * 1.5]) cylinder(h = radius * sin(45), r1 = radius * sin(45), r2 = 0, center = true, $fn = 30);\n\t}\n\t\t\n\t//I worked this portion out when a bug was causing the projection above to take FOREVER to calculate. It works as a replacement, and I figured I'd leave it here just in case.\n\t/*\n\t\t#polygon(points = [[radius * cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]);\n\t\t#polygon(points = [[radius * -cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * -cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]);\n\t\t#polygon(points = [[radius * sin(-angle / 2), radius * cos(-angle / 2), 0],[radius * sin(-angle / 2), radius * -cos(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]);\n\t*/\n}\n\nmodule test_teardrop(){\n    translate([0, -15, 0]) teardrop(5, 20, 90);\n    translate([0, 0, 0]) teardrop(5, 20, 60);\n    translate([0, 15, 0]) teardrop(5, 20, 45);\n}\n\n//test_teardrop();\n"
  },
  {
    "path": "test_docs.py",
    "content": "import py\nimport os.path\n\ndirpath = py.path.local(\"./\")\n\ndef pytest_generate_tests(metafunc):\n    if \"filename\" in metafunc.funcargnames:\n        for fpath in dirpath.visit('*.scad'):\n            metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))\n        for fpath in dirpath.visit('*.py'):\n            name = fpath.basename\n            if not (name.startswith('test_') or name.startswith('_')):\n                metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))\n\ndef test_README(filename):\n    README = dirpath.join('README').read()\n\n    assert filename in README\n"
  },
  {
    "path": "test_mcad.py",
    "content": "from openscad_testing import *\n"
  },
  {
    "path": "transformations.scad",
    "content": "// License: GNU LGPL 2.1 or later.\n// © 2010 by Elmo Mäntynen\n\nmodule local_scale(v, reference=[0, 0, 0]) {\n    translate(-reference) scale(v) translate(reference) child(0);\n}\n"
  },
  {
    "path": "triangles.scad",
    "content": "/**\n * Simple triangles library\n *\n * Authors:\n *   - Eero 'rambo' af Heurlin 2010-\n *\n * License: LGPL 2.1\n */\n\n\n/**\n * Standard right-angled triangle\n *\n * @param number o_len Lenght of the opposite side\n * @param number a_len Lenght of the adjacent side\n * @param number depth How wide/deep the triangle is in the 3rd dimension\n * @todo a better way ?\n */\nmodule triangle(o_len, a_len, depth)\n{\n    linear_extrude(height=depth)\n    {\n        polygon(points=[[0,0],[a_len,0],[0,o_len]], paths=[[0,1,2]]);\n    }\n}\n\n/**\n * Standard right-angled triangle (tangent version)\n *\n * @param number angle of adjacent to hypotenuse (ie tangent)\n * @param number a_len Lenght of the adjacent side\n * @param number depth How wide/deep the triangle is in the 3rd dimension\n */\nmodule a_triangle(tan_angle, a_len, depth)\n{\n    linear_extrude(height=depth)\n    {\n        polygon(points=[[0,0],[a_len,0],[0,tan(tan_angle) * a_len]], paths=[[0,1,2]]);\n    }\n}\n\n// Tests:\nmodule test_triangle() { triangle(5, 5, 5); }\nmodule test_a_triangle() { a_triangle(45, 5, 5); }\nmodule test_triangles()\n{\n    // Generate a bunch of triangles by sizes\n    for (i = [1:10])\n    {\n        translate([i*7, -30, i*7])\n        {\n            triangle(i*5, sqrt(i*5+pow(i,2)), 5);\n        }\n    }\n\n    // Generate a bunch of triangles by angle\n    for (i = [1:85/5])\n    {\n        translate([i*7, 22, i*7])\n        {\n            a_triangle(i*5, 10, 5);\n        }\n    }\n}\n"
  },
  {
    "path": "trochoids.scad",
    "content": "//===========================================\r\n//   Public Domain Epi- and Hypo- trochoids in OpenSCAD\r\n//   version 1.0\r\n//   by Matt Moses, 2011, mmoses152@gmail.com\r\n//   http://www.thingiverse.com/thing:8067\r\n//\r\n//   This file is public domain.  Use it for any purpose, including commercial\r\n//   applications.  Attribution would be nice, but is not required.  There is\r\n//   no warranty of any kind, including its correctness, usefulness, or safety.\r\n//\r\n//   An EPITROCHOID is a curve traced by a point \r\n//   fixed at a distance \"d\" \r\n//   to the center of a circle of radius \"r\"\r\n//   as the circle rolls \r\n//   outside another circle of radius \"R\".\r\n//\r\n//   An HYPOTROCHOID is a curve traced by a point \r\n//   fixed at a distance \"d\" \r\n//   to the center of a circle of radius \"r\"\r\n//   as the circle rolls \r\n//   inside another circle of radius \"R\".\r\n//\r\n//   An EPICYCLOID is an epitrochoid with d = r.\r\n//\r\n//   An HYPOCYCLOID is an hypotrochoid with d = r.\r\n//\r\n//   See http://en.wikipedia.org/wiki/Epitrochoid\r\n//   and http://en.wikipedia.org/wiki/Hypotrochoid\r\n// \r\n//   Beware the polar forms of the equations on Wikipedia...\r\n//   They are correct, but theta is measured to the center of the small disk!!\r\n//===========================================\r\n\r\n// There are several different methods for extruding.  The best are probably\r\n// the ones using linear extrude.\r\n\r\n\r\n//===========================================\r\n//   Demo - draws one of each, plus some little wheels and sticks.\r\n//\r\n//   Fun stuff to try: \r\n//   Animate, try FPS = 5 and Steps = 200\r\n//   R = 2, r = 1, d = 0.2\r\n//   R = 4, r = 1, d = 1\r\n//   R = 2, r = 1, d = 0.5\r\n//   \r\n//   What happens when you make d > r ??\r\n//   What happens when d < 0 ??\r\n//   What happens when r < 0 ??\r\n//\r\n//===========================================\r\n\r\n$fn = 30;\r\n\r\nthickness = 2;\r\nR = 4;\r\nr = 1;\r\nd = 1;\r\nn = 60; // number of wedge segments\r\n\r\nalpha = 360*$t;\r\n\r\ncolor([0, 0, 1])\r\ntranslate([0, 0, -0.5])\r\n\tcylinder(h = 1, r= R, center = true);\r\n\r\ncolor([0, 1, 0])\r\nepitrochoid(R,r,d,n,thickness);\r\n\r\ncolor([1, 0, 0])\r\ntranslate([ (R+r)*cos(alpha) , (R+r)*sin(alpha), -0.5]) {\r\n\trotate([0, 0, alpha + R/r*alpha]) {\r\n\t\tcylinder(h = 1, r = r, center = true);\r\n\t\ttranslate([-d, 0, 1.5]) {\r\n\t\t\tcylinder(h = 2.2, r = 0.1, center = true);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\ntranslate([2*(abs(R) + abs(r) + abs(d)), 0, 0]){\r\ncolor([0, 0, 1])\r\ntranslate([0, 0, -0.5])\r\n\tdifference() {\r\n\t\tcylinder(h = 1, r = 1.1*R, center = true);\r\n\t\tcylinder(h = 1.1, r= R, center = true);\r\n\t}\r\n\r\ncolor([0, 1, 0])\r\nhypotrochoid(R,r,d,n,thickness);\r\n\r\ncolor([1, 0, 0])\r\ntranslate([ (R-r)*cos(alpha) , (R-r)*sin(alpha), -0.5]) {\r\n\trotate([0, 0, alpha - R/r*alpha]) {\r\n\t\tcylinder(h = 1, r = r, center = true);\r\n\t\ttranslate([d, 0, 1.5]) {\r\n\t\t\tcylinder(h = 2.2, r = 0.1, center = true);\r\n\t\t}\r\n\t}\r\n}\r\n}\r\n\r\n// This just makes a twisted hypotrochoid\r\ntranslate([0,14, 0])\r\nhypotrochoidLinear(4, 1, 1, 40, 40, 10, 30);\r\n\r\n//   End of Demo Section\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Epitrochoid\r\n//\r\nmodule epitrochoid(R, r, d, n, thickness) {\r\n\tdth = 360/n;\r\n\tfor ( i = [0:n-1] ) {\r\n\t\t\tpolyhedron(points = [[0,0,0], \r\n\t\t\t[(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], \r\n\t\t\t[(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], \r\n\t\t\t[0,0,thickness], \r\n\t\t\t[(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], \r\n\t\t\t[(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness]],\r\n\t\t\ttriangles = [[0, 2, 1], \r\n\t\t\t[0, 1,  3], \r\n\t\t\t[3, 1, 4], \r\n\t\t\t[3, 4, 5], \r\n\t\t\t[0, 3, 2], \r\n\t\t\t[2, 3, 5],\r\n\t\t\t[1, 2, 4],\r\n\t\t\t[2, 5, 4]]);\r\n\t}\r\n}\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Hypotrochoid\r\n//\r\nmodule hypotrochoid(R, r, d, n, thickness) {\r\n\tdth = 360/n;\r\n\tfor ( i = [0:n-1] ) {\r\n\t\t\tpolyhedron(points = [[0,0,0], \r\n\t\t\t[(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], \r\n\t\t\t[(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], \r\n\t\t\t[0,0,thickness], \r\n\t\t\t[(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], \r\n\t\t\t[(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness]],\r\n\t\t\ttriangles = [[0, 2, 1], \r\n\t\t\t[0, 1,  3], \r\n\t\t\t[3, 1, 4], \r\n\t\t\t[3, 4, 5], \r\n\t\t\t[0, 3, 2], \r\n\t\t\t[2, 3, 5],\r\n\t\t\t[1, 2, 4],\r\n\t\t\t[2, 5, 4]]);\r\n\t}\r\n}\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Epitrochoid Wedge with Bore\r\n//\r\nmodule epitrochoidWBore(R, r, d, n, p, thickness, rb) {\r\n\tdth = 360/n;\r\n\tunion() {\r\n\tfor ( i = [0:p-1] ) {\r\n\t\t\tpolyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], \r\n\t\t\t[(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], \r\n\t\t\t[(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], \r\n\t\t\t[rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], \r\n\t\t\t[rb*cos(dth*i), rb*sin(dth*i), thickness],\r\n\t\t\t[(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], \r\n\t\t\t[(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness],\r\n\t\t\t[rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]],\r\n\t\t\ttriangles = [[0, 1, 4], [4, 1, 5],\r\n\t\t\t[1, 2, 5], [5, 2, 6], \r\n\t\t\t[2, 3, 7], [7, 6, 2], \r\n\t\t\t[3, 0, 4], [4, 7, 3], \r\n\t\t\t[4, 5, 7], [7, 5, 6], \r\n\t\t\t[0, 3, 1], [1, 3, 2]]); \r\n\t}\r\n\t}\r\n}\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Epitrochoid Wedge with Bore, Linear Extrude\r\n//\r\nmodule epitrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) {\r\n\tdth = 360/n;\r\n\tlinear_extrude(height = thickness, convexity = 10, twist = twist) {\r\n\tunion() {\r\n\tfor ( i = [0:p-1] ) {\r\n\t\t\tpolygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], \r\n\t\t\t[(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], \r\n\t\t\t[(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))], \r\n\t\t\t[rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]],\r\n\t\t\tpaths = [[0, 1, 2, 3]], convexity = 10); \r\n\t}\r\n\t}\r\n\t}\r\n}\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Epitrochoid Wedge, Linear Extrude\r\n//\r\nmodule epitrochoidLinear(R, r, d, n, p, thickness, twist) {\r\n\tdth = 360/n;\r\n\tlinear_extrude(height = thickness, convexity = 10, twist = twist) {\r\n\tunion() {\r\n\tfor ( i = [0:p-1] ) {\r\n\t\t\tpolygon(points = [[0, 0], \r\n\t\t\t[(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], \r\n\t\t\t[(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))]], \r\n\t\t\tpaths = [[0, 1, 2]], convexity = 10); \r\n\t}\r\n\t}\r\n\t}\r\n}\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Hypotrochoid Wedge with Bore\r\n//\r\nmodule hypotrochoidWBore(R, r, d, n, p, thickness, rb) {\r\n\tdth = 360/n;\r\n\tunion() {\r\n\tfor ( i = [0:p-1] ) {\r\n\t\t\tpolyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], \r\n\t\t\t[(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], \r\n\t\t\t[(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], \r\n\t\t\t[rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], \r\n\t\t\t[rb*cos(dth*i), rb*sin(dth*i), thickness],\r\n\t\t\t[(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], \r\n\t\t\t[(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness],\r\n\t\t\t[rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]],\r\n\t\t\ttriangles = [[0, 1, 4], [4, 1, 5],\r\n\t\t\t[1, 2, 5], [5, 2, 6], \r\n\t\t\t[2, 3, 7], [7, 6, 2], \r\n\t\t\t[3, 0, 4], [4, 7, 3], \r\n\t\t\t[4, 5, 7], [7, 5, 6], \r\n\t\t\t[0, 3, 1], [1, 3, 2]]); \r\n\t}\r\n\t}\r\n}\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Hypotrochoid Wedge with Bore, Linear Extrude\r\n//\r\nmodule hypotrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) {\r\n\tdth = 360/n;\r\n\tlinear_extrude(height = thickness, convexity = 10, twist = twist) {\r\n\tunion() {\r\n\tfor ( i = [0:p-1] ) {\r\n\t\t\tpolygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], \r\n\t\t\t[(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], \r\n\t\t\t[(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))], \r\n\t\t\t[rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]], \r\n\t\t\tpaths = [[0, 1, 2, 3]], convexity = 10); \r\n\t}\r\n\t}\r\n\t}\r\n}\r\n//===========================================\r\n\r\n\r\n//===========================================\r\n// Hypotrochoid Wedge, Linear Extrude\r\n//\r\nmodule hypotrochoidLinear(R, r, d, n, p, thickness, twist) {\r\n\tdth = 360/n;\r\n\tlinear_extrude(height = thickness, convexity = 10, twist = twist) {\r\n\tunion() {\r\n\tfor ( i = [0:p-1] ) {\r\n\t\t\tpolygon(points = [[0, 0], \r\n\t\t\t[(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], \r\n\t\t\t[(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))]],\r\n\t\t\tpaths = [[0, 1, 2]], convexity = 10); \r\n\t}\r\n\t}\r\n\t}\r\n}\r\n//=========================================== \r\n"
  },
  {
    "path": "units.scad",
    "content": "/*\n * Basic units.\n * \n * Originally by Hans Häggström, 2010.\n * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later\n */\n\n\nmm = 1;\ncm = 10 * mm;\ndm = 100 * mm;\nm = 1000 * mm;\n\ninch = 25.4 * mm;\n\nX = [1, 0, 0];\nY = [0, 1, 0];\nZ = [0, 0, 1];\n\nM3 = 3*mm;\nM4 = 4*mm;\nM5 = 5*mm;\nM6 = 6*mm;\nM8 = 8*mm;\n\n\n// When a small distance is needed to overlap shapes for boolean cutting, etc.\nepsilon = 0.01*mm;\n\n"
  },
  {
    "path": "unregular_shapes.scad",
    "content": "// Copyright 2011 Elmo Mäntynen\n// LGPL 2.1\n\n// Give a list of 4+4 points (check order) to form an 8 point polyhedron \nmodule connect_squares(points){\n    polyhedron(points=points,\n               triangles=[[0,1,2], [3,0,2], [7,6,5], [7,5,4], // Given polygons\n                          [0,4,1], [4,5,1], [1,5,2], [2,5,6],  // Connecting\n                          [2,6,3], [3,6,7], [3,4,0], [3,7,4]]);// sides\n}\n"
  },
  {
    "path": "utilities.scad",
    "content": "/*\n * Utility functions.\n *\n * Originally by Hans Häggström, 2010.\n * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later\n */\n\ninclude <units.scad>\n\nfunction distance(a, b) = sqrt( (a[0] - b[0])*(a[0] - b[0]) +\n                                (a[1] - b[1])*(a[1] - b[1]) +\n                                (a[2] - b[2])*(a[2] - b[2]) );\n\nfunction length2(a) = sqrt( a[0]*a[0] + a[1]*a[1] );\n\nfunction normalized(a) = a / (max(distance([0,0,0], a), 0.00001));\n\nfunction normalized_axis(a) = a == \"x\" ? [1, 0, 0]:\n                   a == \"y\" ? [0, 1, 0]:\n                   a == \"z\" ? [0, 0, 1]: normalized(a);\n\nfunction angleOfNormalizedVector(n) = [0, -atan2(n[2], length2([n[0], n[1]])), atan2(n[1], n[0]) ];\n\nfunction angle(v) = angleOfNormalizedVector(normalized(v));\n\nfunction angleBetweenTwoPoints(a, b) = angle(normalized(b-a));\n\n\nCENTER = 0;\nLEFT = -0.5;\nRIGHT = 0.5;\nTOP = 0.5;\nBOTTOM = -0.5;\n\nFlatCap =0;\nExtendedCap =0.5;\nCutCap =-0.5;\n\n\nmodule fromTo(from=[0,0,0], to=[1*m,0,0], size=[1*cm, 1*cm], align=[CENTER, CENTER], material=[0.5, 0.5, 0.5], name=\"\", endExtras=[0,0], endCaps=[FlatCap, FlatCap], rotation=[0,0,0], printString=true) {\n\n  angle = angleBetweenTwoPoints(from, to);\n  length = distance(from, to) + endCaps[0]*size[0] + endCaps[1]*size[0] + endExtras[0] + endExtras[1];\n\n  if (length > 0) {\n    if (printString) echo(str(\"  \" ,name, \" \", size[0], \"mm x \", size[1], \"mm, length \",length,\"mm\"));\n\n    color(material)\n      translate(from)\n        rotate(angle)\n          translate( [ -endCaps[0]*size[0] - endExtras[0], size[0]*(-0.5-align[0]), size[1]*(-0.5+align[1]) ] )\n            rotate(rotation)\n              scale([length, size[0], size[1]]) child();\n  }\n}\n\nmodule part(name) {\n  echo(\"\");\n  echo(str(name, \":\"));\n}\n"
  }
]