summaryrefslogtreecommitdiff
path: root/testdata/scad/features/polyhedron-tests.scad
blob: 1f11d7ef45fce8cbb4236709c628fba891837e79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module polyhedrons() {
 polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],
            triangles = [[0,4,2],[0,2,5],[0,3,4],[0,5,3],[1,2,4],[1,5,2],[1,4,3], [1,3,5]]);

 // One face flipped
 translate([2,0,0])
  polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],
            triangles = [[0,4,2],[0,2,5],[0,3,4],[0,5,3],[1,2,4],[1,5,2],[1,3,4], [1,3,5]]);

 // All faces flipped
 translate([4,0,0])
  polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],
            triangles = [[0,2,4],[0,5,2],[0,4,3],[0,3,5],[1,4,2],[1,2,5],[1,3,4], [1,5,3]]);

// Containing concave polygons
translate([6,0,0])
polyhedron(points=[
        [-0.8,-0.8,-0.8],
        [0,0,-0.8],
        [0.8,-0.8,-0.8],
        [0.8,0.8,-0.8],
        [-0.8,0.8,-0.8],
        [-0.8,-0.8,0.8],
        [0,0,0.8],
        [0.8,-0.8,0.8],
        [0.8,0.8,0.8],
        [-0.8,0.8,0.8],
    ],
    triangles=[
        [0,1,2,3,4],
        [5,6,1,0],
        [6,7,2,1],
        [7,8,3,2],
        [8,9,4,3],
        [9,5,0,4],
        [9,8,7,6,5],
    ], convexity=2);
}

polyhedrons();
translate([0,2,0]) difference() {
  polyhedrons();
  translate([3,0,2]) cube([8,3,3], center=true);
}

contact: Jan Huwald // Impressum