comparison python/processing.py @ 998:933670761a57

updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 27 May 2018 23:22:48 -0400
parents 15e244d2a1b5
children
comparison
equal deleted inserted replaced
997:4f3387a242a1 998:933670761a57
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