def _slow_calculate_normals(rr, tris):
 rr = rr.astype(np.float64)
 r1 = rr[tris[:, 0], :]
 r2 = rr[tris[:, 1], :]
 r3 = rr[tris[:, 2], :]
 tri_nn = np.cross((r2 - r1), (r3 - r1))
 size = np.sqrt(np.sum((tri_nn * tri_nn), axis=1))
 zidx = np.where((size == 0))[0]
 size[zidx] = 1.0
 tri_nn /= size[:, np.newaxis]
 nn = np.zeros((len(rr), 3))
 for (p, verts) in enumerate(tris):
  nn[verts] += tri_nn[p, :]
 size = np.sqrt(np.sum((nn * nn), axis=1))
 size[(size == 0)] = 1.0
 nn /= size[:, np.newaxis]
 return nn

def _slow_calculate_normals ( rr , tris ) : rr = rr . astype ( np . float64 ) r1 = rr [ tris [ : , 0 ] , : ] r2 = rr [ tris [ : , 1 ] , : ] r3 = rr [ tris [ : , 2 ] , : ] tri_nn = np . cross ( ( r2 - r1 ) , ( r3 - r1 ) ) size = np . sqrt ( np . sum ( ( tri_nn * tri_nn ) , axis = 1 ) ) zidx = np . where ( ( size == 0 ) ) [ 0 ] size [ zidx ] = 1.0 tri_nn /= size [ : , np . newaxis ] nn = np . zeros ( ( len ( rr ) , 3 ) ) for ( p , verts ) in enumerate ( tris ) : nn [ verts ] += tri_nn [ p , : ] size = np . sqrt ( np . sum ( ( nn * nn ) , axis = 1 ) ) size [ ( size == 0 ) ] = 1.0 nn /= size [ : , np . newaxis ] return nn
efficiently compute vertex normals for triangulated surface .