@jscad/web 2.5.10 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +1 -1
- package/dist/jscad-web.min.js +959 -2030
- package/examples/CHANGELOG.md +30 -0
- package/examples/README.md +1 -5
- package/examples/package.json +1 -1
- package/examples/parameters/gear.js +1 -1
- package/locales/README.md +23 -0
- package/locales/de.json +1 -0
- package/locales/en.json +2 -1
- package/locales/fr.json +1 -0
- package/locales/hr.json +1 -0
- package/locales/ja.json +1 -0
- package/locales/zh.json +62 -0
- package/package.json +7 -7
- package/postInstall.js +0 -1
- package/src/index.js +2 -1
- package/src/sideEffects/i18n/index.js +2 -1
- package/src/sideEffects/worker/index.js +7 -8
- package/src/ui/flow/design.js +10 -305
- package/src/ui/flow/reducers.js +304 -0
- package/examples/old/benchmark-cag.jscad +0 -27
- package/examples/old/benchmark-csg.jscad +0 -29
- package/examples/old/benchmark.jscad +0 -25
- package/examples/old/bunch-cubes.jscad +0 -17
- package/examples/old/complex/example001.jscad +0 -31
- package/examples/old/complex/example002.jscad +0 -25
- package/examples/old/complex/example003.jscad +0 -25
- package/examples/old/complex/example004.jscad +0 -16
- package/examples/old/complex/example005.jscad +0 -27
- package/examples/old/complex/globe.js +0 -235
- package/examples/old/complex/iphone4-case.js +0 -213
- package/examples/old/complex/umbilical_torus.js +0 -43
- package/examples/old/complex/umbilical_torus.scad +0 -37
- package/examples/old/core/cncCutout.js +0 -16
- package/examples/old/core/connectors/servo.js +0 -185
- package/examples/old/core/extrusions/extrudeLinear.js +0 -24
- package/examples/old/core/extrusions/extrudeRectangular.js +0 -21
- package/examples/old/core/extrusions/extrudeRotate.js +0 -43
- package/examples/old/core/extrusions/slices/four2three-round.js +0 -62
- package/examples/old/core/extrusions/slices/four2three.js +0 -53
- package/examples/old/core/extrusions/slices/jar-barrel.js +0 -60
- package/examples/old/core/extrusions/slices/jar.js +0 -69
- package/examples/old/core/extrusions/slices/non-aff.js +0 -72
- package/examples/old/core/extrusions/slices/rose.js +0 -52
- package/examples/old/core/extrusions/slices/screw.js +0 -34
- package/examples/old/core/extrusions/slices/screwDouble.js +0 -34
- package/examples/old/core/extrusions/slices/slices.js +0 -43
- package/examples/old/core/extrusions/slices/spring.js +0 -41
- package/examples/old/core/extrusions/slices/three2four.js +0 -42
- package/examples/old/core/extrusions/slices/tor.js +0 -30
- package/examples/old/core/hulls/hullChain.js +0 -58
- package/examples/old/core/lookup.js +0 -19
- package/examples/old/core/platonics/main.jscad +0 -42
- package/examples/old/core/platonics/maths_geodesic.jscad +0 -192
- package/examples/old/core/platonics/origv07/dualdodeca_difference.stl +0 -1962
- package/examples/old/core/platonics/origv07/dualdodeca_intersection.stl +0 -1374
- package/examples/old/core/platonics/origv07/dualdodeca_union.stl +0 -1822
- package/examples/old/core/platonics/origv07/maths_geodesic.scad +0 -162
- package/examples/old/core/platonics/origv07/platonic.scad +0 -483
- package/examples/old/core/platonics/origv07/test_platonic.scad +0 -616
- package/examples/old/core/platonics/platonic.jscad +0 -528
- package/examples/old/core/text/textSimplex.js +0 -625
- package/examples/old/core/transforms/transformations.js +0 -29
- package/examples/old/echo.jscad +0 -7
- package/examples/old/formats/scad/example001.scad +0 -26
- package/examples/old/formats/scad/example002.scad +0 -23
- package/examples/old/formats/scad/example003.scad +0 -20
- package/examples/old/formats/scad/example004.scad +0 -11
- package/examples/old/formats/scad/example005.scad +0 -20
- package/examples/old/json_logo.json +0 -1
- package/examples/old/parameters/axis-coupler.js +0 -149
- package/examples/old/parameters/celtic-knot-ring.js +0 -300
- package/examples/old/parameters/grille.js +0 -257
- package/examples/old/parameters/lamp-shade.js +0 -369
- package/examples/old/parameters/name-plate.js +0 -46
- package/examples/old/parameters/s-hook.js +0 -131
- package/examples/old/parameters/stepper-motor.js +0 -127
- package/examples/old/various/logo.js +0 -32
- package/examples/old/voxel.json +0 -1
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
License: This code is placed in the public Domain
|
|
3
|
-
Contributed By: Willliam A Adams
|
|
4
|
-
August 2011
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// A couple of useful constants
|
|
8
|
-
Cpi = 3.14159;
|
|
9
|
-
Cphi = 1.61803399;
|
|
10
|
-
Cepsilon = 0.00000001;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Function: clean
|
|
14
|
-
//
|
|
15
|
-
// Parameters:
|
|
16
|
-
// n - A number that might be very close to zero
|
|
17
|
-
// Description:
|
|
18
|
-
// There are times when you want a very small number to
|
|
19
|
-
// just be zero, instead of being that very small number.
|
|
20
|
-
// This function will compare the number to an arbitrarily small
|
|
21
|
-
// number. If it is smaller than the 'epsilon', then zero will be
|
|
22
|
-
// returned. Otherwise, the original number will be returned.
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
function clean(n) = (n < 0) ? ((n < -Cepsilon) ? n : 0) :
|
|
26
|
-
(n < Cepsilon) ? 0 : n;
|
|
27
|
-
|
|
28
|
-
// Function: safediv
|
|
29
|
-
//
|
|
30
|
-
// Parameters
|
|
31
|
-
// n - The numerator
|
|
32
|
-
// d - The denominator
|
|
33
|
-
//
|
|
34
|
-
// Description:
|
|
35
|
-
// Since division by zero is generally not a desirable thing, safediv
|
|
36
|
-
// will return '0' whenever there is a division by zero. Although this will
|
|
37
|
-
// mask some erroneous division by zero errors, it is often the case
|
|
38
|
-
// that you actually want this behavior. So, it makes it convenient.
|
|
39
|
-
function safediv(n,d) = (d==0) ? 0 : n/d;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//==================================
|
|
43
|
-
// Degrees
|
|
44
|
-
//==================================
|
|
45
|
-
|
|
46
|
-
function DEGREES(radians) = (180/Cpi) * radians;
|
|
47
|
-
|
|
48
|
-
function RADIANS(degrees) = Cpi/180 * degrees;
|
|
49
|
-
|
|
50
|
-
function deg(deg, min=0, sec=0) = [deg, min, sec];
|
|
51
|
-
|
|
52
|
-
function deg_to_dec(d) = d[0] + d[1]/60 + d[2]/60/60;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//==================================
|
|
56
|
-
// Spherical coordinates
|
|
57
|
-
//==================================
|
|
58
|
-
|
|
59
|
-
// create an instance of a spherical coordinate
|
|
60
|
-
// long - rotation around z -axis
|
|
61
|
-
// lat - latitude, starting at 0 == 'north pole'
|
|
62
|
-
// rad - distance from center
|
|
63
|
-
function sph(long, lat, rad=1) = [long, lat, rad];
|
|
64
|
-
|
|
65
|
-
// Convert spherical to cartesian
|
|
66
|
-
function sph_to_cart(s) = [
|
|
67
|
-
clean(s[2]*sin(s[1])*cos(s[0])),
|
|
68
|
-
clean(s[2]*sin(s[1])*sin(s[0])),
|
|
69
|
-
clean(s[2]*cos(s[1]))
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
// Convert from cartesian to spherical
|
|
73
|
-
function sph_from_cart(c) = sph(
|
|
74
|
-
atan2(c[1],c[0]),
|
|
75
|
-
atan2(sqrt(c[0]*c[0]+c[1]*c[1]), c[2]),
|
|
76
|
-
sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2])
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
function sphu_from_cart(c, rad=1) = sph(
|
|
80
|
-
atan2(c[1],c[0]),
|
|
81
|
-
atan2(sqrt(c[0]*c[0]+c[1]*c[1]), c[2]),
|
|
82
|
-
rad
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// compute the chord distance between two points on a sphere
|
|
86
|
-
function sph_dist(c1, c2) = sqrt(
|
|
87
|
-
c1[2]*c1[2] + c2[2]*c2[2] -
|
|
88
|
-
2*c1[2]*c2[2]*
|
|
89
|
-
((cos(c1[1])*cos(c2[1])) + cos(c1[0]-c2[0])*sin(c1[1])*sin(c2[1]))
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//==========================================
|
|
94
|
-
// Geodesic calculations
|
|
95
|
-
//
|
|
96
|
-
// Reference: Geodesic Math and How to Use It
|
|
97
|
-
// By: Hugh Kenner
|
|
98
|
-
// Second Paperback Edition (2003), p.74-75
|
|
99
|
-
// http://www.amazon.com/Geodesic-Math-How-Hugh-Kenner/dp/0520239318
|
|
100
|
-
//
|
|
101
|
-
// The book was used for reference, so if you want to check the math,
|
|
102
|
-
// you can plug in various numbers to various routines and see if you get
|
|
103
|
-
// the same numbers in the book.
|
|
104
|
-
//
|
|
105
|
-
// In general, there are enough routines here to implement the various
|
|
106
|
-
// pieces necessary to make geodesic objects.
|
|
107
|
-
//==========================================
|
|
108
|
-
|
|
109
|
-
function poly_sum_interior_angles(sides) = (sides-2)*180;
|
|
110
|
-
function poly_single_interior_angle(pq) = poly_sum_interior_angles(pq[0])/pq[0];
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// Given a set of coordinates, return the frequency
|
|
115
|
-
// Simply calculated by adding up the values of the coordinates
|
|
116
|
-
function geo_freq(xyz) = xyz[0]+xyz[1]+xyz[2];
|
|
117
|
-
|
|
118
|
-
// Convert between the 2D coordinates of vertices on the face triangle
|
|
119
|
-
// to the 3D vertices needed to calculate spherical coordinates
|
|
120
|
-
function geo_tri2_tri3(xyf) = [xyf[1], xyf[0]-xyf[1], xyf[2]-xyf[0]];
|
|
121
|
-
|
|
122
|
-
// Given coordinates for a vertex on the octahedron face
|
|
123
|
-
// return the spherical coordinates for the vertex
|
|
124
|
-
// class 1, method 1
|
|
125
|
-
function octa_class1(c) = sph(
|
|
126
|
-
atan(safediv(c[0], c[1])),
|
|
127
|
-
atan(sqrt(c[0]*c[0]+c[1]*c[1])/c[2]),
|
|
128
|
-
1
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
function octa_class2(c) = sph(
|
|
132
|
-
atan(c[0]/c[1]),
|
|
133
|
-
atan( sqrt( 2*(c[0]*c[0]+c[1]*c[1])) /c[2]),
|
|
134
|
-
1
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
function icosa_class1(c) = octa_class1(
|
|
138
|
-
[
|
|
139
|
-
c[0]*sin(72),
|
|
140
|
-
c[1]+c[0]*cos(72),
|
|
141
|
-
geo_freq(c)/2+c[2]/Cphi
|
|
142
|
-
]);
|
|
143
|
-
|
|
144
|
-
function icosa_class2(c) = sph(
|
|
145
|
-
atan([c0]/c[1]),
|
|
146
|
-
atan(sqrt(c[0]*c[0]+c[1]*c[1]))/cos(36)*c[2],
|
|
147
|
-
1
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
function tetra_class1(c) = octa_class1(
|
|
151
|
-
[
|
|
152
|
-
sqrt(3*c[0]),
|
|
153
|
-
2*c[1]-c[0],
|
|
154
|
-
(3*c[2]-c[0]-c[1])/sqrt(2)
|
|
155
|
-
]);
|
|
156
|
-
|
|
157
|
-
function class1_icosa_chord_factor(v1, v2, freq) = sph_dist(
|
|
158
|
-
icosa_class1(geo_tri2_tri3( [v1[0], v1[1], freq])),
|
|
159
|
-
icosa_class1(geo_tri2_tri3( [v2[0], v2[1], freq]))
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
|
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
include <maths_geodesic.scad>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// Information about platonic solids
|
|
5
|
-
// This information is useful in constructing the various solids
|
|
6
|
-
// can be found here: http://en.wikipedia.org/wiki/Platonic_solid
|
|
7
|
-
// V - vertices
|
|
8
|
-
// E - edges
|
|
9
|
-
// F - faces
|
|
10
|
-
// number, V, E, F, schlafli symbol, dihedral angle, element, name
|
|
11
|
-
//tetrahedron = [1, 4, 6, 4, [3,3], 70.5333, "fire", "tetrahedron"];
|
|
12
|
-
//hexahedron = [2, 8, 12, 6, [4,3], 90, "earth", "cube"];
|
|
13
|
-
//octahedron = [3, 6, 12, 8, [3,4], 109.467, "air", "air"];
|
|
14
|
-
//dodecahedron = [4, 20, 30, 12, [5,3], 116.565, "ether", "universe"];
|
|
15
|
-
//icosahedron = [5, 12, 30, 20, [3,5], 138.190, "water", "water"];
|
|
16
|
-
|
|
17
|
-
// Schlafli representation for the platonic solids
|
|
18
|
-
// Given this representation, we have enough information
|
|
19
|
-
// to derive a number of other attributes of the solids
|
|
20
|
-
tetra_sch = [3,3];
|
|
21
|
-
hexa_sch = [4,3];
|
|
22
|
-
octa_sch = [3,4];
|
|
23
|
-
dodeca_sch = [5,3];
|
|
24
|
-
icosa_sch = [3,5];
|
|
25
|
-
|
|
26
|
-
// Given the schlafli representation, calculate
|
|
27
|
-
// the number of edges, vertices, and faces for the solid
|
|
28
|
-
function plat_edges(pq) = (2*pq[0]*pq[1])/
|
|
29
|
-
((2*pq[0])-(pq[0]*pq[1])+(2*pq[1]));
|
|
30
|
-
function plat_vertices(pq) = (2*plat_edges(pq))/pq[1];
|
|
31
|
-
function plat_faces(pq) = (2*plat_edges(pq))/pq[0];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Calculate angular deficiency of each vertex in a platonic solid
|
|
35
|
-
// p - sides
|
|
36
|
-
// q - number of edges per vertex
|
|
37
|
-
//function angular_defect(pq) = 360 - (poly_single_interior_angle(pq)*pq[1]);
|
|
38
|
-
function plat_deficiency(pq) = DEGREES(2*Cpi - pq[1]*Cpi*(1-2/pq[0]));
|
|
39
|
-
|
|
40
|
-
function plat_dihedral(pq) = 2 * asin( cos(180/pq[1])/sin(180/pq[0]));
|
|
41
|
-
|
|
42
|
-
function plat_circumradius(pq, a) =
|
|
43
|
-
(a/2)*
|
|
44
|
-
tan(Cpi/pq[1])*
|
|
45
|
-
tan(plat_dihedral(pq)/2);
|
|
46
|
-
|
|
47
|
-
function plat_midradius(pq, a) =
|
|
48
|
-
(a/2)*
|
|
49
|
-
cot(Cpi/pq[0])*
|
|
50
|
-
tan(plat_dihedral(pq)/2);
|
|
51
|
-
|
|
52
|
-
function plat_inradius(pq,a) =
|
|
53
|
-
a/(2*tan(DEGREES(Cpi/pq[0])))*
|
|
54
|
-
sqrt((1-cos(plat_dihedral(pq)))/(1+cos(plat_dihedral(pq))));
|
|
55
|
-
|
|
56
|
-
//================================================
|
|
57
|
-
// Tetrahedron
|
|
58
|
-
//================================================
|
|
59
|
-
tetra_cart = [
|
|
60
|
-
[+1, +1, +1],
|
|
61
|
-
[-1, -1, +1],
|
|
62
|
-
[-1, +1, -1],
|
|
63
|
-
[+1, -1, -1]
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
function tetra_unit(rad=1) = [
|
|
67
|
-
sph_to_cart(sphu_from_cart(tetra_cart[0], rad)),
|
|
68
|
-
sph_to_cart(sphu_from_cart(tetra_cart[1], rad)),
|
|
69
|
-
sph_to_cart(sphu_from_cart(tetra_cart[2], rad)),
|
|
70
|
-
sph_to_cart(sphu_from_cart(tetra_cart[3], rad)),
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
tetrafaces = [
|
|
75
|
-
[0, 3, 1],
|
|
76
|
-
[0,1,2],
|
|
77
|
-
[2,1,3],
|
|
78
|
-
[0,2,3]
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
tetra_edges = [
|
|
82
|
-
[0,1],
|
|
83
|
-
[0,2],
|
|
84
|
-
[0,3],
|
|
85
|
-
[1,2],
|
|
86
|
-
[1,3],
|
|
87
|
-
[2,3],
|
|
88
|
-
];
|
|
89
|
-
|
|
90
|
-
function tetrahedron(rad=1) = [tetra_unit(rad), tetrafaces, tetra_edges];
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//================================================
|
|
94
|
-
// Hexahedron - Cube
|
|
95
|
-
//================================================
|
|
96
|
-
// vertices for a unit cube with sides of length 1
|
|
97
|
-
hexa_cart = [
|
|
98
|
-
[0.5, 0.5, 0.5],
|
|
99
|
-
[-0.5, 0.5, 0.5],
|
|
100
|
-
[-0.5, -0.5, 0.5],
|
|
101
|
-
[0.5, -0.5, 0.5],
|
|
102
|
-
[0.5, 0.5, -0.5],
|
|
103
|
-
[-0.5, 0.5, -0.5],
|
|
104
|
-
[-0.5, -0.5, -0.5],
|
|
105
|
-
[0.5, -0.5, -0.5],
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
function hexa_unit(rad=1) = [
|
|
109
|
-
sph_to_cart(sphu_from_cart(hexa_cart[0], rad)),
|
|
110
|
-
sph_to_cart(sphu_from_cart(hexa_cart[1], rad)),
|
|
111
|
-
sph_to_cart(sphu_from_cart(hexa_cart[2], rad)),
|
|
112
|
-
sph_to_cart(sphu_from_cart(hexa_cart[3], rad)),
|
|
113
|
-
sph_to_cart(sphu_from_cart(hexa_cart[4], rad)),
|
|
114
|
-
sph_to_cart(sphu_from_cart(hexa_cart[5], rad)),
|
|
115
|
-
sph_to_cart(sphu_from_cart(hexa_cart[6], rad)),
|
|
116
|
-
sph_to_cart(sphu_from_cart(hexa_cart[7], rad)),
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// enumerate the faces of a cube
|
|
121
|
-
// vertex order is clockwise winding
|
|
122
|
-
hexafaces = [
|
|
123
|
-
[0,3,2,1], // top
|
|
124
|
-
[0,1,5,4],
|
|
125
|
-
[1,2,6,5],
|
|
126
|
-
[2,3,7,6],
|
|
127
|
-
[3,0,4,7],
|
|
128
|
-
[4,5,6,7], // bottom
|
|
129
|
-
];
|
|
130
|
-
|
|
131
|
-
hexa_edges = [
|
|
132
|
-
[0,1],
|
|
133
|
-
[0,3],
|
|
134
|
-
[0,4],
|
|
135
|
-
[1,2],
|
|
136
|
-
[1,5],
|
|
137
|
-
[2,3],
|
|
138
|
-
[2,6],
|
|
139
|
-
[3,7],
|
|
140
|
-
[4,5],
|
|
141
|
-
[4,7],
|
|
142
|
-
[5,4],
|
|
143
|
-
[5,6],
|
|
144
|
-
[6,7],
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
function hexahedron(rad=1) =[hexa_unit(rad), hexafaces, hexa_edges];
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
//================================================
|
|
152
|
-
// Octahedron
|
|
153
|
-
//================================================
|
|
154
|
-
|
|
155
|
-
octa_cart = [
|
|
156
|
-
[+1, 0, 0], // + x axis
|
|
157
|
-
[-1, 0, 0], // - x axis
|
|
158
|
-
[0, +1, 0], // + y axis
|
|
159
|
-
[0, -1, 0], // - y axis
|
|
160
|
-
[0, 0, +1], // + z axis
|
|
161
|
-
[0, 0, -1] // - z axis
|
|
162
|
-
];
|
|
163
|
-
|
|
164
|
-
function octa_unit(rad=1) = [
|
|
165
|
-
sph_to_cart(sphu_from_cart(octa_cart[0], rad)),
|
|
166
|
-
sph_to_cart(sphu_from_cart(octa_cart[1], rad)),
|
|
167
|
-
sph_to_cart(sphu_from_cart(octa_cart[2], rad)),
|
|
168
|
-
sph_to_cart(sphu_from_cart(octa_cart[3], rad)),
|
|
169
|
-
sph_to_cart(sphu_from_cart(octa_cart[4], rad)),
|
|
170
|
-
sph_to_cart(sphu_from_cart(octa_cart[5], rad)),
|
|
171
|
-
];
|
|
172
|
-
|
|
173
|
-
octafaces = [
|
|
174
|
-
[4,2,0],
|
|
175
|
-
[4,0,3],
|
|
176
|
-
[4,3,1],
|
|
177
|
-
[4,1,2],
|
|
178
|
-
[5,0,2],
|
|
179
|
-
[5,3,0],
|
|
180
|
-
[5,1,3],
|
|
181
|
-
[5,2,1]
|
|
182
|
-
];
|
|
183
|
-
|
|
184
|
-
octa_edges = [
|
|
185
|
-
[0,2],
|
|
186
|
-
[0,3],
|
|
187
|
-
[0,4],
|
|
188
|
-
[0,5],
|
|
189
|
-
[1,2],
|
|
190
|
-
[1,3],
|
|
191
|
-
[1,4],
|
|
192
|
-
[1,5],
|
|
193
|
-
[2,4],
|
|
194
|
-
[2,5],
|
|
195
|
-
[3,4],
|
|
196
|
-
[3,5],
|
|
197
|
-
];
|
|
198
|
-
|
|
199
|
-
function octahedron(rad=1) = [octa_unit(rad), octafaces, octa_edges];
|
|
200
|
-
|
|
201
|
-
//================================================
|
|
202
|
-
// Dodecahedron
|
|
203
|
-
//================================================
|
|
204
|
-
// (+-1, +-1, +-1)
|
|
205
|
-
// (0, +-1/Cphi, +-Cphi)
|
|
206
|
-
// (+-1/Cphi, +-Cphi, 0)
|
|
207
|
-
// (+-Cphi, 0, +-1/Cphi)
|
|
208
|
-
|
|
209
|
-
dodeca_cart = [
|
|
210
|
-
[+1, +1, +1], // 0, 0
|
|
211
|
-
[+1, -1, +1], // 0, 1
|
|
212
|
-
[-1, -1, +1], // 0, 2
|
|
213
|
-
[-1, +1, +1], // 0, 3
|
|
214
|
-
|
|
215
|
-
[+1, +1, -1], // 1, 4
|
|
216
|
-
[-1, +1, -1], // 1, 5
|
|
217
|
-
[-1, -1, -1], // 1, 6
|
|
218
|
-
[+1, -1, -1], // 1, 7
|
|
219
|
-
|
|
220
|
-
[0, +1/Cphi, +Cphi], // 2, 8
|
|
221
|
-
[0, -1/Cphi, +Cphi], // 2, 9
|
|
222
|
-
[0, -1/Cphi, -Cphi], // 2, 10
|
|
223
|
-
[0, +1/Cphi, -Cphi], // 2, 11
|
|
224
|
-
|
|
225
|
-
[-1/Cphi, +Cphi, 0], // 3, 12
|
|
226
|
-
[+1/Cphi, +Cphi, 0], // 3, 13
|
|
227
|
-
[+1/Cphi, -Cphi, 0], // 3, 14
|
|
228
|
-
[-1/Cphi, -Cphi, 0], // 3, 15
|
|
229
|
-
|
|
230
|
-
[-Cphi, 0, +1/Cphi], // 4, 16
|
|
231
|
-
[+Cphi, 0, +1/Cphi], // 4, 17
|
|
232
|
-
[+Cphi, 0, -1/Cphi], // 4, 18
|
|
233
|
-
[-Cphi, 0, -1/Cphi], // 4, 19
|
|
234
|
-
];
|
|
235
|
-
|
|
236
|
-
function dodeca_unit(rad=1) = [
|
|
237
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[0], rad)),
|
|
238
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[1], rad)),
|
|
239
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[2], rad)),
|
|
240
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[3], rad)),
|
|
241
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[4], rad)),
|
|
242
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[5], rad)),
|
|
243
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[6], rad)),
|
|
244
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[7], rad)),
|
|
245
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[8], rad)),
|
|
246
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[9], rad)),
|
|
247
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[10], rad)),
|
|
248
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[11], rad)),
|
|
249
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[12], rad)),
|
|
250
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[13], rad)),
|
|
251
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[14], rad)),
|
|
252
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[15], rad)),
|
|
253
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[16], rad)),
|
|
254
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[17], rad)),
|
|
255
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[18], rad)),
|
|
256
|
-
sph_to_cart(sphu_from_cart(dodeca_cart[19], rad)),
|
|
257
|
-
];
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
// These are the pentagon faces
|
|
262
|
-
// but CGAL has a problem rendering if things are
|
|
263
|
-
// not EXACTLY coplanar
|
|
264
|
-
// so use the triangle faces instead
|
|
265
|
-
//dodeca_faces=[
|
|
266
|
-
// [1,9,8,0,17],
|
|
267
|
-
// [9,1,14,15,2],
|
|
268
|
-
// [9,2,16,3,8],
|
|
269
|
-
// [8,3,12,13,0],
|
|
270
|
-
// [0,13,4,18,17],
|
|
271
|
-
// [1,17,18,7,14],
|
|
272
|
-
// [15,14,7,10,6],
|
|
273
|
-
// [2,15,6,19,16],
|
|
274
|
-
// [16,19,5,12,3],
|
|
275
|
-
// [12,5,11,4,13],
|
|
276
|
-
// [18,4,11,10,7],
|
|
277
|
-
// [19,6,10,11,5]
|
|
278
|
-
// ];
|
|
279
|
-
dodeca_faces = [
|
|
280
|
-
[1,9,8],
|
|
281
|
-
[1,8,0],
|
|
282
|
-
[1,0,17],
|
|
283
|
-
|
|
284
|
-
[9,1,14],
|
|
285
|
-
[9,14,15],
|
|
286
|
-
[9,15,2],
|
|
287
|
-
|
|
288
|
-
[9,2,16],
|
|
289
|
-
[9,16,3],
|
|
290
|
-
[9,3,8],
|
|
291
|
-
|
|
292
|
-
[8,3,12],
|
|
293
|
-
[8,12,13],
|
|
294
|
-
[8,13,0],
|
|
295
|
-
|
|
296
|
-
[0,13,4],
|
|
297
|
-
[0,4,18],
|
|
298
|
-
[0,18,17],
|
|
299
|
-
|
|
300
|
-
[1,17,18],
|
|
301
|
-
[1,18,7],
|
|
302
|
-
[1,7,14],
|
|
303
|
-
|
|
304
|
-
[15,14,7],
|
|
305
|
-
[15,7,10],
|
|
306
|
-
[15,10,6],
|
|
307
|
-
|
|
308
|
-
[2,15,6],
|
|
309
|
-
[2,6,19],
|
|
310
|
-
[2,19,16],
|
|
311
|
-
|
|
312
|
-
[16,19,5],
|
|
313
|
-
[16,5,12],
|
|
314
|
-
[16,12,3],
|
|
315
|
-
|
|
316
|
-
[12,5,11],
|
|
317
|
-
[12,11,4],
|
|
318
|
-
[12,4,13],
|
|
319
|
-
|
|
320
|
-
[18,4,11],
|
|
321
|
-
[18,11,10],
|
|
322
|
-
[18,10,7],
|
|
323
|
-
|
|
324
|
-
[19,6,10],
|
|
325
|
-
[19,10,11],
|
|
326
|
-
[19,11,5]
|
|
327
|
-
];
|
|
328
|
-
|
|
329
|
-
dodeca_edges=[
|
|
330
|
-
[0,8],
|
|
331
|
-
[0,13],
|
|
332
|
-
[0,17],
|
|
333
|
-
|
|
334
|
-
[1,9],
|
|
335
|
-
[1,14],
|
|
336
|
-
[1,17],
|
|
337
|
-
|
|
338
|
-
[2,9],
|
|
339
|
-
[2,15],
|
|
340
|
-
[2,16],
|
|
341
|
-
|
|
342
|
-
[3,8],
|
|
343
|
-
[3,12],
|
|
344
|
-
[3,16],
|
|
345
|
-
|
|
346
|
-
[4,11],
|
|
347
|
-
[4,13],
|
|
348
|
-
[4,18],
|
|
349
|
-
|
|
350
|
-
[5,11],
|
|
351
|
-
[5,12],
|
|
352
|
-
[5,19],
|
|
353
|
-
|
|
354
|
-
[6,10],
|
|
355
|
-
[6,15],
|
|
356
|
-
[6,19],
|
|
357
|
-
|
|
358
|
-
[7,10],
|
|
359
|
-
[7,14],
|
|
360
|
-
[7,18],
|
|
361
|
-
|
|
362
|
-
[8,9],
|
|
363
|
-
[10,11],
|
|
364
|
-
[12,13],
|
|
365
|
-
[14,15],
|
|
366
|
-
[16,19],
|
|
367
|
-
[17,18],
|
|
368
|
-
];
|
|
369
|
-
|
|
370
|
-
function dodecahedron(rad=1) = [dodeca_unit(rad), dodeca_faces, dodeca_edges];
|
|
371
|
-
|
|
372
|
-
//================================================
|
|
373
|
-
// Icosahedron
|
|
374
|
-
//================================================
|
|
375
|
-
//
|
|
376
|
-
// (0, +-1, +-Cphi)
|
|
377
|
-
// (+-Cphi, 0, +-1)
|
|
378
|
-
// (+-1, +-Cphi, 0)
|
|
379
|
-
|
|
380
|
-
icosa_cart = [
|
|
381
|
-
[0, +1, +Cphi], // 0
|
|
382
|
-
[0, +1, -Cphi], // 1
|
|
383
|
-
[0, -1, -Cphi], // 2
|
|
384
|
-
[0, -1, +Cphi], // 3
|
|
385
|
-
|
|
386
|
-
[+Cphi, 0, +1], // 4
|
|
387
|
-
[+Cphi, 0, -1], // 5
|
|
388
|
-
[-Cphi, 0, -1], // 6
|
|
389
|
-
[-Cphi, 0, +1], // 7
|
|
390
|
-
|
|
391
|
-
[+1, +Cphi, 0], // 8
|
|
392
|
-
[+1, -Cphi, 0], // 9
|
|
393
|
-
[-1, -Cphi, 0], // 10
|
|
394
|
-
[-1, +Cphi, 0] // 11
|
|
395
|
-
];
|
|
396
|
-
|
|
397
|
-
function icosa_sph(rad=1) = [
|
|
398
|
-
sphu_from_cart(icosa_cart[0], rad),
|
|
399
|
-
sphu_from_cart(icosa_cart[1], rad),
|
|
400
|
-
sphu_from_cart(icosa_cart[2], rad),
|
|
401
|
-
sphu_from_cart(icosa_cart[3], rad),
|
|
402
|
-
sphu_from_cart(icosa_cart[4], rad),
|
|
403
|
-
sphu_from_cart(icosa_cart[5], rad),
|
|
404
|
-
sphu_from_cart(icosa_cart[6], rad),
|
|
405
|
-
sphu_from_cart(icosa_cart[7], rad),
|
|
406
|
-
sphu_from_cart(icosa_cart[8], rad),
|
|
407
|
-
sphu_from_cart(icosa_cart[9], rad),
|
|
408
|
-
sphu_from_cart(icosa_cart[10], rad),
|
|
409
|
-
sphu_from_cart(icosa_cart[11], rad),
|
|
410
|
-
];
|
|
411
|
-
|
|
412
|
-
function icosa_unit(rad=1) = [
|
|
413
|
-
sph_to_cart(sphu_from_cart(icosa_cart[0], rad)),
|
|
414
|
-
sph_to_cart(sphu_from_cart(icosa_cart[1], rad)),
|
|
415
|
-
sph_to_cart(sphu_from_cart(icosa_cart[2], rad)),
|
|
416
|
-
sph_to_cart(sphu_from_cart(icosa_cart[3], rad)),
|
|
417
|
-
sph_to_cart(sphu_from_cart(icosa_cart[4], rad)),
|
|
418
|
-
sph_to_cart(sphu_from_cart(icosa_cart[5], rad)),
|
|
419
|
-
sph_to_cart(sphu_from_cart(icosa_cart[6], rad)),
|
|
420
|
-
sph_to_cart(sphu_from_cart(icosa_cart[7], rad)),
|
|
421
|
-
sph_to_cart(sphu_from_cart(icosa_cart[8], rad)),
|
|
422
|
-
sph_to_cart(sphu_from_cart(icosa_cart[9], rad)),
|
|
423
|
-
sph_to_cart(sphu_from_cart(icosa_cart[10], rad)),
|
|
424
|
-
sph_to_cart(sphu_from_cart(icosa_cart[11], rad)),
|
|
425
|
-
];
|
|
426
|
-
|
|
427
|
-
icosa_faces = [
|
|
428
|
-
[3,0,4],
|
|
429
|
-
[3,4,9],
|
|
430
|
-
[3,9,10],
|
|
431
|
-
[3,10,7],
|
|
432
|
-
[3,7,0],
|
|
433
|
-
[0,8,4],
|
|
434
|
-
[0,7,11],
|
|
435
|
-
[0,11,8],
|
|
436
|
-
[4,8,5],
|
|
437
|
-
[4,5,9],
|
|
438
|
-
[7,10,6],
|
|
439
|
-
[7,6,11],
|
|
440
|
-
[9,5,2],
|
|
441
|
-
[9,2,10],
|
|
442
|
-
[2,6,10],
|
|
443
|
-
[1,5,8],
|
|
444
|
-
[1,8,11],
|
|
445
|
-
[1,11,6],
|
|
446
|
-
[5,1,2],
|
|
447
|
-
[2,1,6]
|
|
448
|
-
];
|
|
449
|
-
|
|
450
|
-
icosa_edges = [
|
|
451
|
-
[0,3],
|
|
452
|
-
[0,4],
|
|
453
|
-
[0,7],
|
|
454
|
-
[0,8],
|
|
455
|
-
[0,11],
|
|
456
|
-
[1,5],
|
|
457
|
-
[1,8],
|
|
458
|
-
[1,11],
|
|
459
|
-
[1,6],
|
|
460
|
-
[1,2],
|
|
461
|
-
[2,5],
|
|
462
|
-
[2,6],
|
|
463
|
-
[2,9],
|
|
464
|
-
[2,10],
|
|
465
|
-
[3,4],
|
|
466
|
-
[3,9],
|
|
467
|
-
[3,10],
|
|
468
|
-
[3,7],
|
|
469
|
-
[4,5],
|
|
470
|
-
[4,8],
|
|
471
|
-
[4,9],
|
|
472
|
-
[5,8],
|
|
473
|
-
[5,9],
|
|
474
|
-
[6,7],
|
|
475
|
-
[6,10],
|
|
476
|
-
[6,11],
|
|
477
|
-
[7,10],
|
|
478
|
-
[7,11],
|
|
479
|
-
[8,11],
|
|
480
|
-
[9,10],
|
|
481
|
-
];
|
|
482
|
-
|
|
483
|
-
function icosahedron(rad=1) = [icosa_unit(rad), icosa_faces, icosa_edges];
|