omdl  v0.6.1
OpenSCAD Mechanical Design Library
platonic.scad
Go to the documentation of this file.
1 //! Table of polyhedra data group: \c platonic
2 /***************************************************************************//**
3  \file platonic.scad
4  \author Roy Allen Sutton
5  \date 2017
6 
7  \copyright
8 
9  This file is part of [omdl] (https://github.com/royasutton/omdl),
10  an OpenSCAD mechanical design library.
11 
12  The \em omdl is free software; you can redistribute it and/or modify
13  it under the terms of the [GNU Lesser General Public License]
14  (http://www.gnu.org/licenses/lgpl.html) as published by the Free
15  Software Foundation; either version 2.1 of the License, or (at
16  your option) any later version.
17 
18  The \em omdl is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with the \em omdl; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301, USA; or see <http://www.gnu.org/licenses/>.
27 
28  \details
29 
30  This [omdl] formatted data table has been assembled using a script
31  that converts the polyhedra data obtained from [Anthony Thyssen]'s
32  [Studies into Polyhedra]. The vertices are tabulated in both their
33  original Cartesian as well as their converted spherical coordinate
34  form, which is convenient when scaling. The data originates from
35  one of three sources:
36 
37  \li [Exact Mathematics] as presented by [Anthony Thyssen],
38  \li the [Polyhedron Database] maintained by [Netlib], and
39  \li an [Encyclopedia of Polyhedra] by [George W. Hart].
40 
41  \note Include this library file using the \b include statement.
42 
43  [omdl]: https://github.com/royasutton/omdl
44 
45  [Anthony Thyssen]: http://www.ict.griffith.edu.au/anthony/anthony.html
46  [Studies into Polyhedra]: http://www.ict.griffith.edu.au/anthony/graphics/polyhedra
47  [Exact Mathematics]: http://www.ict.griffith.edu.au/anthony/graphics/polyhedra/maths.shtml
48 
49  [George W. Hart]: http://www.georgehart.com
50  [Encyclopedia of Polyhedra]: http://www.georgehart.com/virtual-polyhedra/vp.html
51 
52  [Netlib]: http://www.netlib.org
53  [Polyhedron Database]: http://www.netlib.org/polyhedra
54 
55  \ingroup database_polyhedra
56 *******************************************************************************/
57 
58 //----------------------------------------------------------------------------//
59 /***************************************************************************//**
60  \addtogroup database_polyhedra
61  @{
62  <br>
63  ### Group: platonic ###
64 
65  \amu_define caption (platonic)
66  \amu_make png_files (append=db_dim extension=png)
67  \amu_make stl_files (append=db_dim extension=stl)
68 
69  \amu_shell file_cnt ("echo ${png_files} | wc -w")
70  \amu_shell cell_num ("seq -f '(%g)' -s '^' ${file_cnt}")
71 
72  \amu_shell html_cell_titles
73  (
74  "echo ${stl_files} | grep -Po 'db_dim_\K[^.]*' | tr '\n' '^'"
75  )
76 
77  \htmlonly
78  \amu_image_table
79  (
80  type=html columns=4 image_width="200" cell_files="${png_files}"
81  table_caption="${caption}" cell_captions="${cell_num}"
82  cell_titles="${html_cell_titles}" cell_urls="${stl_files}"
83  )
84  \endhtmlonly
85 
86  \amu_define caption (platonic)
87  \amu_make eps_files (append=db_dim extension=png2eps)
88 
89  \latexonly
90  \amu_image_table
91  (
92  type=latex columns=4 image_width="1.25in" cell_files="${eps_files}"
93  table_caption="${caption}" cell_captions="${cell_num}"
94  )
95  \endlatexonly
96 
97  \amu_shell data
98  (
99  "grep -Po 'ECHO: \"\K[^\"]*' build/csg/platonic_db_autostat.log" --rmnl
100  )
101  \amu_shell columns ("echo '${data}' | awk -F '^' 'NR==1 {print NF;exit}'")
102  \amu_shell heading ("echo '${data}' | awk -F '^' 'NR==1 {print;exit}'")
103  \amu_shell texts ("echo '${data}' | awk -F '^' 'NR>1 {print}'")
104 
105  \amu_table
106  (
107  columns=${columns} column_headings="${heading}" cell_texts="${texts}"
108  )
109 *******************************************************************************/
110 //----------------------------------------------------------------------------//
111 
112 //! <matrix-2x9> \c platonic polyhedra data table columns definition.
113 //! \hideinitializer
115 [
116  ["id", "identifier"],
117  ["n", "name"],
118  ["o", "other name"],
119  ["g", "group"],
120  ["d", "data source"],
121  ["c", "cartesian vertices"],
122  ["s", "spherical vertices"],
123  ["f", "faces"],
124  ["e", "edges"]
125 ];
126 
127 //! <matrix-9xR> \c platonic polyhedra data table rows.
128 //! \hideinitializer
130 [
131  [
132  "cube",
133  "Cube",
134  "Hexahedron",
135  "platonic",
136  "Exact Mathematics",
137  [
138  [ 1.00000000000, 1.00000000000, 1.00000000000],
139  [ 1.00000000000, 1.00000000000, -1.00000000000],
140  [ 1.00000000000, -1.00000000000, 1.00000000000],
141  [ 1.00000000000, -1.00000000000, -1.00000000000],
142  [-1.00000000000, 1.00000000000, 1.00000000000],
143  [-1.00000000000, 1.00000000000, -1.00000000000],
144  [-1.00000000000, -1.00000000000, 1.00000000000],
145  [-1.00000000000, -1.00000000000, -1.00000000000]
146  ],
147  [
148  [1.73205080757, 45.00000000000, 54.73561031724],
149  [1.73205080757, 45.00000000000, 125.26438968275],
150  [1.73205080757, -45.00000000000, 54.73561031724],
151  [1.73205080757, -45.00000000000, 125.26438968275],
152  [1.73205080757, 134.99999999999, 54.73561031724],
153  [1.73205080757, 134.99999999999, 125.26438968275],
154  [1.73205080757, -134.99999999999, 54.73561031724],
155  [1.73205080757, -134.99999999999, 125.26438968275]
156  ],
157  [
158  [6,4,0,2],
159  [5,1,0,4],
160  [7,5,4,6],
161  [1,3,2,0],
162  [3,7,6,2],
163  [7,3,1,5]
164  ],
165  [
166  [0,1],
167  [0,2],
168  [0,4],
169  [1,3],
170  [1,5],
171  [2,3],
172  [2,6],
173  [3,7],
174  [4,5],
175  [4,6],
176  [5,7],
177  [6,7]
178  ]
179  ],
180  [
181  "dodecahedron",
182  "Dodecahedron",
183  empty_str,
184  "platonic",
185  "Exact Mathematics",
186  [
187  [ 0.57735026919, 0.57735026919, 0.57735026919],
188  [-0.00000000000, 0.93417235896, -0.35682208977],
189  [-0.57735026919, 0.57735026919, 0.57735026919],
190  [-0.00000000000, 0.93417235896, 0.35682208977],
191  [-0.93417235896, 0.35682208977, -0.00000000000],
192  [-0.57735026919, 0.57735026919, -0.57735026919],
193  [ 0.93417235896, -0.35682208977, -0.00000000000],
194  [ 0.93417235896, 0.35682208977, -0.00000000000],
195  [ 0.57735026919, 0.57735026919, -0.57735026919],
196  [ 0.57735026919, -0.57735026919, 0.57735026919],
197  [ 0.35682208977, 0.00000000000, 0.93417235896],
198  [-0.35682208977, 0.00000000000, 0.93417235896],
199  [-0.93417235896, -0.35682208977, -0.00000000000],
200  [-0.57735026919, -0.57735026919, 0.57735026919],
201  [-0.00000000000, -0.93417235896, 0.35682208977],
202  [ 0.35682208977, 0.00000000000, -0.93417235896],
203  [ 0.57735026919, -0.57735026919, -0.57735026919],
204  [-0.00000000000, -0.93417235896, -0.35682208977],
205  [-0.35682208977, 0.00000000000, -0.93417235896],
206  [-0.57735026919, -0.57735026919, -0.57735026919]
207  ],
208  [
209  [1.00000000000, 45.00000000000, 54.73561031724],
210  [1.00000000000, 89.99999999999, 110.90515744788],
211  [1.00000000000, 134.99999999999, 54.73561031724],
212  [1.00000000000, 89.99999999999, 69.09484255211],
213  [1.00000000000, 159.09484255210, 89.99999999999],
214  [1.00000000000, 134.99999999999, 125.26438968275],
215  [1.00000000000, -20.90515744789, 89.99999999999],
216  [1.00000000000, 20.90515744789, 89.99999999999],
217  [1.00000000000, 45.00000000000, 125.26438968275],
218  [1.00000000000, -45.00000000000, 54.73561031724],
219  [1.00000000000, 0.00000000000, 20.90515744789],
220  [1.00000000000, 179.99999999999, 20.90515744789],
221  [1.00000000000, -159.09484255210, 89.99999999999],
222  [1.00000000000, -134.99999999999, 54.73561031724],
223  [1.00000000000, -89.99999999999, 69.09484255211],
224  [1.00000000000, 0.00000000000, 159.09484255210],
225  [1.00000000000, -45.00000000000, 125.26438968275],
226  [1.00000000000, -89.99999999999, 110.90515744788],
227  [1.00000000000, 179.99999999999, 159.09484255210],
228  [1.00000000000, -134.99999999999, 125.26438968275]
229  ],
230  [
231  [2,4,5,1,3],
232  [0,7,6,9,10],
233  [8,15,16,6,7],
234  [8,7,0,3,1],
235  [5,18,15,8,1],
236  [0,10,11,2,3],
237  [6,16,17,14,9],
238  [11,13,12,4,2],
239  [11,10,9,14,13],
240  [19,17,16,15,18],
241  [19,12,13,14,17],
242  [18,5,4,12,19]
243  ],
244  [
245  [0,3],
246  [0,7],
247  [0,10],
248  [1,3],
249  [1,5],
250  [1,8],
251  [2,3],
252  [2,4],
253  [2,11],
254  [4,5],
255  [4,12],
256  [5,18],
257  [6,7],
258  [6,9],
259  [6,16],
260  [7,8],
261  [8,15],
262  [9,10],
263  [9,14],
264  [10,11],
265  [11,13],
266  [12,13],
267  [12,19],
268  [13,14],
269  [14,17],
270  [15,16],
271  [15,18],
272  [16,17],
273  [17,19],
274  [18,19]
275  ]
276  ],
277  [
278  "icosahedron",
279  "Icosahedron",
280  empty_str,
281  "platonic",
282  "Exact Mathematics",
283  [
284  [-1.00000000000, 0.00000000000, 0.61803398875],
285  [ 1.00000000000, 0.00000000000, 0.61803398875],
286  [-1.00000000000, 0.00000000000, -0.61803398875],
287  [ 1.00000000000, 0.00000000000, -0.61803398875],
288  [ 0.00000000000, 0.61803398875, 1.00000000000],
289  [ 0.00000000000, 0.61803398875, -1.00000000000],
290  [ 0.00000000000, -0.61803398875, 1.00000000000],
291  [ 0.00000000000, -0.61803398875, -1.00000000000],
292  [ 0.61803398875, 1.00000000000, 0.00000000000],
293  [-0.61803398875, 1.00000000000, 0.00000000000],
294  [ 0.61803398875, -1.00000000000, 0.00000000000],
295  [-0.61803398875, -1.00000000000, 0.00000000000]
296  ],
297  [
298  [1.17557050458, 179.99999999999, 58.28252558853],
299  [1.17557050458, 0.00000000000, 58.28252558853],
300  [1.17557050458, 179.99999999999, 121.71747441145],
301  [1.17557050458, 0.00000000000, 121.71747441145],
302  [1.17557050458, 89.99999999999, 31.71747441146],
303  [1.17557050458, 89.99999999999, 148.28252558853],
304  [1.17557050458, -89.99999999999, 31.71747441146],
305  [1.17557050458, -89.99999999999, 148.28252558853],
306  [1.17557050458, 58.28252558853, 89.99999999999],
307  [1.17557050458, 121.71747441145, 89.99999999999],
308  [1.17557050458, -58.28252558853, 89.99999999999],
309  [1.17557050458, -121.71747441145, 89.99999999999]
310  ],
311  [
312  [4,8,1],
313  [10,6,1],
314  [4,6,0],
315  [6,4,1],
316  [8,3,1],
317  [3,10,1],
318  [4,9,8],
319  [2,9,0],
320  [9,4,0],
321  [11,6,10],
322  [11,2,0],
323  [6,11,0],
324  [5,3,8],
325  [9,5,8],
326  [5,9,2],
327  [3,7,10],
328  [7,11,10],
329  [11,7,2],
330  [7,5,2],
331  [5,7,3]
332  ],
333  [
334  [0,2],
335  [0,4],
336  [0,6],
337  [0,9],
338  [0,11],
339  [1,3],
340  [1,4],
341  [1,6],
342  [1,8],
343  [1,10],
344  [2,5],
345  [2,7],
346  [2,9],
347  [2,11],
348  [3,5],
349  [3,7],
350  [3,8],
351  [3,10],
352  [4,6],
353  [4,8],
354  [4,9],
355  [5,7],
356  [5,8],
357  [5,9],
358  [6,10],
359  [6,11],
360  [7,10],
361  [7,11],
362  [8,9],
363  [10,11]
364  ]
365  ],
366  [
367  "octahedron",
368  "Octahedron",
369  empty_str,
370  "platonic",
371  "Exact Mathematics",
372  [
373  [ 0.00000000000, 0.00000000000, 1.00000000000],
374  [ 0.00000000000, 1.00000000000, 0.00000000000],
375  [-1.00000000000, 0.00000000000, 0.00000000000],
376  [ 1.00000000000, 0.00000000000, 0.00000000000],
377  [ 0.00000000000, -1.00000000000, 0.00000000000],
378  [ 0.00000000000, 0.00000000000, -1.00000000000]
379  ],
380  [
381  [1.00000000000, 0.00000000000, 0.00000000000],
382  [1.00000000000, 89.99999999999, 89.99999999999],
383  [1.00000000000, 179.99999999999, 89.99999999999],
384  [1.00000000000, 0.00000000000, 89.99999999999],
385  [1.00000000000, -89.99999999999, 89.99999999999],
386  [1.00000000000, 0.00000000000, 179.99999999999]
387  ],
388  [
389  [1,0,2],
390  [0,1,3],
391  [5,1,2],
392  [1,5,3],
393  [4,0,3],
394  [0,4,2],
395  [4,5,2],
396  [5,4,3]
397  ],
398  [
399  [0,1],
400  [0,2],
401  [0,3],
402  [0,4],
403  [1,2],
404  [1,3],
405  [2,4],
406  [3,4],
407  [1,5],
408  [2,5],
409  [3,5],
410  [4,5]
411  ]
412  ],
413  [
414  "tetrahedron",
415  "Tetrahedron",
416  empty_str,
417  "platonic",
418  "Exact Mathematics",
419  [
420  [ 1.00000000000, 1.00000000000, -1.00000000000],
421  [-1.00000000000, 1.00000000000, 1.00000000000],
422  [ 1.00000000000, -1.00000000000, 1.00000000000],
423  [-1.00000000000, -1.00000000000, -1.00000000000]
424  ],
425  [
426  [1.73205080757, 45.00000000000, 125.26438968275],
427  [1.73205080757, 134.99999999999, 54.73561031724],
428  [1.73205080757, -45.00000000000, 54.73561031724],
429  [1.73205080757, -134.99999999999, 125.26438968275]
430  ],
431  [
432  [0,2,1],
433  [3,0,1],
434  [2,3,1],
435  [3,2,0]
436  ],
437  [
438  [0,1],
439  [0,2],
440  [0,3],
441  [1,2],
442  [1,3],
443  [2,3]
444  ]
445  ]
446 ];
447 
448 //! @}
449 
450 //----------------------------------------------------------------------------//
451 // openscad-amu auxiliary scripts
452 //----------------------------------------------------------------------------//
453 
454 /*
455 BEGIN_SCOPE db;
456 BEGIN_SCOPE autostat;
457  BEGIN_OPENSCAD;
458  include <math/math_polytope.scad>;
459  include <math/math_utility.scad>;
460  include <datatypes/datatypes_table.scad>;
461  include <database/geometry/polyhedra/platonic.scad>;
462 
463  fs = "^";
464 
465  tc = dtc_polyhedra_platonic;
466  tr = dtr_polyhedra_platonic;
467 
468  ids = get_table_ridl(tr);
469 
470  echo
471  (
472  str
473  (
474  "no.", fs, "table id", fs, "other name", fs,
475  "vertices", fs, "faces", fs, "edges",
476 
477  fs, "face-verticies",
478  fs, "face-angles",
479  fs, "edge-lengths",
480  fs, "edge-angles"
481  )
482  );
483 
484  for ( id = ids )
485  {
486  i = first(find(id, ids, c=1))+1;
487 
488  n = get_table_v(tr, tc, id, "n");
489  o = get_table_v(tr, tc, id, "o");
490  g = get_table_v(tr, tc, id, "g");
491  d = get_table_v(tr, tc, id, "d");
492 
493  c = get_table_v(tr, tc, id, "c");
494  s = get_table_v(tr, tc, id, "s");
495  f = get_table_v(tr, tc, id, "f");
496  e = get_table_v(tr, tc, id, "e");
497 
498  fo = is_empty(o) ? "-" : o;
499 
500  echo
501  (
502  str
503  (
504  i, fs, id, fs, fo, fs,
505  len(c), fs, len(f), fs, len(e),
506 
507  fs, hist(qsort(polytope_face_vcounts(f)), m=9),
508  fs, hist(qsort(dround(polytope_face_angles(c, f), d=1)), m=9),
509  fs, hist(qsort(sround(polytope_edge_lengths(c, e), d=3)), m=9),
510  fs, hist(qsort(dround(polytope_edge_angles(c, f), d=1)), m=9),
511 
512  fs
513  )
514  );
515  }
516  END_OPENSCAD;
517 
518  BEGIN_MFSCRIPT;
519  include --path "${INCLUDE_PATH}" {config_base,config_csg}.mfs;
520  include --path "${INCLUDE_PATH}" script_std.mfs;
521  END_MFSCRIPT;
522 END_SCOPE;
523 END_SCOPE;
524 */
525 
526 /*
527 BEGIN_SCOPE db;
528 BEGIN_SCOPE dim;
529  BEGIN_OPENSCAD;
530  include <units/units_coordinate.scad>;
531  include <tools/tools_polytope.scad>;
532  include <datatypes/datatypes_table.scad>;
533  include <database/geometry/polyhedra/platonic.scad>;
534 
535  config = 0;
536 
537  tc = dtc_polyhedra_platonic;
538  tr = dtr_polyhedra_platonic;
539 
540  id = "default";
541  sr = 100;
542 
543  pv = get_table_v(tr, tc, id, "c");
544  pf = get_table_v(tr, tc, id, "f");
545  pe = get_table_v(tr, tc, id, "e");
546 
547  sv = coordinates_csc(pv, sr);
548 
549  if (config == 0) // png preview
550  {
551  $fn = 25;
552 
553  %polyhedron(sv, pf);
554 
555  polytope_frame(sv, pf, pe)
556  {
557  circle(r = sr / 25);
558  color("lightblue")
559  sphere(r = sr / 25 * (1 + 1/2));
560  }
561  }
562 
563  if (config == 1) // stl model
564  {
565  polyhedron(sv, pf);
566  }
567  END_OPENSCAD;
568 
569  BEGIN_MFSCRIPT;
570  include --path "${INCLUDE_PATH}" {config_base,config_png}.mfs;
571 
572  views name "views" views "diag";
573  defines name "ids" define "id"
574  strings
575  "
576  cube
577  dodecahedron
578  icosahedron
579  octahedron
580  tetrahedron
581  ";
582  variables add_opts_combine "views ids";
583  variables add_opts "-D config=0 --viewall --autocenter";
584 
585  include --path "${INCLUDE_PATH}" script_new.mfs;
586 
587  include --path "${INCLUDE_PATH}" config_stl.mfs;
588  variables add_opts_combine "ids";
589  variables add_opts "-D config=1";
590 
591  include --path "${INCLUDE_PATH}" script_app.mfs;
592  END_MFSCRIPT;
593 END_SCOPE;
594 END_SCOPE;
595 */
596 
597 //----------------------------------------------------------------------------//
598 // end of file
599 //----------------------------------------------------------------------------//
dtc_polyhedra_platonic
Definition: platonic.scad:114
empty_str
A string with no characters (the empty string).
Definition: constants.scad:77
dtr_polyhedra_platonic
Definition: platonic.scad:129