Skip to content

Commit

Permalink
Added new shape families for Archimedean, Catalan, Johnson, and other…
Browse files Browse the repository at this point in the history
… solids. (#177)

* test: Fix assumption on quaternions.

Only test quaternions that are not effectively zero.

* Added new classes to return the edges of polyhedra

The new class ``polyhedron.edges`` returns the a list of the edges of a polyhedron as vertex-index pairs, similar to the current ``polyhedron.faces`` class. The class ``polyhedron.get_edge_vectors`` returns a list of edges as vectors in 3D space.

* Added json files for new shape families as well as accompanying import functions.

* Added new pytest marks and a few test functions.

* New pytest marks have been created for the Archimedean, Catalan, and Johnson shape families.
* A function has been written to combine multiple marks into a single mark for more compact testing of shape properties.
* test_volume function for damasceno shapes has been adapted to test the new shape families
* A test_surface_area method similar to test_volume has been added.

* Tightnened tolerance for test_insphere and increased deadline

Tightened ``atol`` of ``test_insphere``. Increased the deadline of the test to accommodate testing of shapes with many faces (e.g. disdyakis triacontahedron).

* Applied test_bounding_sphere to archimedean solids

* Tightened tolerance for test_bounding_sphere

* Added marks for prism/antiprism and pyramid/dipyramid families

* Applied test_get_set_minimal_centered_bounding_sphere_radius to all new shape families, including prism/antiprism and pyramid/dipyramid

* Applied test_volume and test_surface_area to prism/antiprism and pyramid/dipyramid. Fixed typo in conftest

* Formatted code with black.

* Revert commit "Added new classes to return the edges of polyhedra"

This commit reverts changes made in  ab21279, which are included in a different PR.

* Fixed docstring for common.py

* Split test_insphere into multiple functions based on input data complexity.

The Random3DRotationStrategy test varies widely in runtime based on the complexity of the input shape. Splitting the calling function into two tests (for simple Platonic shapes and more complex Catalan shapes) should solve this issue.

* Increased resilience of minimal_bounding_sphere method

The ``minimal_bounding_sphere`` method is reliant on the solution to a linear system of equations. For polyhedra with portions that protrude out from the main mass, this method can fail due to numerical instability in a small percent of cases. This fix double-checks that the calculated miniball contains all points on the polyhedron, and allows the method to make more attempts to find a correct answer before failing.

* Revert "Increased resilience of minimal_bounding_sphere method"

This reverts commit 40f500c, moving all miniball-related changes to #178.

* Removed unnecessary print statement in the combine_mark function

* Updated Credits.rst to not conflict with master

* Fixed missing space in archimedean.json "Truncated Cuboctahedron"

* Added additional pytest for json data and new families

---------

Co-authored-by: Brandon Butler <butlerbr@umich.edu>
Co-authored-by: Vyas Ramasubramani <vyas.ramasubramani@gmail.com>
  • Loading branch information
3 people committed Mar 27, 2023
1 parent cfb4637 commit 2a2bff3
Show file tree
Hide file tree
Showing 12 changed files with 18,983 additions and 123 deletions.
5 changes: 5 additions & 0 deletions Credits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ Tobias Dwyer
* Added examples for the shape classes.

Jen Bradley

* Bug fixes for ``gsd_shape_spec`` to correctly comply with GSD specifications.
* Fixed error where ``__repr__`` would fail for polyhedra with multiple face types.
* Increased accuracy of stored data for PlatonicFamily solids
* Added shape families for Archimedean, Catalan, and Johnson solids.
* Added shape family for prisms and antiprisms.
* Added shape family for equilateral pyramids and dipyramids.

Source code
-----------
Expand Down
15 changes: 14 additions & 1 deletion coxeter/families/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
reproducing the exact set of shapes from publications.
"""

from .common import PlatonicFamily, RegularNGonFamily
from .common import (
ArchimedeanFamily,
CatalanFamily,
JohnsonFamily,
PlatonicFamily,
PrismAntiprismFamily,
PyramidDipyramidFamily,
RegularNGonFamily,
)
from .doi_data_repositories import _doi_shape_collection_factory, _KeyedDefaultDict
from .plane_shape_families import (
Family323Plus,
Expand Down Expand Up @@ -53,6 +61,11 @@
"Family423",
"Family523",
"PlatonicFamily",
"ArchimedeanFamily",
"CatalanFamily",
"JohnsonFamily",
"PrismAntiprismFamily",
"PyramidDipyramidFamily",
"RegularNGonFamily",
"ShapeFamily",
"TabulatedShapeFamily",
Expand Down
71 changes: 71 additions & 0 deletions coxeter/families/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,74 @@ def make_vertices(cls, n):
"Icosahedron", "Octahedron", and "Tetrahedron".
""",
)

ArchimedeanFamily = TabulatedGSDShapeFamily.from_json_file(
os.path.join(_DATA_FOLDER, "archimedean.json"),
classname="ArchimedeanFamily",
docstring="""The family of Archimedean solids (13 total).
The following parameters are required by this class:
- name: The name of the ArchimedeanFamily solid. Options are "Cuboctahedron", \
"Icosidodecahedron", "Truncated Tetrahedron", "Truncated Octahedron", \
"Truncated Cube", "Truncated Icosahedron", "Truncated Dodecahedron", \
"Rhombicuboctahedron", "Rhombicosidodecahedron", "Truncated \
Cuboctahedron", "Truncated Icosidodecahedron", "Snub Cuboctahedron", \
and "Snub Icosidodecahedron".
""",
)

CatalanFamily = TabulatedGSDShapeFamily.from_json_file(
os.path.join(_DATA_FOLDER, "catalan.json"),
classname="CatalanFamily",
docstring="""The family of Catalan solids, also known as Archimedean duals
(13 total).
The following parameters are required by this class:
- name: The name of the CatalanFamily solid. Options are "Deltoidal \
Hexecontahedron", "DeltoidalIcositetrahedron", "Disdyakis \
Dodecahedron", "Disdyakis Triacontahedron", "Pentagonal \
Hexecontahedron", "Pentagonal Icositetrahedron", "Pentakis \
Dodecahedron", "Rhombic Dodecahedron", "Rhombic \
Triacontahedron", "Triakis Octahedron", "Tetrakis \
Hexahedron", "Triakis Icosahedron", and "Triakis Tetrahedron".
""",
)

JohnsonFamily = TabulatedGSDShapeFamily.from_json_file(
os.path.join(_DATA_FOLDER, "johnson.json"),
classname="JohnsonFamily",
docstring="""The family of Johnson solids (92 total).
The following parameters are required by this class:
- name: The name of the JohnsonFamily solid. A full list is available in \
10.1126/science.1220869: :cite:`Damasceno2012`. In general, shape names \
should have the first character of each word capitalized, with spaces \
between words (e.g. "Elongated Triangular Cupola"). Pyramids and \
dipyramids are named from their base polygon (e.g. "Square Pyramid" \
or "Elongated Pentagonal Dipyramid").
""",
)


PyramidDipyramidFamily = TabulatedGSDShapeFamily.from_json_file(
os.path.join(_DATA_FOLDER, "pyramid_dipyramid.json"),
classname="PyramidDipyramidFamily",
docstring="""The family of regular equilateral pyramids and dipyramids (6 total).
The following parameters are required by this class:
- name: The name of the pyramid or dipyramid. Options are "Triangular Pyramid", \
"Square Pyramid", "Pentagonal Pyramid", "Triangular Dipyramid", \
"Square Dipyramid", and "Pentagonal Dipyramid".
""",
)

PrismAntiprismFamily = TabulatedGSDShapeFamily.from_json_file(
os.path.join(_DATA_FOLDER, "prism_antiprism.json"),
classname="PrismAntiprismFamily",
docstring="""The family of n-gonal prisms and antiprisms with n∈[3,10] (16 total).
The following parameters are required by this class:
- name: The name of the prism or antiprism. Options for prisms are \
"Triangular Prism", "Square Prism", "Pentagonal Prism", "Hexagonal Prism", \
"Heptagonal Prism", "Octagonal Prism", "Nonagonal Prism", and \
"Decagonal Prism". Options for antiprisms are "Triangular Antiprism", \
"Square Antiprism", "Pentagonal Antiprism", "Hexagonal Antiprism", \
"Heptagonal Antiprism", "Octagonal Antiprism","Nonagonal Antiprism", \
and "Decagonal Antiprism".
""",
)
Loading

0 comments on commit 2a2bff3

Please sign in to comment.