MCPcopy
hub / github.com/mne-tools/mne-python / _accumulate_normals

Function _accumulate_normals

mne/surface.py:391–405  ·  view source on GitHub ↗

Efficiently accumulate triangle normals.

(tris, tri_nn, npts)

Source from the content-addressed store, hash-verified

389
390@jit()
391def _accumulate_normals(tris, tri_nn, npts):
392 """Efficiently accumulate triangle normals."""
393 # this code replaces the following, but is faster (vectorized):
394 #
395 # this['nn'] = np.zeros((this['np'], 3))
396 # for p in xrange(this['ntri']):
397 # verts = this['tris'][p]
398 # this['nn'][verts, :] += this['tri_nn'][p, :]
399 #
400 nn = np.zeros((npts, 3))
401 for vi in range(3):
402 verts = tris[:, vi]
403 for idx in range(3): # x, y, z
404 nn[:, idx] += bincount(verts, weights=tri_nn[:, idx], minlength=npts)
405 return nn
406
407
408def _triangle_neighbors(tris, npts):

Callers 3

test_accumulate_normalsFunction · 0.90
_project_onto_surfaceFunction · 0.85
complete_surface_infoFunction · 0.85

Calls 1

bincountFunction · 0.85

Tested by 1

test_accumulate_normalsFunction · 0.72