mesh_laplacian_matrix

compas.datastructures.mesh_laplacian_matrix(mesh, rtype='csr')[source]

Construct a Laplacian matrix with uniform weights from a mesh data structure.

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

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

Returns

array-like – The Laplacian matrix.

Notes

The \(n \times n\) uniform Laplacian matrix \(\mathbf{L}\) of a mesh with vertices \(\mathbf{V}\) and edges \(\mathbf{E}\) is defined as follows 1

\[\begin{split}\mathbf{L}_{ij} = \begin{cases} -1 & i = j \\ \frac{1}{deg(i)} & (i, j) \in \mathbf{E} \\ 0 & \text{otherwise} \end{cases}\end{split}\]

with \(deg(i)\) the degree of vertex \(i\).

Therefore, the uniform Laplacian of a vertex \(\mathbf{v}_{i}\) points to the centroid of its neighboring vertices.

Examples

>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_polyhedron(6)
>>> L = mesh_laplacian_matrix(mesh, rtype='array')
>>> type(L)
<class 'numpy.ndarray'>
>>> L = mesh_face_matrix(mesh, rtype='csr')
>>> type(L)
<class 'scipy.sparse.csr.csr_matrix'>
>>> xyz = asarray(mesh.vertices_attributes('xyz'))
>>> L = mesh_laplacian_matrix(mesh)
>>> d = L.dot(xyz)

References

1

Nealen A., Igarashi T., Sorkine O. and Alexa M. Laplacian Mesh Optimization.