Mercurial Hosting > traffic-intelligence
changeset 487:e04b22ce2fcd
generalized createInteractions to 2 lists of objects (for cars and pedestrians for example)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 04 Apr 2014 17:43:56 -0400 |
parents | a5847c0ca27c |
children | 247f403dfed7 000bddf84ad0 |
files | python/events.py |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/python/events.py Thu Apr 03 17:48:27 2014 -0400 +++ b/python/events.py Fri Apr 04 17:43:56 2014 -0400 @@ -148,14 +148,17 @@ ''' interaction types: conflict or collision if they are known''' self.interactionType= interactionType -def createInteractions(objects): - '''Create all interactions of two co-existing road users +def createInteractions(objects, _others = None): + '''Create all interactions of two co-existing road users''' + if _others != None: + others = _others - todo add test to compute categories?''' interactions = [] num = 0 for i in xrange(len(objects)): - for j in xrange(i): + if _others == None: + others = objects[:i] + for j in xrange(len(others)): commonTimeInterval = objects[i].commonTimeInterval(objects[j]) if not commonTimeInterval.empty(): interactions.append(Interaction(num, commonTimeInterval, objects[i].num, objects[j].num, objects[i], objects[j]))