Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 32:48e56179c39e
added ceil function
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Sat, 10 Apr 2010 18:58:43 -0400 |
| parents | c000f37c316d |
| children | 8cafee54466f |
comparison
equal
deleted
inserted
replaced
| 31:c000f37c316d | 32:48e56179c39e |
|---|---|
| 28 | 28 |
| 29 | 29 |
| 30 ######################### | 30 ######################### |
| 31 # maths section | 31 # maths section |
| 32 ######################### | 32 ######################### |
| 33 | |
| 34 def ceilDecimals(v, nDecimals): | |
| 35 '''Rounds the number at the nth decimal | |
| 36 eg 1.23 at 0 decimal is 2, at 1 decimal is 1.3''' | |
| 37 from math import ceil,pow | |
| 38 tens = pow(10,nDecimals) | |
| 39 return ceil(v*tens)/tens | |
| 33 | 40 |
| 34 def segmentIntersection(p1, p2, p3, p4): | 41 def segmentIntersection(p1, p2, p3, p4): |
| 35 '''Returns the intersecting point of the segments [p1, p2] and [p3, p4], None otherwise''' | 42 '''Returns the intersecting point of the segments [p1, p2] and [p3, p4], None otherwise''' |
| 36 from numpy import matrix | 43 from numpy import matrix |
| 37 from numpy.linalg import linalg, det | 44 from numpy.linalg import linalg, det |
