def test_accumulate_normals():
 n_pts = int(160000.0)
 n_tris = int(320000.0)
 tris = (rng.rand(n_tris, 1) * (n_pts - 2)).astype(int)
 tris = np.c_[(tris, (tris + 1), (tris + 2))]
 tri_nn = rng.rand(n_tris, 3)
 this = dict(tris=tris, np=n_pts, ntri=n_tris, tri_nn=tri_nn)
 this['nn'] = np.zeros((this['np'], 3))
 for p in range(this['ntri']):
  verts = this['tris'][p]
  this['nn'][verts, :] += this['tri_nn'][p, :]
 nn = _accumulate_normals(this['tris'], this['tri_nn'], this['np'])
 assert_allclose(nn, this['nn'], rtol=1e-07, atol=1e-07)

def test_accumulate_normals ( ) : n_pts = int ( 160000.0 ) n_tris = int ( 320000.0 ) tris = ( rng . rand ( n_tris , 1 ) * ( n_pts - 2 ) ) . astype ( int ) tris = np . c_ [ ( tris , ( tris + 1 ) , ( tris + 2 ) ) ] tri_nn = rng . rand ( n_tris , 3 ) this = dict ( tris = tris , np = n_pts , ntri = n_tris , tri_nn = tri_nn ) this [ 'nn' ] = np . zeros ( ( this [ 'np' ] , 3 ) ) for p in range ( this [ 'ntri' ] ) : verts = this [ 'tris' ] [ p ] this [ 'nn' ] [ verts , : ] += this [ 'tri_nn' ] [ p , : ] nn = _accumulate_normals ( this [ 'tris' ] , this [ 'tri_nn' ] , this [ 'np' ] ) assert_allclose ( nn , this [ 'nn' ] , rtol = 1e-07 , atol = 1e-07 )
test efficient normal accumulation for surfaces .