comparison python/processing.py @ 1012:01db14e947e4

resolved
author Wendlasida
date Fri, 01 Jun 2018 10:47:49 -0400
parents 933670761a57
children
comparison
equal deleted inserted replaced
1011:4f0312bee393 1012:01db14e947e4
11 objectsNotInZone = [] 11 objectsNotInZone = []
12 import matplotlib.nxutils as nx 12 import matplotlib.nxutils as nx
13 for o in objects: 13 for o in objects:
14 inPolygon = nx.points_inside_poly(o.getPositions().asArray().T, zone.T) 14 inPolygon = nx.points_inside_poly(o.getPositions().asArray().T, zone.T)
15 if inPolygon.any(): 15 if inPolygon.any():
16 objspeeds = [o.getVelocityAt(i).norm2() for i in xrange(int(o.length()-1)) if inPolygon[i]] 16 objspeeds = [o.getVelocityAt(i).norm2() for i in range(int(o.length()-1)) if inPolygon[i]]
17 speeds[o.num] = np.mean(objspeeds) # km/h 17 speeds[o.num] = np.mean(objspeeds) # km/h
18 else: 18 else:
19 objectsNotInZone.append(o) 19 objectsNotInZone.append(o)
20 return speeds.values(), speeds, objectsNotInZone 20 return speeds, objectsNotInZone