OpenSCAD User Manual/要素図形

原点の座標に直方体を作る。 centerがtrueの際、原点を中心に作られ、falseの際はx, y, z 共に正の方向に作られる。 引数が下記のパラメータと同じ順ならば、引数の名前を省略し、値だけを入力してもよい。
引数
例:

原点を中心に球を作る。引数名は省略可である。
引数
例:

座標系の原点に円筒を生成する。 1つの半径 (r) を指定すると円筒になり、2つの異なる半径 (r1, r2) を指定すると円錐になる。
引数
デフォルトは false、つまり円筒の底面 (半径 r1) が原点となる。
例:

Create a polyhedron with a list of points and a list of triangles. The point list is all the vertexes of the shape, the triangle list is how the points relates to the surfaces of the polyhedron.
Parameters
Syntax example
Triangle points ordering 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 triangle triple. The order of triangles 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.
Example, a square base pyramid:
Ordering of triangle points An example of a more complex polyhedron, and showing how to fix polyhedrons with badly oriented polygons.
When you select 'Thrown together' from the view menu and compile the design (not compile and render!) you will see a preview with the mis-oriented polygons highlighted. Unfortunately this highlighting is not possible in the OpenCSG preview mode because it would interfere with the way the OpenCSG preview mode is implemented.)
Below you can see the code and the picture of such a problematic polyhedron, the bad polygons (triangles or compositions of triangles) are in pink.
A correct polyhedron would be the following:
Beginner's tip:
If you don't really understand "orientation", try to identify the mis-oriented pink triangles and then permute the references to the points vectors until you get it right. E.g. in the above example, the third triangle ([0,4,5]) was wrong and we fixed it as [4,0,5]. In addition, you may select "Show Edges" from the "View Menu", print a screen capture and number both the points and the triangles. In our example, the points are annotated in black and the triangles in blue. Turn the object around and make a second copy from the back if needed. This way you can keep track.
Clockwise Technique:
Orientation is determined by clockwise indexing. This means that if you're looking at the triangle (in this case [4,0,5]) from the outside you'll see that the path is clockwise around the center of the face. The winding order [4,0,5] is clockwise and therefore good. The winding order [0,4,5] is counter-clockwise and therefore bad. Likewise, any other clockwise order of [4,0,5] works: [5,4,0] & [0,5,4] are good too. If you use the clockwise technique, you'll always have your faces outside (outside of OpenSCAD, other programs do use counter-clockwise as the outside though).
Think of it as a Left Hand Rule:
If you hold the triangle and the fingers of your hand curls is the same order as the points, then your thumb points outwards.
Succinct description of a 'Polyhedron'
Each point, in the point list, is defined with a 3-tuple x,y,z position specification. Points in the point list are automatically given an identifier starting at zero for use in the triangle list (0,1,2,3,... etc).
Each triangle, in the triangle list, is defined by selecting 3 of the points (using the point identifier) out of the point list.
e.g. triangles=[ [0,1,2] ] defines a triangle from the first point (points are zero referenced) to the second point and then to the third point.
When looking at any triangle from the outside, the triangle must list their 3 points in a clockwise order.