omdl  v1.0
OpenSCAD Mechanical Design Library
platonic.scad
Go to the documentation of this file.
1 //! Polyhedra data table: \c platonic.
2 /***************************************************************************//**
3  \file
4  \author Roy Allen Sutton
5  \date 2017-2023
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  [omdl]: https://github.com/royasutton/omdl
42 
43  [Anthony Thyssen]: http://www.ict.griffith.edu.au/anthony/anthony.html
44  [Studies into Polyhedra]: http://www.ict.griffith.edu.au/anthony/graphics/polyhedra
45 
46  [George W. Hart]: http://www.georgehart.com
47  [Encyclopedia of Polyhedra]: http://www.georgehart.com/virtual-polyhedra/vp.html
48 
49  [Netlib]: http://www.netlib.org
50  [Polyhedron Database]: http://www.netlib.org/polyhedra
51 
52  \amu_pathid parent (++path_parent)
53  \amu_pathid group (++path)
54 
55  \ingroup \amu_eval(${group})
56 *******************************************************************************/
57 
58 //----------------------------------------------------------------------------//
59 /***************************************************************************//**
60  \addtogroup \amu_eval(${group})
61  @{
62  <br>
63  ### Platonic ###
64  \amu_include (include/amu/includes_required.amu)
65 
66  \amu_eval
67  (
68  ++global
69  title="Examples"
70  stem=platonic scope=db_dim size=qvga view=diag
71  )
72 
73  \amu_define object_stem (${stem}_${scope}_${size}_${view}_${shape})
74  \amu_make files_png (append=db_dim extension=png)
75  \amu_make files_stl (append=db_dim extension=stl)
76  \amu_word files_cnt (words="${files_png}" ++count)
77  \amu_seq cell_num (prefix="(" suffix=")" last="${files_cnt}" ++number)
78  \amu_eval object_prefix (shape="" ${object_stem})
79  \amu_filename cell_txt (files="${files_png}" separator="^" ++stem)
80  \amu_replace cell_id (text="${cell_txt}" search="${object_prefix}" replace="id: ")
81  \amu_replace cell_end (text="${cell_txt}" search="${object_prefix}")
82  \amu_replace cell_end (text="${cell_end}" search="_" replace="<br>")
83  \amu_combine cell_end (p="<center>" s="</center>" j="" f="^" t="^" ${cell_end})
84 
85  \htmlonly
86  \amu_image_table
87  (
88  type=html columns=4 image_width="200" cell_files="${files_png}"
89  table_caption="${title}" cell_captions="${cell_num}"
90  cell_titles="${cell_id}" cell_end="${cell_end}"
91  cell_urls="${files_stl}"
92  )
93  \endhtmlonly
94 
95  \amu_make eps_files (append=db_dim extension=png2eps)
96 
97  \latexonly
98  \amu_image_table
99  (
100  type=latex columns=4 image_width="1.25in" cell_files="${eps_files}"
101  table_caption="${title}" cell_captions="${cell_num}"
102  )
103  \endlatexonly
104 
105  \b Autostats
106 
107  \amu_scope scope (index=1)
108  \amu_file heading (file="${scope}.log" last=1 ++rmecho ++rmnl ++read ++quiet)
109  \amu_file texts (file="${scope}.log" first=2 ++rmecho ++rmnl ++read ++quiet)
110  \amu_word columns (tokenizer="^" words="${heading}" ++count)
111 
112  \amu_table table
113  (
114  columns=${columns} column_headings="${heading}" cell_texts="${texts}"
115  )
116 
117  \amu_if ( -w ${heading} )
118  { ${table} }
119  else
120  { \note Statistics table not available. To build and include, remove
121  \c db_autostat from \c scopes_exclude in library makefile.
122  For more information see \ref lb. }
123  endif
124 *******************************************************************************/
125 //----------------------------------------------------------------------------//
126 
127 //! <map> \c platonic polyhedra data table columns definition.
128 //! \hideinitializer
130 [
131  ["id", "identifier"],
132  ["n", "name"],
133  ["o", "other name"],
134  ["g", "group"],
135  ["d", "data source"],
136  ["c", "cartesian vertices"],
137  ["s", "spherical vertices"],
138  ["f", "faces"],
139  ["e", "edges"]
140 ];
141 
142 //! <table> \c platonic polyhedra data table rows.
143 //! \hideinitializer
145 [
146  [
147  "cube",
148  "Cube",
149  "Hexahedron",
150  "platonic",
151  "Exact Mathematics",
152  [
153  [ 1.00000000000, 1.00000000000, 1.00000000000],
154  [ 1.00000000000, 1.00000000000, -1.00000000000],
155  [ 1.00000000000, -1.00000000000, 1.00000000000],
156  [ 1.00000000000, -1.00000000000, -1.00000000000],
157  [-1.00000000000, 1.00000000000, 1.00000000000],
158  [-1.00000000000, 1.00000000000, -1.00000000000],
159  [-1.00000000000, -1.00000000000, 1.00000000000],
160  [-1.00000000000, -1.00000000000, -1.00000000000]
161  ],
162  [
163  [1.73205080757, 45.00000000000, 54.73561031724],
164  [1.73205080757, 45.00000000000, 125.26438968275],
165  [1.73205080757, -45.00000000000, 54.73561031724],
166  [1.73205080757, -45.00000000000, 125.26438968275],
167  [1.73205080757, 134.99999999999, 54.73561031724],
168  [1.73205080757, 134.99999999999, 125.26438968275],
169  [1.73205080757, -134.99999999999, 54.73561031724],
170  [1.73205080757, -134.99999999999, 125.26438968275]
171  ],
172  [
173  [6,4,0,2],
174  [5,1,0,4],
175  [7,5,4,6],
176  [1,3,2,0],
177  [3,7,6,2],
178  [7,3,1,5]
179  ],
180  [
181  [0,1],
182  [0,2],
183  [0,4],
184  [1,3],
185  [1,5],
186  [2,3],
187  [2,6],
188  [3,7],
189  [4,5],
190  [4,6],
191  [5,7],
192  [6,7]
193  ]
194  ],
195  [
196  "dodecahedron",
197  "Dodecahedron",
198  empty_str,
199  "platonic",
200  "Exact Mathematics",
201  [
202  [ 0.57735026919, 0.57735026919, 0.57735026919],
203  [-0.00000000000, 0.93417235896, -0.35682208977],
204  [-0.57735026919, 0.57735026919, 0.57735026919],
205  [-0.00000000000, 0.93417235896, 0.35682208977],
206  [-0.93417235896, 0.35682208977, -0.00000000000],
207  [-0.57735026919, 0.57735026919, -0.57735026919],
208  [ 0.93417235896, -0.35682208977, -0.00000000000],
209  [ 0.93417235896, 0.35682208977, -0.00000000000],
210  [ 0.57735026919, 0.57735026919, -0.57735026919],
211  [ 0.57735026919, -0.57735026919, 0.57735026919],
212  [ 0.35682208977, 0.00000000000, 0.93417235896],
213  [-0.35682208977, 0.00000000000, 0.93417235896],
214  [-0.93417235896, -0.35682208977, -0.00000000000],
215  [-0.57735026919, -0.57735026919, 0.57735026919],
216  [-0.00000000000, -0.93417235896, 0.35682208977],
217  [ 0.35682208977, 0.00000000000, -0.93417235896],
218  [ 0.57735026919, -0.57735026919, -0.57735026919],
219  [-0.00000000000, -0.93417235896, -0.35682208977],
220  [-0.35682208977, 0.00000000000, -0.93417235896],
221  [-0.57735026919, -0.57735026919, -0.57735026919]
222  ],
223  [
224  [1.00000000000, 45.00000000000, 54.73561031724],
225  [1.00000000000, 89.99999999999, 110.90515744788],
226  [1.00000000000, 134.99999999999, 54.73561031724],
227  [1.00000000000, 89.99999999999, 69.09484255211],
228  [1.00000000000, 159.09484255210, 89.99999999999],
229  [1.00000000000, 134.99999999999, 125.26438968275],
230  [1.00000000000, -20.90515744789, 89.99999999999],
231  [1.00000000000, 20.90515744789, 89.99999999999],
232  [1.00000000000, 45.00000000000, 125.26438968275],
233  [1.00000000000, -45.00000000000, 54.73561031724],
234  [1.00000000000, 0.00000000000, 20.90515744789],
235  [1.00000000000, 179.99999999999, 20.90515744789],
236  [1.00000000000, -159.09484255210, 89.99999999999],
237  [1.00000000000, -134.99999999999, 54.73561031724],
238  [1.00000000000, -89.99999999999, 69.09484255211],
239  [1.00000000000, 0.00000000000, 159.09484255210],
240  [1.00000000000, -45.00000000000, 125.26438968275],
241  [1.00000000000, -89.99999999999, 110.90515744788],
242  [1.00000000000, 179.99999999999, 159.09484255210],
243  [1.00000000000, -134.99999999999, 125.26438968275]
244  ],
245  [
246  [2,4,5,1,3],
247  [0,7,6,9,10],
248  [8,15,16,6,7],
249  [8,7,0,3,1],
250  [5,18,15,8,1],
251  [0,10,11,2,3],
252  [6,16,17,14,9],
253  [11,13,12,4,2],
254  [11,10,9,14,13],
255  [19,17,16,15,18],
256  [19,12,13,14,17],
257  [18,5,4,12,19]
258  ],
259  [
260  [0,3],
261  [0,7],
262  [0,10],
263  [1,3],
264  [1,5],
265  [1,8],
266  [2,3],
267  [2,4],
268  [2,11],
269  [4,5],
270  [4,12],
271  [5,18],
272  [6,7],
273  [6,9],
274  [6,16],
275  [7,8],
276  [8,15],
277  [9,10],
278  [9,14],
279  [10,11],
280  [11,13],
281  [12,13],
282  [12,19],
283  [13,14],
284  [14,17],
285  [15,16],
286  [15,18],
287  [16,17],
288  [17,19],
289  [18,19]
290  ]
291  ],
292  [
293  "icosahedron",
294  "Icosahedron",
295  empty_str,
296  "platonic",
297  "Exact Mathematics",
298  [
299  [-1.00000000000, 0.00000000000, 0.61803398875],
300  [ 1.00000000000, 0.00000000000, 0.61803398875],
301  [-1.00000000000, 0.00000000000, -0.61803398875],
302  [ 1.00000000000, 0.00000000000, -0.61803398875],
303  [ 0.00000000000, 0.61803398875, 1.00000000000],
304  [ 0.00000000000, 0.61803398875, -1.00000000000],
305  [ 0.00000000000, -0.61803398875, 1.00000000000],
306  [ 0.00000000000, -0.61803398875, -1.00000000000],
307  [ 0.61803398875, 1.00000000000, 0.00000000000],
308  [-0.61803398875, 1.00000000000, 0.00000000000],
309  [ 0.61803398875, -1.00000000000, 0.00000000000],
310  [-0.61803398875, -1.00000000000, 0.00000000000]
311  ],
312  [
313  [1.17557050458, 179.99999999999, 58.28252558853],
314  [1.17557050458, 0.00000000000, 58.28252558853],
315  [1.17557050458, 179.99999999999, 121.71747441145],
316  [1.17557050458, 0.00000000000, 121.71747441145],
317  [1.17557050458, 89.99999999999, 31.71747441146],
318  [1.17557050458, 89.99999999999, 148.28252558853],
319  [1.17557050458, -89.99999999999, 31.71747441146],
320  [1.17557050458, -89.99999999999, 148.28252558853],
321  [1.17557050458, 58.28252558853, 89.99999999999],
322  [1.17557050458, 121.71747441145, 89.99999999999],
323  [1.17557050458, -58.28252558853, 89.99999999999],
324  [1.17557050458, -121.71747441145, 89.99999999999]
325  ],
326  [
327  [4,8,1],
328  [10,6,1],
329  [4,6,0],
330  [6,4,1],
331  [8,3,1],
332  [3,10,1],
333  [4,9,8],
334  [2,9,0],
335  [9,4,0],
336  [11,6,10],
337  [11,2,0],
338  [6,11,0],
339  [5,3,8],
340  [9,5,8],
341  [5,9,2],
342  [3,7,10],
343  [7,11,10],
344  [11,7,2],
345  [7,5,2],
346  [5,7,3]
347  ],
348  [
349  [0,2],
350  [0,4],
351  [0,6],
352  [0,9],
353  [0,11],
354  [1,3],
355  [1,4],
356  [1,6],
357  [1,8],
358  [1,10],
359  [2,5],
360  [2,7],
361  [2,9],
362  [2,11],
363  [3,5],
364  [3,7],
365  [3,8],
366  [3,10],
367  [4,6],
368  [4,8],
369  [4,9],
370  [5,7],
371  [5,8],
372  [5,9],
373  [6,10],
374  [6,11],
375  [7,10],
376  [7,11],
377  [8,9],
378  [10,11]
379  ]
380  ],
381  [
382  "octahedron",
383  "Octahedron",
384  empty_str,
385  "platonic",
386  "Exact Mathematics",
387  [
388  [ 0.00000000000, 0.00000000000, 1.00000000000],
389  [ 0.00000000000, 1.00000000000, 0.00000000000],
390  [-1.00000000000, 0.00000000000, 0.00000000000],
391  [ 1.00000000000, 0.00000000000, 0.00000000000],
392  [ 0.00000000000, -1.00000000000, 0.00000000000],
393  [ 0.00000000000, 0.00000000000, -1.00000000000]
394  ],
395  [
396  [1.00000000000, 0.00000000000, 0.00000000000],
397  [1.00000000000, 89.99999999999, 89.99999999999],
398  [1.00000000000, 179.99999999999, 89.99999999999],
399  [1.00000000000, 0.00000000000, 89.99999999999],
400  [1.00000000000, -89.99999999999, 89.99999999999],
401  [1.00000000000, 0.00000000000, 179.99999999999]
402  ],
403  [
404  [1,0,2],
405  [0,1,3],
406  [5,1,2],
407  [1,5,3],
408  [4,0,3],
409  [0,4,2],
410  [4,5,2],
411  [5,4,3]
412  ],
413  [
414  [0,1],
415  [0,2],
416  [0,3],
417  [0,4],
418  [1,2],
419  [1,3],
420  [2,4],
421  [3,4],
422  [1,5],
423  [2,5],
424  [3,5],
425  [4,5]
426  ]
427  ],
428  [
429  "tetrahedron",
430  "Tetrahedron",
431  empty_str,
432  "platonic",
433  "Exact Mathematics",
434  [
435  [ 1.00000000000, 1.00000000000, -1.00000000000],
436  [-1.00000000000, 1.00000000000, 1.00000000000],
437  [ 1.00000000000, -1.00000000000, 1.00000000000],
438  [-1.00000000000, -1.00000000000, -1.00000000000]
439  ],
440  [
441  [1.73205080757, 45.00000000000, 125.26438968275],
442  [1.73205080757, 134.99999999999, 54.73561031724],
443  [1.73205080757, -45.00000000000, 54.73561031724],
444  [1.73205080757, -134.99999999999, 125.26438968275]
445  ],
446  [
447  [0,2,1],
448  [3,0,1],
449  [2,3,1],
450  [3,2,0]
451  ],
452  [
453  [0,1],
454  [0,2],
455  [0,3],
456  [1,2],
457  [1,3],
458  [2,3]
459  ]
460  ]
461 ];
462 
463 //! @}
464 
465 //----------------------------------------------------------------------------//
466 // openscad-amu auxiliary scripts
467 //----------------------------------------------------------------------------//
468 
469 /*
470 BEGIN_SCOPE db;
471 BEGIN_SCOPE autostat;
472  BEGIN_OPENSCAD;
473  include <omdl-base.scad>;
474  include <database/geometry/polyhedra/platonic.scad>;
475 
476  fs = "^";
477 
478  tc = dtc_polyhedra_platonic;
479  tr = dtr_polyhedra_platonic;
480 
481  ids = table_get_row_ids(tr);
482 
483  echo
484  (
485  str
486  (
487  "no.", fs, "id", fs, "other name", fs,
488  "vertices", fs, "faces", fs, "edges",
489 
490  fs, "face-verticies",
491  fs, "face-angles",
492  fs, "edge-lengths",
493  fs, "edge-angles"
494  )
495  );
496 
497  for ( id = ids )
498  {
499  i = first(find(id, ids, c=1))+1;
500 
501  n = table_get_value(tr, tc, id, "n");
502  o = table_get_value(tr, tc, id, "o");
503  g = table_get_value(tr, tc, id, "g");
504  d = table_get_value(tr, tc, id, "d");
505 
506  c = table_get_value(tr, tc, id, "c");
507  s = table_get_value(tr, tc, id, "s");
508  f = table_get_value(tr, tc, id, "f");
509  e = table_get_value(tr, tc, id, "e");
510 
511  fo = is_empty(o) ? "-" : o;
512 
513  echo
514  (
515  str
516  (
517  i, fs, id, fs, fo, fs,
518  len(c), fs, len(f), fs, len(e),
519 
520  fs, histogram(sort_q(polytope_face_vertex_counts(f)), m=9),
521  fs, histogram(sort_q(round_d(polytope_face_angles(c, f), d=1)), m=9),
522  fs, histogram(sort_q(round_s(polytope_edge_lengths(c, e), d=3)), m=9),
523  fs, histogram(sort_q(round_d(polytope_edge_angles(c, f), d=1)), m=9),
524 
525  fs
526  )
527  );
528  }
529  END_OPENSCAD;
530 
531  BEGIN_MFSCRIPT;
532  include --path "${INCLUDE_PATH}" {var_init,var_gen_term}.mfs;
533  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
534  END_MFSCRIPT;
535 END_SCOPE;
536 END_SCOPE;
537 */
538 
539 /*
540 BEGIN_SCOPE db;
541 BEGIN_SCOPE dim;
542  BEGIN_OPENSCAD;
543  include <omdl-base.scad>;
544  include <units/coordinate.scad>;
545  include <tools/common/polytope.scad>;
546  include <database/geometry/polyhedra/platonic.scad>;
547 
548  config = 0;
549 
550  tc = dtc_polyhedra_platonic;
551  tr = dtr_polyhedra_platonic;
552 
553  id = "default";
554  sr = 100;
555 
556  pv = table_get_value(tr, tc, id, "c");
557  pf = table_get_value(tr, tc, id, "f");
558  pe = table_get_value(tr, tc, id, "e");
559 
560  sv = coordinate_scale3d_csc(pv, sr);
561 
562  if (config == 0) // png preview
563  {
564  $fn = 25;
565 
566  %polyhedron(sv, pf);
567 
568  polytope_frame(sv, pf, pe)
569  {
570  circle(r = sr / 25);
571  color("lightblue")
572  sphere(r = sr / 25 * (1 + 1/2));
573  }
574  }
575 
576  if (config == 1) // stl model
577  {
578  polyhedron(sv, pf);
579  }
580  END_OPENSCAD;
581 
582  BEGIN_MFSCRIPT;
583  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
584 
585  views name "views" views "diag";
586  defines name "ids" define "id"
587  strings
588  "
589  cube
590  dodecahedron
591  icosahedron
592  octahedron
593  tetrahedron
594  ";
595  variables add_opts_combine "views ids";
596  variables add_opts "-D config=0 --viewall --autocenter --view=axes";
597 
598  include --path "${INCLUDE_PATH}" scr_make_mf_begin.mfs;
599  include --path "${INCLUDE_PATH}" scr_make_mf_add_ext.mfs;
600 
601  include --path "${INCLUDE_PATH}" var_gen_stl.mfs;
602  variables add_opts_combine "ids";
603  variables add_opts "-D config=1";
604 
605  include --path "${INCLUDE_PATH}" scr_make_mf_add_ext.mfs;
606  include --path "${INCLUDE_PATH}" scr_make_mf_end.mfs;
607  END_MFSCRIPT;
608 END_SCOPE;
609 END_SCOPE;
610 */
611 
612 //----------------------------------------------------------------------------//
613 // end of file
614 //----------------------------------------------------------------------------//
empty_str
<string> A string with no characters (the empty string).
Definition: constants.scad:301
dtc_polyhedra_platonic
Definition: platonic.scad:197
dtr_polyhedra_platonic
Definition: platonic.scad:212