User:LABoyd2/polyhedron from manual 160313

polyhedron
Create a polyhedron with a list of points and a list of faces. The point list is all the vertices of the shape, the faces list is how the points relate to the surfaces of the polyhedron.

note: if your version of OpenSCAD is lower than 2014.03 replace "faces" with "triangles" in the below examples

Parameters
 * points : vector of points or vertices (each a 3 vector).
 * triangles : (deprecated in version 2014.03, use faces) vector of point triplets (each a 3 number vector). Each number is the 0-indexed point number from the point vector.
 * faces : (introduced in version 2014.03) vector of point n-tuples with n >= 3. Each number is the 0-indexed point number from the point vector. That is, faces=0,1,4 specifies a triangle made from the first, second, and fifth point listed in points. When referencing more than 3 points in a single tuple, the points must all be on the same plane.
 * convexity: Integer. The convexity parameter specifies the maximum number of front sides (back sides) a ray intersecting the object might penetrate. This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering.

Syntax example

Point ordering for faces When looking at the face from the outside inwards, the points must be clockwise. You can rearrange the order of the points or the order they are referenced in each tuple. The order of faces is immaterial. Note that if your polygons are not all oriented the same way OpenSCAD will either print an error or crash completely, so pay attention to the vertex ordering. Again, remember that the 'pN' components of the faces vector are 0-indexed references to the elements of the points vector.

Example, a square base pyramid: