MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compute_cotan_field

Function compute_cotan_field

scripts/geodesic.py:32–46  ·  view source on GitHub ↗
(mesh)

Source from the content-addressed store, hash-verified

30 mesh.set_attribute("edges", np.ravel(edges));
31
32def compute_cotan_field(mesh):
33 cotans = [];
34 edges = mesh.get_attribute("edges").reshape((-1, 3));
35 for i,f in enumerate(mesh.faces):
36 e0 = edges[i*3];
37 e1 = edges[i*3+1];
38 e2 = edges[i*3+2];
39 c0 = np.dot(e0, -e2) / norm(np.cross(e0, -e2));
40 c1 = np.dot(e1, -e0) / norm(np.cross(e1, -e0));
41 c2 = np.dot(e2, -e1) / norm(np.cross(e2, -e1));
42 cotans.append(c0);
43 cotans.append(c1);
44 cotans.append(c2);
45 mesh.add_attribute("cotan");
46 mesh.set_attribute("cotan", np.ravel(cotans));
47
48def compute_area_and_normal_field(mesh):
49 mesh.add_attribute("face_area");

Callers 1

mainFunction · 0.85

Calls 4

enumerateFunction · 0.85
get_attributeMethod · 0.45
add_attributeMethod · 0.45
set_attributeMethod · 0.45

Tested by

no test coverage detected