mesh_connectivity_matrix

compas.datastructures.mesh_connectivity_matrix(mesh, rtype='array')[source]

Creates a connectivity matrix from a Mesh datastructure.

Parameters
  • mesh (compas.datastructures.Mesh) – Instance of mesh.

  • rtype ({‘array’, ‘csc’, ‘csr’, ‘coo’, ‘list’}) – Format of the result.

Returns

array-like – Constructed connectivity matrix.

Examples

>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_polyhedron(6)
>>> C = mesh_connectivity_matrix(mesh)
>>> type(C)
<class 'numpy.ndarray'>
>>> C = mesh_connectivity_matrix(mesh, rtype='csr')
>>> type(C)
<class 'scipy.sparse.csr.csr_matrix'>
>>> xyz = asarray(mesh.vertices_attributes('xyz'))
>>> C = mesh_connectivity_matrix(mesh, rtype='csr')
>>> uv = C.dot(xyz)