Skip to content

Commit a2bf5cb

Browse files
committed
ENH: Cleaner normal calculation
1 parent d77cea2 commit a2bf5cb

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

surfer/utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,8 @@ def _compute_normals(rr, tris):
191191
#
192192
nn = np.zeros((npts, 3))
193193
for verts in tris.T: # note this only loops 3x (number of verts per tri)
194-
counts = np.bincount(verts, minlength=npts)
195-
reord = np.argsort(verts)
196-
vals = np.r_[np.zeros((1, 3)), np.cumsum(tri_nn[reord, :], 0)]
197-
idx = np.cumsum(np.r_[0, counts])
198-
nn += vals[idx[1:], :] - vals[idx[:-1], :]
194+
for idx in range(3): # x, y, z
195+
nn[:, idx] += np.bincount(verts, tri_nn[:, idx], minlength=npts)
199196
size = np.sqrt(np.sum(nn * nn, axis=1))
200197
size[size == 0] = 1.0 # prevent ugly divide-by-zero
201198
nn /= size[:, np.newaxis]

0 commit comments

Comments
 (0)