meta data for this page
This is an old revision of the document!
Polyhedron
A three dimensional shape where connecting faces create a solid. Each face is a three dimensional polygon (a flat shape with straight sides).
Learn about polyhedrons at MathIsFun.com
Create a polyhedron with a list of points and a list of triangles or polygons. The point list is all the vertexes of the shape, the triangle list is how the points relates to the surfaces of the polyhedron
polyhedron({ // openscad-like (e.g. pyramid) points: [ [10,10,0],[10,-10,0],[-10,-10,0],[-10,10,0], // the four points at base [0,0,10] ], // the apex point triangles: [ [0,1,4],[1,2,4],[2,3,4],[3,0,4], // each triangle side [1,0,3],[2,1,3] ] // two triangles for square base });
Additionally you can also define `polygons: [ [0,1,4,5], [..] ]` too, not just `triangles:`.
You can also create a polyhedron at a more low-level.
var polygons = []; polygons.push(new CSG.Polygon([ new CSG.Vertex(new CSG.Vector3D(-5,-5,0)), new CSG.Vertex(new CSG.Vector3D(2,2,5)), new CSG.Vertex(new CSG.Vector3D(3,3,15)) ]) ); // add more polygons and finally: solid = CSG.fromPolygons(polygons);