Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 55:88d5ee5ac164
updated comments and added shell for interaction between road users
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 13 Oct 2010 19:19:17 -0400 |
| parents | c354d41ef7cd |
| children | 61fe73df2d36 |
comparison
equal
deleted
inserted
replaced
| 54:c354d41ef7cd | 55:88d5ee5ac164 |
|---|---|
| 299 | 299 |
| 300 def draw(self, options = ''): | 300 def draw(self, options = ''): |
| 301 self.positions.draw(options) | 301 self.positions.draw(options) |
| 302 | 302 |
| 303 def getInstantPassingLane(self, p1, p2): | 303 def getInstantPassingLane(self, p1, p2): |
| 304 '''Returns the instant(s) the object passes from one side of the segment to the other | 304 '''Returns the instant(s) |
| 305 empty list if not''' | 305 at which the object passes from one side of the segment to the other |
| 306 empty list if there is no crossing''' | |
| 306 instants = [] | 307 instants = [] |
| 307 | 308 |
| 308 for i in xrange(self.length()-1): | 309 for i in xrange(self.length()-1): |
| 309 p = utils.segmentIntersection(self.positions[i], self.positions[i+1], p1, p2) | 310 p = utils.segmentIntersection(self.positions[i], self.positions[i+1], p1, p2) |
| 310 if p: | 311 if p: |
| 328 | 329 |
| 329 def __init__(self, name, values = {}): | 330 def __init__(self, name, values = {}): |
| 330 self.name = name | 331 self.name = name |
| 331 self.values = values | 332 self.values = values |
| 332 | 333 |
| 334 class Interaction(STObject): | |
| 335 '''Class for an interaction between two road users | |
| 336 or a road user and an obstacle | |
| 337 | |
| 338 link to the moving objects | |
| 339 ''' | |
| 340 | |
| 341 def __init__(self, num = None, timeInterval = None, protagonistNum1 = None, protagonistNum2 = None, movingObject1 = None, movingObject2 = None): | |
| 342 STObject.__init__(self, num, timeInterval) | |
| 343 self.protagonistNum1 = protagonistNum1 | |
| 344 self.protagonistNum2 = protagonistNum2 | |
| 345 self.movingObject1 = movingObject1 | |
| 346 self.movingObject2 = movingObject2 | |
| 347 | |
| 333 if __name__ == "__main__": | 348 if __name__ == "__main__": |
| 334 import doctest | 349 import doctest |
| 335 import unittest | 350 import unittest |
| 336 suite = doctest.DocFileSuite('tests/moving.txt') | 351 suite = doctest.DocFileSuite('tests/moving.txt') |
| 337 #suite = doctest.DocTestSuite() | 352 #suite = doctest.DocTestSuite() |
| 338 unittest.TextTestRunner().run(suite) | 353 unittest.TextTestRunner().run(suite) |
| 339 #doctest.testmod() | 354 #doctest.testmod() |
| 340 #doctest.testfile("example.txt") | 355 #doctest.testfile("example.txt") |
| 356 |
