-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_polyhedron.jscad
104 lines (95 loc) · 1.95 KB
/
test_polyhedron.jscad
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
joined_truncated_cube = function () {
// http://dmccooey.com/polyhedra/JoinedTruncatedCube.html
var C0, C1, vertices, faces;
C0 = (1 + sqrt(2)) / 2;
C1 = 1 + sqrt(2);
vertices = [
[ 0.0, 0.0, C1],
[ 0.0, 0.0, -C1],
[ C1, 0.0, 0.0],
[ -C1, 0.0, 0.0],
[ 0.0, C1, 0.0],
[ 0.0, -C1, 0.0],
[ C0, 0.5, C0],
[ C0, 0.5, -C0],
[ C0, -0.5, C0],
[ C0, -0.5, -C0],
[ -C0, 0.5, C0],
[ -C0, 0.5, -C0],
[ -C0, -0.5, C0],
[ -C0, -0.5, -C0],
[ C0, C0, 0.5],
[ C0, C0, -0.5],
[ C0, -C0, 0.5],
[ C0, -C0, -0.5],
[ -C0, C0, 0.5],
[ -C0, C0, -0.5],
[ -C0, -C0, 0.5],
[ -C0, -C0, -0.5],
[ 0.5, C0, C0],
[ 0.5, C0, -C0],
[ 0.5, -C0, C0],
[ 0.5, -C0, -C0],
[-0.5, C0, C0],
[-0.5, C0, -C0],
[-0.5, -C0, C0],
[-0.5, -C0, -C0],
[ 1.0, 1.0, 1.0],
[ 1.0, 1.0, -1.0],
[ 1.0, -1.0, 1.0],
[ 1.0, -1.0, -1.0],
[-1.0, 1.0, 1.0],
[-1.0, 1.0, -1.0],
[-1.0, -1.0, 1.0],
[-1.0, -1.0, -1.0]
];
faces = [
[30, 6, 2, 14],
[30, 14, 4, 22],
[30, 22, 0, 6],
[31, 7, 1, 23],
[31, 23, 4, 15],
[31, 15, 2, 7],
[32, 8, 0, 24],
[32, 24, 5, 16],
[32, 16, 2, 8],
[33, 9, 2, 17],
[33, 17, 5, 25],
[33, 25, 1, 9],
[34, 10, 0, 26],
[34, 26, 4, 18],
[34, 18, 3, 10],
[35, 11, 3, 19],
[35, 19, 4, 27],
[35, 27, 1, 11],
[36, 12, 3, 20],
[36, 20, 5, 28],
[36, 28, 0, 12],
[37, 13, 1, 29],
[37, 29, 5, 21],
[37, 21, 3, 13],
[ 0, 8, 2, 6],
[ 0, 10, 3, 12],
[ 1, 7, 2, 9],
[ 1, 13, 3, 11],
[ 2, 15, 4, 14],
[ 2, 16, 5, 17],
[ 3, 18, 4, 19],
[ 3, 21, 5, 20],
[ 4, 26, 0, 22],
[ 4, 23, 1, 27],
[ 5, 24, 0, 28],
[ 5, 29, 1, 25]
];
return {
normal : polyhedron({points:vertices, polygons:faces}),
reverse: polyhedron({points:vertices, polygons:faces.map(f=>f.reverse())})
};
};
function main(){
var r = [];
var v = joined_truncated_cube();
r.push(color("orange", v.normal.scale(10).translate([0,0,25])));
r.push(color("red", v.reverse.scale(10).translate([-50,0,25])));
return r;
}