diff --git a/examples/example.libtriangles.scad b/examples/example.libtriangles.scad new file mode 100644 index 0000000..05390ec --- /dev/null +++ b/examples/example.libtriangles.scad @@ -0,0 +1,10 @@ +use <../libtriangles.scad>; + +//all of these follow the (X,Y,Z) syntax + +translate(v = [0, 0, 0])eqlpyramid(10,20,30); +translate(v = [20, 0, 0]) rightpyramid(10,20,30); +translate(v = [40, 0, 0]) cornerpyramid(10,20,30); +translate(v = [60, 0, 0]) rightprism(10,20,30); +translate(v = [80, 0, 0]) eqlprism(10,20,30); + diff --git a/examples/example.stl b/examples/example.stl new file mode 100644 index 0000000..f3adc29 --- /dev/null +++ b/examples/example.stl @@ -0,0 +1,240 @@ +solid OpenSCAD_Model + facet normal -0.986394 0 0.164399 + outer loop + vertex 0 20 0 + vertex 0 0 0 + vertex 5 10 30 + endloop + endfacet + facet normal 0 -0.948683 0.316228 + outer loop + vertex 5 10 30 + vertex 0 0 0 + vertex 10 0 0 + endloop + endfacet + facet normal -0 -0 -1 + outer loop + vertex 0 0 0 + vertex 0 20 0 + vertex 10 0 0 + endloop + endfacet + facet normal 0 0 -1 + outer loop + vertex 10 0 0 + vertex 0 20 0 + vertex 10 20 0 + endloop + endfacet + facet normal -0 0.948683 0.316228 + outer loop + vertex 10 20 0 + vertex 0 20 0 + vertex 5 10 30 + endloop + endfacet + facet normal 0.986394 -0 0.164399 + outer loop + vertex 10 20 0 + vertex 5 10 30 + vertex 10 0 0 + endloop + endfacet + facet normal -0.986394 0 0.164399 + outer loop + vertex 20 20 0 + vertex 20 0 0 + vertex 25 20 30 + endloop + endfacet + facet normal 0 -0.83205 0.5547 + outer loop + vertex 25 20 30 + vertex 20 0 0 + vertex 30 0 0 + endloop + endfacet + facet normal -0 -0 -1 + outer loop + vertex 20 0 0 + vertex 20 20 0 + vertex 30 0 0 + endloop + endfacet + facet normal 0 0 -1 + outer loop + vertex 30 0 0 + vertex 20 20 0 + vertex 30 20 0 + endloop + endfacet + facet normal -0 1 0 + outer loop + vertex 30 20 0 + vertex 20 20 0 + vertex 25 20 30 + endloop + endfacet + facet normal 0.986394 -0 0.164399 + outer loop + vertex 30 20 0 + vertex 25 20 30 + vertex 30 0 0 + endloop + endfacet + facet normal -1 0 0 + outer loop + vertex 40 20 0 + vertex 40 0 0 + vertex 40 20 30 + endloop + endfacet + facet normal 0 -0.83205 0.5547 + outer loop + vertex 40 20 30 + vertex 40 0 0 + vertex 50 0 0 + endloop + endfacet + facet normal -0 -0 -1 + outer loop + vertex 40 0 0 + vertex 40 20 0 + vertex 50 0 0 + endloop + endfacet + facet normal 0 0 -1 + outer loop + vertex 50 0 0 + vertex 40 20 0 + vertex 50 20 0 + endloop + endfacet + facet normal -0 1 0 + outer loop + vertex 50 20 0 + vertex 40 20 0 + vertex 40 20 30 + endloop + endfacet + facet normal 0.948683 -0 0.316228 + outer loop + vertex 50 20 0 + vertex 40 20 30 + vertex 50 0 0 + endloop + endfacet + facet normal -1 -0 -0 + outer loop + vertex 60 0 0 + vertex 60 0 30 + vertex 60 20 0 + endloop + endfacet + facet normal -1 0 0 + outer loop + vertex 60 20 0 + vertex 60 0 30 + vertex 60 20 30 + endloop + endfacet + facet normal 0 -1 0 + outer loop + vertex 60 0 30 + vertex 60 0 0 + vertex 70 0 0 + endloop + endfacet + facet normal -0 -0 -1 + outer loop + vertex 60 0 0 + vertex 60 20 0 + vertex 70 0 0 + endloop + endfacet + facet normal 0 0 -1 + outer loop + vertex 70 0 0 + vertex 60 20 0 + vertex 70 20 0 + endloop + endfacet + facet normal -0 1 0 + outer loop + vertex 70 20 0 + vertex 60 20 0 + vertex 60 20 30 + endloop + endfacet + facet normal 0.948683 -0 0.316228 + outer loop + vertex 60 20 30 + vertex 60 0 30 + vertex 70 0 0 + endloop + endfacet + facet normal 0.948683 -0 0.316228 + outer loop + vertex 70 20 0 + vertex 60 20 30 + vertex 70 0 0 + endloop + endfacet + facet normal -0.986394 0 0.164399 + outer loop + vertex 80 0 0 + vertex 85 0 30 + vertex 80 20 0 + endloop + endfacet + facet normal -0.986394 0 0.164399 + outer loop + vertex 80 20 0 + vertex 85 0 30 + vertex 85 20 30 + endloop + endfacet + facet normal 0 -1 0 + outer loop + vertex 85 0 30 + vertex 80 0 0 + vertex 90 0 0 + endloop + endfacet + facet normal -0 -0 -1 + outer loop + vertex 80 0 0 + vertex 80 20 0 + vertex 90 0 0 + endloop + endfacet + facet normal 0 0 -1 + outer loop + vertex 90 0 0 + vertex 80 20 0 + vertex 90 20 0 + endloop + endfacet + facet normal -0 1 0 + outer loop + vertex 90 20 0 + vertex 80 20 0 + vertex 85 20 30 + endloop + endfacet + facet normal 0.986394 -0 0.164399 + outer loop + vertex 85 20 30 + vertex 85 0 30 + vertex 90 0 0 + endloop + endfacet + facet normal 0.986394 -0 0.164399 + outer loop + vertex 90 20 0 + vertex 85 20 30 + vertex 90 0 0 + endloop + endfacet +endsolid OpenSCAD_Model diff --git a/libtriangles.scad b/libtriangles.scad new file mode 100644 index 0000000..40e4876 --- /dev/null +++ b/libtriangles.scad @@ -0,0 +1,58 @@ +//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. + +module rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) { + polyhedron ( points = [[0,0,0], + [rightpyramidx, 0, 0], + [0, rightpyramidy, 0], + [rightpyramidx, rightpyramidy, 0], + [rightpyramidx/2, rightpyramidy, rightpyramidz]], + + triangles = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); + +} + +module cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) { + polyhedron ( points = [[0,0,0], + [cornerpyramidx, 0, 0], + [0, cornerpyramidy, 0], + [cornerpyramidx, cornerpyramidy, 0], + [0, cornerpyramidy, cornerpyramidz]], + + triangles = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); + +} + +module eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) { + polyhedron ( points = [[0,0,0], + [eqlpyramidx, 0, 0], + [0, eqlpyramidy, 0], + [eqlpyramidx, eqlpyramidy, 0], + [eqlpyramidx/2, eqlpyramidy/2, eqlpyramidz]], + + triangles = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); + +} + + +module rightprism(rightprismx,rightprismy,rightprismz){ + polyhedron ( points = [[0,0,0], + [rightprismx,0,0], + [rightprismx,rightprismy,0], + [0,rightprismy,0], + [0,rightprismy,rightprismz], + [0,0,rightprismz]], + triangles = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); +} + + + +module eqlprism(rightprismx,rightprismy,rightprismz){ + polyhedron ( points = [[0,0,0], + [rightprismx,0,0], + [rightprismx,rightprismy,0], + [0,rightprismy,0], + [rightprismx/2,rightprismy,rightprismz], + [rightprismx/2,0,rightprismz]], + triangles = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); +} +