Mercurial Hosting > traffic-intelligence
changeset 771:bd13937818a4 dev
minor bug fix
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 22 Jan 2016 17:43:09 -0500 |
parents | 0f6b0f63eb07 |
children | e92a96f2bdd3 |
files | python/moving.py |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Thu Jan 21 23:44:51 2016 -0500 +++ b/python/moving.py Fri Jan 22 17:43:09 2016 -0500 @@ -217,6 +217,10 @@ def plot(self, options = 'o', **kwargs): plot([self.x], [self.y], options, **kwargs) + @staticmethod + def plotSegment(p1, p2, options = 'o', **kwargs): + plot([p1.x, p2.x], [p1.y, p2.y], options, **kwargs) + def norm2Squared(self): '''2-norm distance (Euclidean distance)''' return self.x**2+self.y**2 @@ -845,14 +849,14 @@ def getIntersections(self, p1, p2): '''Returns a list of the indices at which the trajectory intersects with the segment of extremities p1 and p2 - the list is empty if there is no crossing''' + Returns an empty list if there is no crossing''' indices = [] intersections = [] for i in xrange(self.length()-1): q1=self.__getitem__(i) q2=self.__getitem__(i+1) - p = utils.segmentIntersection(q1, q2, p1, p2) + p = segmentIntersection(q1, q2, p1, p2) if p is not None: if q1.x != q2.x: ratio = (p.x-q1.x)/(q2.x-q1.x) @@ -862,19 +866,19 @@ ratio = 0 indices.append(i+ratio) intersections.append(p) - return indices + return indices, intersections def getLineIntersections(self, p1, p2): '''Returns a list of the indices at which the trajectory - intersects with the segment of extremities p1 and p2 - the list is empty if there is no crossing''' + intersects with the line going through p1 and p2 + Returns an empty list if there is no crossing''' indices = [] intersections = [] for i in xrange(self.length()-1): q1=self.__getitem__(i) q2=self.__getitem__(i+1) - p = utils.segmentLineIntersection(p1, p2, q1, q2) + p = segmentLineIntersection(p1, p2, q1, q2) if p is not None: if q1.x != q2.x: ratio = (p.x-q1.x)/(q2.x-q1.x) @@ -989,7 +993,7 @@ '''Returns a list of the indices at which the trajectory goes past the curvilinear coordinate S1 (in provided lane if lane is not None) - the list is empty if there is no crossing''' + Returns an empty list if there is no crossing''' indices = [] for i in xrange(self.length()-1): q1=self.__getitem__(i)