Debian Codegraph @

doc/shapes.rst

raw
1 .. Copyright (c) 2016-2026 The Regents of the University of Michigan
2 .. Part of GSD, released under the BSD 2-Clause License.
3
4 .. _shapes:
5
6 Shape Visualization
7 ===================
8
9 The chunk :chunk:`particles/type_shapes` stores information about shapes
10 corresponding to particle types. Shape definitions are stored for each type as a
11 UTF-8 encoded JSON string containing key-value pairs. The class of a shape is
12 defined by the ``type`` key. All other keys define properties of that shape.
13 Keys without a default value are required for a valid shape specification.
14
15 Empty (Undefined) Shape
16 -----------------------
17
18 An empty dictionary can be used for undefined shapes. A visualization
19 application may choose how to interpret this, e.g. by drawing nothing or drawing
20 spheres.
21
22 Example::
23
24 {}
25
26 Spheres
27 -------
28
29 Type: ``Sphere``
30
31 Spheres' dimensionality (2D circles or 3D spheres) can be inferred from the
32 system box dimensionality.
33
34 =============== =============== ====== ==== ======= ======
35 Key Description Type Size Default Units
36 =============== =============== ====== ==== ======= ======
37 diameter Sphere diameter float 1x1 length
38 =============== =============== ====== ==== ======= ======
39
40 Example::
41
42 {
43 "type": "Sphere",
44 "diameter": 2.0
45 }
46
47 Ellipsoids
48 ----------
49
50 Type: ``Ellipsoid``
51
52 The ellipsoid class has principal axes a, b, c corresponding to its radii in the
53 x, y, and z directions.
54
55 =============== ===================== ====== ==== ======= ======
56 Key Description Type Size Default Units
57 =============== ===================== ====== ==== ======= ======
58 a Radius in x direction float 1x1 length
59 b Radius in y direction float 1x1 length
60 c Radius in z direction float 1x1 length
61 =============== ===================== ====== ==== ======= ======
62
63 Example::
64
65 {
66 "type": "Ellipsoid",
67 "a": 7.0,
68 "b": 5.0,
69 "c": 3.0
70 }
71
72 Polygons
73 --------
74
75 Type: ``Polygon``
76
77 A simple polygon with its vertices specified in a counterclockwise order.
78 Spheropolygons can be represented using this shape type, through the
79 ``rounding_radius`` key.
80
81 =============== =============== ===== ==== ======= ======
82 Key Description Type Size Default Units
83 =============== =============== ===== ==== ======= ======
84 rounding_radius Rounding radius float 1x1 0.0 length
85 vertices Shape vertices float Nx2 length
86 =============== =============== ===== ==== ======= ======
87
88 Example::
89
90 {
91 "type": "Polygon",
92 "rounding_radius": 0.1,
93 "vertices": [[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5]]
94 }
95
96 Convex Polyhedra
97 ----------------
98
99 Type: ``ConvexPolyhedron``
100
101 A convex polyhedron with vertices specifying the convex hull of the shape.
102 Spheropolyhedra can be represented using this shape type, through the
103 ``rounding_radius`` key.
104
105 =============== =============== ===== ==== ======= ======
106 Key Description Type Size Default Units
107 =============== =============== ===== ==== ======= ======
108 rounding_radius Rounding radius float 1x1 0.0 length
109 vertices Shape vertices float Nx3 length
110 =============== =============== ===== ==== ======= ======
111
112 Example::
113
114 {
115 "type": "ConvexPolyhedron",
116 "rounding_radius": 0.1,
117 "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]]
118 }
119
120 General 3D Meshes
121 -----------------
122
123 Type: ``Mesh``
124
125 A list of lists of indices are used to specify faces. Faces must contain 3 or
126 more vertex indices. The vertex indices must be zero-based. Faces must be
127 defined with a counterclockwise winding order (to produce an "outward" normal).
128
129 =============== ================ ====== ==== ======= ======
130 Key Description Type Size Default Units
131 =============== ================ ====== ==== ======= ======
132 vertices Shape vertices float Nx3 length
133 indices Vertices indices uint32 number
134 =============== ================ ====== ==== ======= ======
135
136
137 Example::
138
139 {
140 "type": "Mesh",
141 "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]],
142 "indices": [[0, 1, 2], [0, 3, 1], [0, 2, 3], [1, 3, 2]]
143 }
144
145 Sphere Unions
146 -------------
147
148 Type: ``SphereUnion``
149
150 A collection of spheres, defined by their diameters and centers.
151
152 =============== ================ ===== ==== ======= ======
153 Key Description Type Size Default Units
154 =============== ================ ===== ==== ======= ======
155 diameters Sphere diameters float Nx1 length
156 centers Sphere centers float Nx3 length
157 =============== ================ ===== ==== ======= ======
158
159 Example::
160
161 {
162 "type": "SphereUnion",
163 "centers": [[0, 0, 1.0], [0, 1.0, 0], [1.0, 0, 0]],
164 "diameters": [0.5, 0.5, 0.5]
165 }