omdl  v1.0
OpenSCAD Mechanical Design Library
pyramids.scad
Go to the documentation of this file.
1 //! Polyhedra data table: \c pyramids.
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  ### Pyramids ###
64  \amu_include (include/amu/includes_required.amu)
65 
66  \amu_eval
67  (
68  ++global
69  title="Examples"
70  stem=pyramids 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 pyramids 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 pyramids polyhedra data table rows.
143 //! \hideinitializer
145 [
146  [
147  "pentagonal_dipyramid",
148  "Pentagonal Dipyramid",
149  "J13",
150  "pyramids",
151  "Polyhedron Database #57",
152  [
153  [ 0.00000000000, 0.61803398875, 0.00000000000],
154  [ 0.00000000000, -0.00000000000, 1.00000000000],
155  [ 0.95105651630, -0.00000000000, 0.30901699437],
156  [-0.95105651630, -0.00000000000, 0.30901699437],
157  [ 0.58778525229, 0.00000000000, -0.80901699437],
158  [-0.58778525229, -0.00000000000, -0.80901699437],
159  [ 0.00000000000, -0.61803398875, 0.00000000000]
160  ],
161  [
162  [0.61803398875, 89.99999999999, 89.99999999999],
163  [1.00000000000, -0.00000000000, 0.00000000000],
164  [1.00000000000, -0.00000000000, 72.00000000000],
165  [1.00000000000, -179.99999999999, 72.00000000000],
166  [1.00000000000, 0.00000000000, 143.99999999999],
167  [1.00000000000, -179.99999999999, 143.99999999999],
168  [0.61803398875, -89.99999999999, 89.99999999999]
169  ],
170  [
171  [0,2,1],
172  [0,5,4],
173  [0,4,2],
174  [0,1,3],
175  [0,3,5],
176  [6,1,2],
177  [6,4,5],
178  [6,2,4],
179  [6,3,1],
180  [6,5,3]
181  ],
182  [
183  [0,1],
184  [0,2],
185  [0,3],
186  [0,4],
187  [0,5],
188  [1,2],
189  [1,3],
190  [1,6],
191  [2,4],
192  [2,6],
193  [3,5],
194  [3,6],
195  [4,5],
196  [4,6],
197  [5,6]
198  ]
199  ],
200  [
201  "pentagonal_pyramid",
202  "Pentagonal Pyramid",
203  "J2",
204  "pyramids",
205  "Polyhedron Database #46",
206  [
207  [ 0.00000000000, 0.51231760759, 0.00000000000],
208  [ 0.00000000000, -0.10246352152, 0.99473676254],
209  [ 0.94605088002, -0.10246352152, 0.30739056456],
210  [-0.94605088002, -0.10246352152, 0.30739056456],
211  [ 0.58469159894, -0.10246352152, -0.80475894583],
212  [-0.58469159894, -0.10246352152, -0.80475894583]
213  ],
214  [
215  [0.51231760759, 89.99999999999, 89.99999999999],
216  [1.00000000000, -89.99999999999, 5.88104874729],
217  [1.00000000000, -6.18141426337, 72.09795604403],
218  [1.00000000000, -173.81858573661, 72.09795604404],
219  [1.00000000000, -9.93979324212, 143.58698182134],
220  [1.00000000000, -170.06020675786, 143.58698182134]
221  ],
222  [
223  [0,2,1],
224  [0,5,4],
225  [0,4,2],
226  [0,1,3],
227  [0,3,5],
228  [1,2,4,5,3]
229  ],
230  [
231  [0,1],
232  [0,2],
233  [0,3],
234  [0,4],
235  [0,5],
236  [1,2],
237  [1,3],
238  [2,4],
239  [3,5],
240  [4,5]
241  ]
242  ],
243  [
244  "square_dipryamid",
245  "Square Dipryamid",
246  "Octahedron",
247  "pyramids",
248  "Exact Mathematics",
249  [
250  [ 0.00000000000, 1.00000000000, 0.00000000000],
251  [-1.00000000000, 0.00000000000, 0.00000000000],
252  [ 0.00000000000, 0.00000000000, -1.00000000000],
253  [ 1.00000000000, 0.00000000000, 0.00000000000],
254  [ 0.00000000000, 0.00000000000, 1.00000000000],
255  [ 0.00000000000, -1.00000000000, 0.00000000000]
256  ],
257  [
258  [1.00000000000, 89.99999999999, 89.99999999999],
259  [1.00000000000, 179.99999999999, 89.99999999999],
260  [1.00000000000, 0.00000000000, 179.99999999999],
261  [1.00000000000, 0.00000000000, 89.99999999999],
262  [1.00000000000, 0.00000000000, 0.00000000000],
263  [1.00000000000, -89.99999999999, 89.99999999999]
264  ],
265  [
266  [0,1,2],
267  [0,2,3],
268  [0,3,4],
269  [0,4,1],
270  [5,2,1],
271  [5,3,2],
272  [5,4,3],
273  [5,1,4]
274  ],
275  [
276  [0,1],
277  [0,2],
278  [0,3],
279  [0,4],
280  [1,2],
281  [1,4],
282  [1,5],
283  [2,3],
284  [2,5],
285  [3,4],
286  [3,5],
287  [4,5]
288  ]
289  ],
290  [
291  "square_pyramid",
292  "Square Pyramid",
293  "J1",
294  "pyramids",
295  "Exact Mathematics",
296  [
297  [ 0.00000000000, 1.00000000000, 0.00000000000],
298  [-1.00000000000, 0.00000000000, 0.00000000000],
299  [ 0.00000000000, 0.00000000000, -1.00000000000],
300  [ 1.00000000000, 0.00000000000, 0.00000000000],
301  [ 0.00000000000, 0.00000000000, 1.00000000000]
302  ],
303  [
304  [1.00000000000, 89.99999999999, 89.99999999999],
305  [1.00000000000, 179.99999999999, 89.99999999999],
306  [1.00000000000, 0.00000000000, 179.99999999999],
307  [1.00000000000, 0.00000000000, 89.99999999999],
308  [1.00000000000, 0.00000000000, 0.00000000000]
309  ],
310  [
311  [0,1,2],
312  [0,2,3],
313  [0,3,4],
314  [0,4,1],
315  [4,3,2,1]
316  ],
317  [
318  [0,1],
319  [0,2],
320  [0,3],
321  [0,4],
322  [1,2],
323  [1,4],
324  [2,3],
325  [3,4]
326  ]
327  ],
328  [
329  "triangular_dipyramid",
330  "Triangular Dipyramid",
331  "J12",
332  "pyramids",
333  "Exact Mathematics",
334  [
335  [ 0.00000000000, 1.00000000000, 0.00000000000],
336  [-0.61237243570, 0.00000000000, 0.35355339059],
337  [ 0.61237243570, 0.00000000000, 0.35355339059],
338  [ 0.00000000000, 0.00000000000, -0.70710678119],
339  [ 0.00000000000, -1.00000000000, 0.00000000000]
340  ],
341  [
342  [1.00000000000, 89.99999999999, 89.99999999999],
343  [0.70710678119, 179.99999999999, 59.99999999999],
344  [0.70710678119, 0.00000000000, 59.99999999999],
345  [0.70710678119, 0.00000000000, 179.99999999999],
346  [1.00000000000, -89.99999999999, 89.99999999999]
347  ],
348  [
349  [0,2,1],
350  [0,1,3],
351  [0,3,2],
352  [4,1,2],
353  [4,3,1],
354  [4,2,3]
355  ],
356  [
357  [0,1],
358  [0,2],
359  [0,3],
360  [1,2],
361  [1,3],
362  [1,4],
363  [2,3],
364  [2,4],
365  [3,4]
366  ]
367  ],
368  [
369  "triangular_pyramid",
370  "Triangular Pyramid",
371  "Tetrahedron",
372  "pyramids",
373  "Exact Mathematics",
374  [
375  [ 0.00000000000, 1.00000000000, 0.00000000000],
376  [-0.81649658093, -0.33333333333, 0.47140452079],
377  [ 0.81649658093, -0.33333333333, 0.47140452079],
378  [-0.00000000000, -0.33333333333, -0.94280904158]
379  ],
380  [
381  [1.00000000000, 89.99999999999, 89.99999999999],
382  [1.00000000000, -157.79234570139, 61.87449429794],
383  [1.00000000000, -22.20765429859, 61.87449429794],
384  [1.00000000000, -89.99999999999, 160.52877936550]
385  ],
386  [
387  [0,2,1],
388  [0,1,3],
389  [0,3,2],
390  [1,2,3]
391  ],
392  [
393  [0,1],
394  [0,2],
395  [0,3],
396  [1,2],
397  [1,3],
398  [2,3]
399  ]
400  ]
401 ];
402 
403 //! @}
404 
405 //----------------------------------------------------------------------------//
406 // openscad-amu auxiliary scripts
407 //----------------------------------------------------------------------------//
408 
409 /*
410 BEGIN_SCOPE db;
411 BEGIN_SCOPE autostat;
412  BEGIN_OPENSCAD;
413  include <omdl-base.scad>;
414  include <database/geometry/polyhedra/pyramids.scad>;
415 
416  fs = "^";
417 
418  tc = dtc_polyhedra_pyramids;
419  tr = dtr_polyhedra_pyramids;
420 
421  ids = table_get_row_ids(tr);
422 
423  echo
424  (
425  str
426  (
427  "no.", fs, "id", fs, "other name", fs,
428  "vertices", fs, "faces", fs, "edges",
429 
430  fs, "face-verticies",
431  fs, "face-angles",
432  fs, "edge-lengths",
433  fs, "edge-angles"
434  )
435  );
436 
437  for ( id = ids )
438  {
439  i = first(find(id, ids, c=1))+1;
440 
441  n = table_get_value(tr, tc, id, "n");
442  o = table_get_value(tr, tc, id, "o");
443  g = table_get_value(tr, tc, id, "g");
444  d = table_get_value(tr, tc, id, "d");
445 
446  c = table_get_value(tr, tc, id, "c");
447  s = table_get_value(tr, tc, id, "s");
448  f = table_get_value(tr, tc, id, "f");
449  e = table_get_value(tr, tc, id, "e");
450 
451  fo = is_empty(o) ? "-" : o;
452 
453  echo
454  (
455  str
456  (
457  i, fs, id, fs, fo, fs,
458  len(c), fs, len(f), fs, len(e),
459 
460  fs, histogram(sort_q(polytope_face_vertex_counts(f)), m=9),
461  fs, histogram(sort_q(round_d(polytope_face_angles(c, f), d=1)), m=9),
462  fs, histogram(sort_q(round_s(polytope_edge_lengths(c, e), d=3)), m=9),
463  fs, histogram(sort_q(round_d(polytope_edge_angles(c, f), d=1)), m=9),
464 
465  fs
466  )
467  );
468  }
469  END_OPENSCAD;
470 
471  BEGIN_MFSCRIPT;
472  include --path "${INCLUDE_PATH}" {var_init,var_gen_term}.mfs;
473  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
474  END_MFSCRIPT;
475 END_SCOPE;
476 END_SCOPE;
477 */
478 
479 /*
480 BEGIN_SCOPE db;
481 BEGIN_SCOPE dim;
482  BEGIN_OPENSCAD;
483  include <omdl-base.scad>;
484  include <units/coordinate.scad>;
485  include <tools/common/polytope.scad>;
486  include <database/geometry/polyhedra/pyramids.scad>;
487 
488  config = 0;
489 
490  tc = dtc_polyhedra_pyramids;
491  tr = dtr_polyhedra_pyramids;
492 
493  id = "default";
494  sr = 100;
495 
496  pv = table_get_value(tr, tc, id, "c");
497  pf = table_get_value(tr, tc, id, "f");
498  pe = table_get_value(tr, tc, id, "e");
499 
500  sv = coordinate_scale3d_csc(pv, sr);
501 
502  if (config == 0) // png preview
503  {
504  $fn = 25;
505 
506  %polyhedron(sv, pf);
507 
508  polytope_frame(sv, pf, pe)
509  {
510  circle(r = sr / 25);
511  color("lightblue")
512  sphere(r = sr / 25 * (1 + 1/2));
513  }
514  }
515 
516  if (config == 1) // stl model
517  {
518  polyhedron(sv, pf);
519  }
520  END_OPENSCAD;
521 
522  BEGIN_MFSCRIPT;
523  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
524 
525  views name "views" views "diag";
526  defines name "ids" define "id"
527  strings
528  "
529  pentagonal_dipyramid
530  pentagonal_pyramid
531  square_dipryamid
532  square_pyramid
533  triangular_dipyramid
534  triangular_pyramid
535  ";
536  variables add_opts_combine "views ids";
537  variables add_opts "-D config=0 --viewall --autocenter --view=axes";
538 
539  include --path "${INCLUDE_PATH}" scr_make_mf_begin.mfs;
540  include --path "${INCLUDE_PATH}" scr_make_mf_add_ext.mfs;
541 
542  include --path "${INCLUDE_PATH}" var_gen_stl.mfs;
543  variables add_opts_combine "ids";
544  variables add_opts "-D config=1";
545 
546  include --path "${INCLUDE_PATH}" scr_make_mf_add_ext.mfs;
547  include --path "${INCLUDE_PATH}" scr_make_mf_end.mfs;
548  END_MFSCRIPT;
549 END_SCOPE;
550 END_SCOPE;
551 */
552 
553 //----------------------------------------------------------------------------//
554 // end of file
555 //----------------------------------------------------------------------------//
dtc_polyhedra_pyramids
Definition: pyramids.scad:197
dtr_polyhedra_pyramids
Definition: pyramids.scad:212