Shape Definitions¶
Shape definitions contain information about the shape of individual particles.
Some shapes define a type_shape
property, which returns a
dict
for consumption by visualization tools.
The type_shape
specification can be found here: Shape Visualization.
-
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: -
pos_string
¶
-
type_shape
¶
-
-
class
garnett.shapes.
SphereShape
(diameter, orientable=False, color=None)[source]¶ Shape class for spheres of a specified diameter.
Parameters: -
pos_string
¶
-
type_shape
¶ Shape as dictionary. Example:
>>> SphereShape(2.0).type_shape {'type': 'Sphere', 'diameter': 2.0}
-
-
class
garnett.shapes.
ArrowShape
(thickness=0.1, color=None)[source]¶ Shape class for arrows of a specified thickness.
Parameters: -
pos_string
¶
-
type_shape
¶
-
-
class
garnett.shapes.
SphereUnionShape
(diameters, centers, colors=None)[source]¶ Shape class for sphere unions, such as rigid bodies of many spheres.
Parameters: -
pos_string
¶
-
type_shape
¶ Shape as dictionary. Example:
>>> SphereUnionShape([0.5, 0.5, 0.5], [[0, 0, 1.0], [0, 1.0, 0], [1.0, 0, 0]]).type_shape {'type': 'SphereUnion', 'diameters': [0.5, 0.5, 0.5], 'centers': [[0, 0, 1.0], [0, 1.0, 0], [1.0, 0, 0]]}
-
-
class
garnett.shapes.
PolygonShape
(vertices, color=None)[source]¶ Shape class for polygons in a 2D plane.
Parameters: -
pos_string
¶
-
type_shape
¶ Shape as dictionary. Example:
>>> PolygonShape([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5]]).type_shape {'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: -
pos_string
¶
-
type_shape
¶ Shape as dictionary. Example:
>>> SpheropolygonShape([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5]], 0.1).type_shape {'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: -
pos_string
¶
-
type_shape
¶ 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]]).type_shape {'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
).
-
pos_string
¶
-
type_shape
¶
-
class
garnett.shapes.
ConvexSpheropolyhedronShape
(vertices, rounding_radius=0, color=None)[source]¶ Shape class for a convex polyhedron extended by a rounding radius.
Parameters: -
pos_string
¶
-
type_shape
¶ 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).type_shape {'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
).
-
pos_string
¶
-
type_shape
¶ 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]]).type_shape {'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': [[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]]}