Efficiently accumulate triangle normals.
(tris, tri_nn, npts)
| 389 | |
| 390 | @jit() |
| 391 | def _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 | |
| 408 | def _triangle_neighbors(tris, npts): |