Shape Definitions¶
Shape definitions contain information about the shape of individual particles.
Some shapes define a shape_dict
property, which returns a
dict
for consumption by visualization tools, in the format of
hoomd.hpmc.integrate.mode_hpmc.get_type_shapes()
.
-
class
garnett.shapes.
FallbackShape
[source]¶ This shape definition class is used when no specialized Shape class can be applied.
The fallback shape definition is a string containing the definition.
-
class
garnett.shapes.
Shape
(shape_class=None, color=None)[source]¶ Parent class of all shape objects.
Parameters:
-
class
garnett.shapes.
SphereShape
(diameter, orientable=False, color=None)[source]¶ Shape class for spheres of a specified diameter.
Parameters: -
shape_dict
¶ Shape as dictionary. Example:
>>> SphereShape(2.0).shape_dict {'type': 'Sphere', 'diameter': 2.0, 'orientable': False}
-
-
class
garnett.shapes.
ArrowShape
(thickness=0.1, color=None)[source]¶ Shape class for arrows of a specified thickness.
Parameters:
-
class
garnett.shapes.
SphereUnionShape
(diameters, centers, colors=None)[source]¶ Shape class for sphere unions, such as rigid bodies of many spheres.
Parameters:
-
class
garnett.shapes.
PolygonShape
(vertices, color=None)[source]¶ Shape class for polygons in a 2D plane.
Parameters: -
shape_dict
¶ Shape as dictionary. Example:
>>> PolygonShape([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5]]).shape_dict {'type': 'Polygon', 'rounding_radius': 0, 'vertices': [[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5]]}
-
-
class
garnett.shapes.
SpheropolygonShape
(vertices, rounding_radius=0, color=None)[source]¶ Shape class for rounded polygons in a 2D plane.
Parameters: -
shape_dict
¶ Shape as dictionary. Example:
>>> SpheropolygonShape([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5]], 0.1).shape_dict {'type': 'Polygon', 'rounding_radius': 0.1, 'vertices': [[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5]]}
-
-
class
garnett.shapes.
ConvexPolyhedronShape
(vertices, color=None)[source]¶ Shape class for convex polyhedra.
Parameters: -
shape_dict
¶ Shape as dictionary. Example:
>>> ConvexPolyhedronShape([[0.5, 0.5, 0.5], [0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [-0.5, -0.5, 0.5]]).shape_dict {'type': 'ConvexPolyhedron', 'rounding_radius': 0, 'vertices': [[0.5, 0.5, 0.5], [0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [-0.5, -0.5, 0.5]]}
-
-
class
garnett.shapes.
ConvexPolyhedronUnionShape
(vertices, centers, orientations, colors=None)[source]¶ Shape class for unions of convex polyhedra.
Parameters: - vertices (list) – List of lists of 3D vertex vectors in particle coordinates (each polyhedron, each vertex).
- centers (list) – List of 3D polyhedra center vectors.
- orientations (list) – Orientations of the polyhedra, as a list of quaternions.
- colors (list) – List of hexadecimal color strings in format
RRGGBBAA
(default:None
).
-
class
garnett.shapes.
ConvexSpheropolyhedronShape
(vertices, rounding_radius=0, color=None)[source]¶ Shape class for a convex polyhedron extended by a rounding radius.
Parameters: -
shape_dict
¶ Shape as dictionary. Example:
>>> ConvexSpheropolyhedronShape([[0.5, 0.5, 0.5], [0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [-0.5, -0.5, 0.5]], 0.1).shape_dict {'type': 'ConvexPolyhedron', 'rounding_radius': 0.1, 'vertices': [[0.5, 0.5, 0.5], [0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [-0.5, -0.5, 0.5]]}
-
-
class
garnett.shapes.
GeneralPolyhedronShape
(vertices, faces, color=None, facet_colors=None)[source]¶ Shape class for general polyhedra, such as arbitrary meshes.
Parameters: - vertices (list) – List of 3D vertex vectors.
- faces (list) – List of lists of integers representing vertex indices for each face.
- color (str) – Hexadecimal color string in format
RRGGBBAA
(default:None
). - facet_colors (list) – List of hexadecimal color strings in format
RRGGBBAA
for each facet (default:None
).
-
shape_dict
¶ Shape as dictionary. Example:
>>> GeneralPolyhedronShape([[0.5, 0.5, 0.5], [0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [-0.5, -0.5, 0.5]]).shape_dict {'type': 'Mesh', 'vertices': [[0.5, 0.5, 0.5], [0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [-0.5, -0.5, 0.5]], 'indices': [[1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]}