Mercurial Hosting > traffic-intelligence
changeset 49:1fb5606506ae
re-arrangement
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sat, 25 Sep 2010 11:33:07 -0400 |
parents | 8aed225f71d8 |
children | 7b06d649122b |
files | python/moving.py |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Thu Sep 23 17:24:31 2010 -0400 +++ b/python/moving.py Sat Sep 25 11:33:07 2010 -0400 @@ -135,6 +135,7 @@ '2-norm distance (Euclidean distance)' return sqrt(self.norm2Squared()) + @staticmethod def distanceNorm2(p1, p2): return (p1-p2).norm2() @@ -225,6 +226,15 @@ # return sqrt(sq) return [hypot(x,y) for x,y in zip(self.positions[0], self.positions[1])] + def cumulatedDisplacement(self): + displacement = 0 + for i in xrange(self.length()-1): + displacement += Point.distanceNorm2(self.__getitem__(i),self.__getitem__(i+1)) + return displacement + + def wiggliness(self): + return self.cumulatedDisplacement()/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) + def getTrajectoryInInterval(self, inter): if inter.first >=0 and inter.last<= self.length(): return Trajectory([self.positions[0][inter.first:inter.last], @@ -271,6 +281,9 @@ def getVelocities(self): return self.velocities + def getSpeeds(self): + return self.getVelocities().norm() + def getPositionAt(self, i): return self.positions[i]