Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 531:f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 27 Jun 2014 17:32:11 -0400 |
| parents | 37830a831818 |
| children | a3add9f751ef 6c0923f1ce68 |
comparison
equal
deleted
inserted
replaced
| 530:d6445cbe7791 | 531:f012a8ad7a0e |
|---|---|
| 288 deltaRoot = sqrt(delta) | 288 deltaRoot = sqrt(delta) |
| 289 ttc1 = (-b + deltaRoot)/(2*a) | 289 ttc1 = (-b + deltaRoot)/(2*a) |
| 290 ttc2 = (-b - deltaRoot)/(2*a) | 290 ttc2 = (-b - deltaRoot)/(2*a) |
| 291 if ttc1 >= 0 and ttc2 >= 0: | 291 if ttc1 >= 0 and ttc2 >= 0: |
| 292 ttc = min(ttc1,ttc2) | 292 ttc = min(ttc1,ttc2) |
| 293 else: | 293 elif ttc1 >= 0: |
| 294 if ttc1 < 0: | 294 ttc = ttc1 |
| 295 ttc = ttc2 | 295 elif ttc2 >= 0: |
| 296 elif ttc2 < 0: | 296 ttc = ttc2 |
| 297 ttc = ttc1 | 297 else: # ttc1 < 0 and ttc2 < 0: |
| 298 else: # ttc1 < 0 and ttc2 < 0: | 298 ttc = None |
| 299 ttc = None | |
| 300 else: | 299 else: |
| 301 ttc = None | 300 ttc = None |
| 302 return ttc | 301 return ttc |
| 303 | 302 |
| 304 | 303 |
