Skip to content

Vector Quantities

Visualize vector-valued data at the elements of a volume mesh.

volume mesh vector values

Example: showing vectors on vertices (here random vectors)

# ... initialization, create mesh ...

ps_vol = ps.register_volume_mesh("test volume mesh", verts, tets=tets)

n_vert = verts.shape[0]
n_cell = tets.shape[0]

# Add vectors on vertices (with some options set)
vecs = np.random.rand(n_vert, 3)
ps_vol.add_vector("my color", vecs, enabled=True, vectortype='ambient')

# Show the GUI
ps.show()

Add vectors to elements

VolumeMesh.add_vector_quantity(name, values, defined_on='vertices', enabled=None, vectortype="standard", length=None, radius=None, color=None)

Add a vector quantity to the mesh.

  • name string, a name for the quantity
  • values an Nx3 numpy array, vectors at vertices/cells
  • defined_on string, one of vertices or cells, is this data a vector per-vertex or a vector per-cell?

This function also accepts optional keyword arguments listed below, which customize the appearance and behavior of the quantity.

Vector Quantity Options

When adding a vector quantity, the following keyword options can be set. These are available for all kinds of vector quantities on all structures.

Keyword arguments:

  • enabled boolean, whether the quantity is initially enabled (Default: false)
  • vectortype, one of "standard" or "ambient". Ambient vectors don’t get auto-scaled, and thus are good for representing values in absolute 3D world coordinates. (Default: "standard")
  • length float, a (relative) length for the vectors
  • radius float, a (relative) radius for the vectors
  • color 3-tuple, color for the vectors

If not specified, these optional parameters will assume a reasonable default value, or a persistent value if previously set.