Mercurial Hosting > traffic-intelligence
diff python/moving.py @ 284:f2cf16ad798f
added LCSS for trajectories
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 21 Dec 2012 18:33:36 -0500 |
parents | 8d44fb1756bc |
children | e0d41c7f53d4 |
line wrap: on
line diff
--- a/python/moving.py Fri Dec 21 18:20:12 2012 -0500 +++ b/python/moving.py Fri Dec 21 18:33:36 2012 -0500 @@ -171,6 +171,12 @@ '2-norm distance (Euclidean distance)' return sqrt(self.norm2Squared()) + def norm1(self): + return abs(self.x)+abs(self.y) + + def normMax(self): + return max(abs(self.x),abs(self.y)) + def aslist(self): return [self.x, self.y] @@ -368,6 +374,9 @@ def length(self): return len(self.positions[0]) + def __len__(self): + return self.length() + def addPositionXY(self, x, y): self.positions[0].append(x) self.positions[1].append(y) @@ -496,6 +505,14 @@ # version 2: use shapely polygon contains + @staticmethod + def norm2LCSS(t1, t2, threshold): + return utils.LCSS(t1, t2, threshold, Point.distanceNorm2) + + @staticmethod + def normMaxLCSS(t1, t2, threshold): + return utils.LCSS(t1, t2, threshold, lambda p1, p2: (p1-p2).normMax()) + ################## # Moving Objects ##################