Mercurial Hosting > traffic-intelligence
diff python/moving.py @ 881:8ba82b371eea
work on storing PET
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 14 Mar 2017 17:48:40 -0400 |
parents | 000555430b28 |
children | e2452abba0e7 |
line wrap: on
line diff
--- a/python/moving.py Tue Mar 14 17:10:35 2017 -0400 +++ b/python/moving.py Tue Mar 14 17:48:40 2017 -0400 @@ -340,16 +340,15 @@ ttc1 = (-b + deltaRoot)/(2*a) ttc2 = (-b - deltaRoot)/(2*a) if ttc1 >= 0 and ttc2 >= 0: - ttc = min(ttc1,ttc2) + return min(ttc1,ttc2) elif ttc1 >= 0: - ttc = ttc1 + return ttc1 elif ttc2 >= 0: - ttc = ttc2 + return ttc2 else: # ttc1 < 0 and ttc2 < 0: - ttc = None + return None else: - ttc = None - return ttc + return None @staticmethod def midPoint(p1, p2): @@ -1428,9 +1427,6 @@ '''Post-encroachment time based on distance threshold Returns the smallest time difference when the object positions are within collisionDistanceThreshold''' - #for i in xrange(int(obj1.length())-1): - # for j in xrange(int(obj2.length())-1): - # inter = segmentIntersection(obj1.getPositionAt(i), obj1.getPositionAt(i+1), obj2.getPositionAt(i), obj2.getPositionAt(i+1)) positions1 = [p.astuple() for p in obj1.getPositions()] positions2 = [p.astuple() for p in obj2.getPositions()] pets = zeros((int(obj1.length()), int(obj2.length()))) @@ -1439,6 +1435,7 @@ pets[i,j] = abs(t1-t2) distances = cdist(positions1, positions2, metric = 'euclidean') if distances.min() <= collisionDistanceThreshold: + #idx = distances.argmin() return pets[distances <= collisionDistanceThreshold].min() else: return None