Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 698:8d99a9e16644 dev
added clarification comments
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 17 Jul 2015 14:28:14 -0400 |
| parents | 9990ef119bce |
| children | c35e4a4b199d |
comparison
equal
deleted
inserted
replaced
| 697:0421a5a0072c | 698:8d99a9e16644 |
|---|---|
| 238 eg 1.23 at 0 decimal is 2, at 1 decimal is 1.3''' | 238 eg 1.23 at 0 decimal is 2, at 1 decimal is 1.3''' |
| 239 tens = 10**nDecimals | 239 tens = 10**nDecimals |
| 240 return ceil(v*tens)/tens | 240 return ceil(v*tens)/tens |
| 241 | 241 |
| 242 def inBetween(bound1, bound2, x): | 242 def inBetween(bound1, bound2, x): |
| 243 'useful if one does not know the order of bound1/bound2' | |
| 243 return bound1 <= x <= bound2 or bound2 <= x <= bound1 | 244 return bound1 <= x <= bound2 or bound2 <= x <= bound1 |
| 244 | 245 |
| 245 def pointDistanceL2(x1,y1,x2,y2): | 246 def pointDistanceL2(x1,y1,x2,y2): |
| 246 ''' Compute point-to-point distance (L2 norm, ie Euclidean distance)''' | 247 ''' Compute point-to-point distance (L2 norm, ie Euclidean distance)''' |
| 247 return sqrt((x2-x1)**2+(y2-y1)**2) | 248 return sqrt((x2-x1)**2+(y2-y1)**2) |
