# HG changeset patch # User Nicolas Saunier # Date 1453502589 18000 # Node ID bd13937818a4a7f009db4bd5f13553eee115a453 # Parent 0f6b0f63eb073dfd4d2612b1be8afb913ff91d78 minor bug fix diff -r 0f6b0f63eb07 -r bd13937818a4 python/moving.py --- 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)