dem.utils

Overview

Details

Various helper utilities for geometry.

hoomd.dem.utils.area(vertices, factor=1.0)

Computes the signed area of a polygon in 2 or 3D.

Parameters
  • vertices (list) – (x, y) or (x, y, z) coordinates for each vertex

  • factor (float) – Factor to scale the resulting area by

hoomd.dem.utils.center(vertices, faces=None)

Centers shapes in 2D or 3D.

Parameters
  • vertices (list) – List of (x, y) or (x, y, z) coordinates in 2D or 3D, respectively

  • faces (list) – List of vertex indices for 3D polyhedra, or None for 2D. Faces should be in right-hand order.

Returns a list of vertices shifted to have the center of mass of the given points at the origin. Shapes should be specified in right-handed order. If the input shape has no mass, return the input.

Warning

All faces should be specified in right-handed order.

hoomd.dem.utils.convexHull(vertices, tol=1e-06)

Compute the 3D convex hull of a set of vertices and merge coplanar faces.

Parameters
  • vertices (list) – List of (x, y, z) coordinates

  • tol (float) – Floating point tolerance for merging coplanar faces

Returns an array of vertices and a list of faces (vertex indices) for the convex hull of the given set of vertice.

Note

This method uses scipy’s quickhull wrapper and therefore requires scipy.

hoomd.dem.utils.massProperties(vertices, faces=None, factor=1.0)

Compute the mass, center of mass, and inertia tensor of a polygon or polyhedron

Parameters
  • vertices (list) – List of (x, y) or (x, y, z) coordinates in 2D or 3D, respectively

  • faces (list) – List of vertex indices for 3D polyhedra, or None for 2D. Faces should be in right-hand order.

  • factor (float) – Factor to scale the resulting results by

Returns (mass, center of mass, moment of inertia tensor in (xx, xy, xz, yy, yz, zz) order) specified by the given list of vertices and faces. Note that the faces must be listed in a consistent order so that normals are all pointing in the correct direction from the face. If given a list of 2D vertices, return the same but for the 2D polygon specified by the vertices.

Warning

All faces should be specified in right-handed order.

The computation for the 3D case follows “Polyhedral Mass Properties (Revisited) by David Eberly, available at:

http://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf

hoomd.dem.utils.rmax(vertices, radius=0.0, factor=1.0)

Compute the maximum distance among a set of vertices

Parameters
  • vertices (list) – list of (x, y) or (x, y, z) coordinates

  • factor (float) – Factor to scale the result by

hoomd.dem.utils.spheroArea(vertices, radius=1.0, factor=1.0)

Computes the area of a spheropolygon.

Parameters
  • vertices (list) – List of (x, y) coordinates, in right-handed (counterclockwise) order

  • radius (float) – Rounding radius of the disk to expand the polygon by

  • factor (float) – Factor to scale the resulting area by