Skip to content

Instantly share code, notes, and snippets.

@Chandler
Last active July 10, 2020 18:49
Show Gist options
  • Save Chandler/3bcd07253580e07b3e57fb27e30c3c36 to your computer and use it in GitHub Desktop.
Save Chandler/3bcd07253580e07b3e57fb27e30c3c36 to your computer and use it in GitHub Desktop.
import igl
import numpy as np
import polyscope as ps
import scipy
# https://www.cs.cmu.edu/~kmcrane/Projects/ModelRepository/spot.zip
path = "/Users/cbabraham/data/mesh/spot/spot_triangulated.obj"
verts,faces = igl.read_triangle_mesh(path)
ps.init()
original = ps.register_surface_mesh("mesh", verts, faces)
L = igl.cotmatrix(verts, faces)
M = igl.massmatrix(verts, faces)
# eigendecomposition of the laplacian
eigenvals, eigenvecs = scipy.sparse.linalg.eigsh(L, 6, M)
for i, eigenvector in enumerate(eigenvecs.swapaxes(0,1)):
original.add_scalar_quantity(
"eigenvector-{}".format(i),
eigenvector.astype(np.float32), # discard complex components
defined_on='vertices'
)
ps.show()
@Chandler
Copy link
Author

Not sure exactly what I was expecting but this doesn't seem right.
Screen Shot 2020-07-10 at 10 37 44 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment