polyhedron:
| ← Older revision | Revision as of 23:27, 31 December 2011 | ||
| (One intermediate revision by one user not shown) | |||
| Line 36: | Line 36: | ||
| sphere(r = 5); | sphere(r = 5); | ||
| sphere(r = 10); | sphere(r = 10); | ||
| − | sphere(2, $fn=100); // this will create a high resolution sphere with a 2mm radius | + | |
| − | sphere(2, $fa=5, $fs=0.1); // will also create a 2mm high resolution sphere but this one does not have as many small triangles on the poles of the sphere | + | // this will create a high resolution sphere with a 2mm radius |
| + | sphere(2, $fn=100); | ||
| + | |||
| + | // will also create a 2mm high resolution sphere but this one | ||
| + | // does not have as many small triangles on the poles of the sphere | ||
| + | sphere(2, $fa=5, $fs=0.1); | ||
| [[File:Openscad-sphere.jpg]] | [[File:Openscad-sphere.jpg]] | ||
| Line 67: | Line 67: | ||
| Usage example: | Usage example: | ||
| + | |||
| + | <source lang="java"> | ||
| polyhedron(points = [ [x, y, z], ... ], triangles = [ [p1, p2, p3..], ... ], convexity = N); | polyhedron(points = [ [x, y, z], ... ], triangles = [ [p1, p2, p3..], ... ], convexity = N); | ||
| + | </source> | ||
| Create a polyhedron with the specified points and triangles. (The 'pN' components of the triangles vector are 0-indexed references to the elements of the points vector.) | Create a polyhedron with the specified points and triangles. (The 'pN' components of the triangles vector are 0-indexed references to the elements of the points vector.) | ||
| Line 74: | Line 77: | ||
| Real Example 1: | Real Example 1: | ||
| − | polyhedron(points=[[0,0,0],[100,0,0],[0,100,0],[0,100,100]], triangles=[[0,1,2],[1,0,3],[0,2,3],[2,1,3]]); | + | <source lang="java"> |
| + | polyhedron( | ||
| + | points=[[0,0,0],[100,0,0],[0,100,0],[0,100,100]], | ||
| + | triangles=[[0,1,2],[1,0,3],[0,2,3],[2,1,3]] | ||
| + | ); | ||
| + | </source> | ||
| Real example 2 (a kind of prism, see the picture below) | Real example 2 (a kind of prism, see the picture below) | ||
| − | polyhedron ( points = [[0, -10, 60], [0, 10, 60], [0, 10, 0], [0, -10, 0], [60, -10, 60], [60, 10, 60]], | + | <source lang="java"> |
| − | triangles = [[0,3,2], [0,2,1], [3,0,4], [1,2,5], [0,5,4], [0,1,5], [5,2,4], [4,2,3], ]); | + | polyhedron ( points = [[0, -10, 60], [0, 10, 60], [0, 10, 0], |
| + | [0, -10, 0], [60, -10, 60], [60, 10, 60]], | ||
| + | triangles = [[0,3,2], [0,2,1], [3,0,4], [1,2,5], | ||
| + | [0,5,4], [0,1,5], [5,2,4], [4,2,3], ]); | ||
| + | </source> | ||
| [[image:openscad-polyhedron-example.png|frame|none|A simple hand-crafted Polyhedron]] | [[image:openscad-polyhedron-example.png|frame|none|A simple hand-crafted Polyhedron]] | ||
| Line 84: | Line 87: | ||
| 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. | 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. | ||
| e.g. | e.g. | ||
| − | polyhedron(points=[[0,0,0],[100,0,0],[0,100,0],[0,100,100]], triangles=[[0,1,2],[0,1,3],[0,2,3],[1,2,3]]); //Generates an error | + | <source lang="java"> |
| − | polyhedron(points=[[0,0,0],[100,0,0],[0,100,0],[0,100,100]], triangles=[[0,1,2],[1,0,3],[0,2,3],[2,1,3]]); //Works | + | polyhedron( points = [[0,0,0],[100,0,0],[0,100,0],[0,100,100]], |
| + | triangles = [[0,1,2], [0,1,3], [0,2,3], [1,2,3]]); //Generates an error | ||
| + | |||
| + | polyhedron( points = [[0,0,0],[100,0,0],[0,100,0],[0,100,100]], | ||
| + | triangles = [[0,1,2], [1,0,3], [0,2,3], [2,1,3]]); //Works | ||
| + | </source> | ||
| Let's now see how to fix polyhedrons with badly oriented polygons. When you select 'Thrown together' from the view menu and '''compile''' the design | Let's now see how to fix polyhedrons with badly oriented polygons. When you select 'Thrown together' from the view menu and '''compile''' the design |
