Families Module#
Overview
Provide tools for generating shapes.
Shape families are coxeter’s way of providing well-defined methods for
generating classes of shapes according to some set of rules. The basic
interface is defined by the ShapeFamily
, which is a functor that is
called to generate a shape. The TabulatedShapeFamily
group of
subclasses enable the generation of shape families according to some
tabulated set of data, while other families are defined by some set of
(discrete or continuous) parameters that are used to construct a shape
analytically.
The DOI_SHAPE_REPOSITORIES
variable provides convenient access to the shape families
associated with different scientific publications. This dataset is useful for
reproducing the exact set of shapes from publications.
Classes:
The family of Archimedean solids (13 total). |
|
The family of Catalan solids, also known as Archimedean duals (13 total). |
|
The 323+ shape family defined in [CKE+14]. |
|
The 423 shape family defined in [CKE+14]. |
|
The 523 shape family defined in [CKE+14]. |
|
The family of Johnson solids, as enumerated in [Joh66] (92 total). |
|
The family of Platonic solids (5 total). |
|
The family of uniform n-prisms and n-antiprisms with n∈[3,10] (16 total). |
|
The family of regular equilateral pyramids and dipyramids (6 total). |
|
The family of convex regular polygons. |
|
A factory for instances of |
|
A tabulated shape family defined by a GSD shape schema. |
|
A shape family corresponding to a tabulated set of shapes. |
|
The truncated tetrahedron family used in [DEG12]. |
Data:
A mapping of DOIs to a list of shape families. |
- class coxeter.families.ArchimedeanFamily#
Bases:
TabulatedGSDShapeFamily
The family of Archimedean solids (13 total).
- Parameters:
name (str) – The name of the Archimedean 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”.
Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
get_shape
(name)Use the class's data to produce a shape for the given name.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- class coxeter.families.CatalanFamily#
Bases:
TabulatedGSDShapeFamily
The family of Catalan solids, also known as Archimedean duals (13 total).
- Parameters:
name (str) – The name of the Catalan solid.
Options are “Deltoidal Hexecontahedron”, “Deltoidal Icositetrahedron”, “Disdyakis Dodecahedron”, “Disdyakis Triacontahedron”, “Pentagonal Hexecontahedron”, “Pentagonal Icositetrahedron”, “Pentakis Dodecahedron”, “Rhombic Dodecahedron”, “Rhombic Triacontahedron”, “Triakis Octahedron”, “Tetrakis Hexahedron”, “Triakis Icosahedron”, and “Triakis Tetrahedron”.
Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
get_shape
(name)Use the class's data to produce a shape for the given name.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- coxeter.families.DOI_SHAPE_REPOSITORIES = {}#
A mapping of DOIs to a list of shape families.
Each known DOI is associated with a list of shape families that can be used to generate the shapes from those papers. Currently supported DOIs are:
- class coxeter.families.Family323Plus#
Bases:
TruncationPlaneShapeFamily
The 323+ shape family defined in [CKE+14].
This class requires the parameters
\(a \in [1, 3]\)
\(c \in [1, 3]\)
The \(b\) parameter is always equal to 1 for this family.
The extremal shapes in this shape family are an octahedron at (1, 1), a tetrahedron at (3, 1) and (1, 3), and a cube at (3, 3).
Methods:
Get the types of the planes.
Get the set of planes used to truncate the shape.
get_shape
(a, c)Generate a shape for the provided parameters.
make_vertices
(a, b, c)Generate vertices from the a, b, and c parameters.
- classmethod get_plane_types()#
Get the types of the planes.
The types are encoded via the following integer mapping:
type 0 corresponds to the parameter a.
type 1 corresponds to the parameter b.
type 2 corresponds to the parameter c.
- Returns:
The plane types.
- Return type:
(\(N_{planes}\), )
numpy.ndarray
of int
- classmethod get_planes()#
Get the set of planes used to truncate the shape.
- Returns:
The planes defining this family
- Return type:
(\(N_{planes}\), 3)
numpy.ndarray
of float
- classmethod get_shape(a, c)#
Generate a shape for the provided parameters.
- Parameters:
- Returns:
The desired shape.
- Return type:
- classmethod make_vertices(a, b, c)#
Generate vertices from the a, b, and c parameters.
- Parameters:
- Returns:
The vertices of the shape generated by the provided parameters.
- Return type:
(\(N_{vertices}\), 3)
numpy.ndarray
of float
- class coxeter.families.Family423#
Bases:
TruncationPlaneShapeFamily
The 423 shape family defined in [CKE+14].
This class requires the parameters
\(a \in [1, 2]\)
\(c \in [2, 3]\)
The \(b\) parameter is always equal to 2 for this family.
The extremal shapes in this shape family are a cuboctahedron at (1, 2), an octahedron at (2, 2), a cube at (1, 3), and a rhombic dodecahedron at (2, 3).
Methods:
Get the types of the planes.
Get the set of planes used to truncate the shape.
get_shape
(a, c)Generate a shape for the provided parameters.
make_vertices
(a, b, c)Generate vertices from the a, b, and c parameters.
- classmethod get_plane_types()#
Get the types of the planes.
The types are encoded via the following integer mapping:
type 0 corresponds to the parameter a.
type 1 corresponds to the parameter b.
type 2 corresponds to the parameter c.
- Returns:
The plane types.
- Return type:
(\(N_{planes}\), )
numpy.ndarray
of int
- classmethod get_planes()#
Get the set of planes used to truncate the shape.
- Returns:
The planes defining this family
- Return type:
(\(N_{planes}\), 3)
numpy.ndarray
of float
- classmethod get_shape(a, c)#
Generate a shape for the provided parameters.
- Parameters:
- Returns:
The desired shape.
- Return type:
- classmethod make_vertices(a, b, c)#
Generate vertices from the a, b, and c parameters.
- Parameters:
- Returns:
The vertices of the shape generated by the provided parameters.
- Return type:
(\(N_{vertices}\), 3)
numpy.ndarray
of float
- class coxeter.families.Family523#
Bases:
TruncationPlaneShapeFamily
The 523 shape family defined in [CKE+14].
This class requires the parameters
\(a \in [1, s\sqrt{5}]\)
\(c \in [S^2, 3]\)
where \(S = \frac{1}{2}\left(\sqrt{5} + 1\right)\) is the golden ratio and \(s = \frac{1}{2}\left(\sqrt{5} - 1\right)\) is its inverse. The \(b\) parameter is always equal to 2 for this family.
The extremal shapes in this shape family are an icosidodecahedron at (\(1\), \(S^2\)), an icosahedron at (\(s\sqrt{5}\), \(S^2\)), a dodecahedron at (\(1\), \(3\)), and a rhombic triacontahedron at (\(s\sqrt{5}\), \(3\)).
Attributes:
Methods:
Get the types of the planes.
Get the set of planes used to truncate the shape.
get_shape
(a, c)Generate a shape for the provided parameters.
make_vertices
(a, b, c)Generate vertices from the a, b, and c parameters.
- S = 1.618033988749895#
The constant S (the golden ratio).
- classmethod get_plane_types()#
Get the types of the planes.
The types are encoded via the following integer mapping:
type 0 corresponds to the parameter a.
type 1 corresponds to the parameter b.
type 2 corresponds to the parameter c.
- Returns:
The plane types.
- Return type:
(\(N_{planes}\), )
numpy.ndarray
of int
- classmethod get_planes()#
Get the set of planes used to truncate the shape.
- Returns:
The planes defining this family
- Return type:
(\(N_{planes}\), 3)
numpy.ndarray
of float
- classmethod get_shape(a, c)#
Generate a shape for the provided parameters.
- Parameters:
- Returns:
The desired shape.
- Return type:
- classmethod make_vertices(a, b, c)#
Generate vertices from the a, b, and c parameters.
- Parameters:
- Returns:
The vertices of the shape generated by the provided parameters.
- Return type:
(\(N_{vertices}\), 3)
numpy.ndarray
of float
- s = 0.6180339887498948#
The constant s (the inverse of the golden ratio).
- class coxeter.families.JohnsonFamily#
Bases:
TabulatedGSDShapeFamily
The family of Johnson solids, as enumerated in [Joh66] (92 total).
- Parameters:
name (str) – The name of the Johnson solid.
A full list of Johnson solids is available in [Joh66]. 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”).
Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
get_shape
(name)Use the class's data to produce a shape for the given name.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- class coxeter.families.PlatonicFamily#
Bases:
TabulatedGSDShapeFamily
The family of Platonic solids (5 total).
- Parameters:
name (str) – The name of the Platonic solid.
Options are “Cube”, “Dodecahedron”, “Icosahedron”, “Octahedron”, and “Tetrahedron”.
Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
get_shape
(name)Use the class's data to produce a shape for the given name.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- class coxeter.families.PrismAntiprismFamily#
Bases:
TabulatedGSDShapeFamily
The family of uniform n-prisms and n-antiprisms with n∈[3,10] (16 total).
- Parameters:
name (str) – 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”.
Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
get_shape
(name)Use the class's data to produce a shape for the given name.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- class coxeter.families.PyramidDipyramidFamily#
Bases:
TabulatedGSDShapeFamily
The family of regular equilateral pyramids and dipyramids (6 total).
- Parameters:
name (str) – The name of the pyramid or dipyramid.
Options for pyramids are “Triangular Pyramid”, “Square Pyramid”, and “Pentagonal Pyramid”. Options for dipyramids are “Triangular Dipyramid”, “Square Dipyramid”, and “Pentagonal Dipyramid”.
Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
get_shape
(name)Use the class's data to produce a shape for the given name.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- class coxeter.families.RegularNGonFamily#
Bases:
ShapeFamily
The family of convex regular polygons.
This class generates the set of convex regular polygons with \(n\) sides. The polygons are normalized to be unit area by default, and the initial vertex always lies on the \(x\) axis (so, for example, a 4-sided shape generated by this will look like a diamond, i.e. a square rotated by 45 degrees).
The following parameters are required by this class:
\(n\): The number of vertices of the polygon
Methods:
get_shape
(n)Generate a unit area n-gon.
Generate vertices of a unit area n-gon.
- class coxeter.families.ShapeFamily#
Bases:
ABC
A factory for instances of
Shape
.This abstract class represents a simple promise of a
get_shape
method that accepts some set of arguments and returns some shape class. The precise behavior is left up to specific subclasses, which document the parameters in the class docstring.This class is designed to never be instantiated. All relevant operations of its subclasses should be classmethods, and any data intrinsic to a family should be stored within the class. This design avoids creating an antipattern of instantiating a stateless class, while also providing a suitable means for using inheritance to create meaningful relationships between shape families. It also simplifies user APIs, avoiding confusing idioms like
shape = family()(SHAPE_NAME)
. For instance, given a family for generating regular polygons, getting a hexagon should look roughly likefamily.get_shape(n=6)
.Methods:
Generate a shape.
- class coxeter.families.TabulatedGSDShapeFamily#
Bases:
TabulatedShapeFamily
A tabulated shape family defined by a GSD shape schema.
The values of the dictionary used to construct this class must adhere to the GSD shape spec. Each mapping may contain additional data, which is ignored when the class is called to actually produce
Shape
objects.- Parameters:
filename_or_dict (str or Mapping) – A dictionary containing valid shape definitions or a JSON file that can be read into such a dictionary.
Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
get_shape
(name)Use the class's data to produce a shape for the given name.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- class coxeter.families.TabulatedShapeFamily#
Bases:
ShapeFamily
A shape family corresponding to a tabulated set of shapes.
Data can either be read from a file or provided in the form of a dictionary. If a filename is provided, it must be a JSON file that can be parsed into an appropriately formatted dictionary, namely a set of key-value pairs such that the call operator of this class can generate a
Shape
from the dictionary. The raw parsed JSON is accessible via thedata
attribute. Subclasses of this class implement the call operator to define exactly how the dictionary values are converted to a shape definition.Methods:
from_json_file
(filename, *args, **kwargs)Generate a subclass for a dataset from a JSON file.
from_mapping
(mapping[, classname, docstring])Generate a subclass for a dataset from a mapping.
Generate a shape.
- classmethod from_json_file(filename, *args, **kwargs)#
Generate a subclass for a dataset from a JSON file.
This method simply loads the JSON file into a dictionary and calls
from_mapping()
, see that docstring for more information.- Parameters:
filename (str) – A JSON file containing valid shape definitions.
*args – Passed on to
from_mapping()
.**kwargs – Passed on to
from_mapping()
.
- Return type:
A subclass of this one associated with the the provided data.
- classmethod from_mapping(mapping, classname=None, docstring=None)#
Generate a subclass for a dataset from a mapping.
Notably, this method is a _class_ factory: rather than generating a new instance, this method actually generates a new subclass. This design is consistent with the usage
ShapeFamily
subclasses by direct interaction with the class (without instantiation).- Parameters:
- Return type:
A subclass of this one associated with the the provided data.
- class coxeter.families.TruncatedTetrahedronFamily#
Bases:
Family323Plus
The truncated tetrahedron family used in [DEG12].
The following parameters are required by this class:
truncation \(\in [0, 1]\)
This family is constructed as a limiting case of
Family323Plus
with a = 1. The c value is then directly related to a linear interpolation over truncations. In particular, \(c = 3 - 2(\text{truncation})\).Methods:
Get the types of the planes.
Get the set of planes used to truncate the shape.
get_shape
(truncation)Generate a shape for a given truncation value.
make_vertices
(a, b, c)Generate vertices from the a, b, and c parameters.
- classmethod get_plane_types()#
Get the types of the planes.
The types are encoded via the following integer mapping:
type 0 corresponds to the parameter a.
type 1 corresponds to the parameter b.
type 2 corresponds to the parameter c.
- Returns:
The plane types.
- Return type:
(\(N_{planes}\), )
numpy.ndarray
of int
- classmethod get_planes()#
Get the set of planes used to truncate the shape.
- Returns:
The planes defining this family
- Return type:
(\(N_{planes}\), 3)
numpy.ndarray
of float
- classmethod get_shape(truncation)#
Generate a shape for a given truncation value.
- Parameters:
truncation (float) – The parameter \(truncation \in [0, 1]\).
- Returns:
The desired truncated tetrahedron.
- Return type:
- classmethod make_vertices(a, b, c)#
Generate vertices from the a, b, and c parameters.
- Parameters:
- Returns:
The vertices of the shape generated by the provided parameters.
- Return type:
(\(N_{vertices}\), 3)
numpy.ndarray
of float