comparison python/moving.py @ 582:7e1ae4d97f1a

corrected bug for curvilinear trajectory with only one position and differentiation
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 18 Sep 2014 15:36:57 -0400
parents 10e8a9f2bd9f
children 6ebfb43e938e
comparison
equal deleted inserted replaced
581:10e8a9f2bd9f 582:7e1ae4d97f1a
612 return len(self.positions[0]) 612 return len(self.positions[0])
613 613
614 def length(self): 614 def length(self):
615 return self.__len__() 615 return self.__len__()
616 616
617 def empty(self):
618 return self.__len__() == 0
619
617 def __getitem__(self, i): 620 def __getitem__(self, i):
618 if isinstance(i, int): 621 if isinstance(i, int):
619 return Point(self.positions[0][i], self.positions[1][i]) 622 return Point(self.positions[0][i], self.positions[1][i])
620 else: 623 else:
621 raise TypeError, "Invalid argument type." 624 raise TypeError, "Invalid argument type."
882 p1 = self[0] 885 p1 = self[0]
883 for i in xrange(1, self.length()): 886 for i in xrange(1, self.length()):
884 p2 = self[i] 887 p2 = self[i]
885 diff.addPositionSYL(p2[0]-p1[0], p2[1]-p1[1], p1[2]) 888 diff.addPositionSYL(p2[0]-p1[0], p2[1]-p1[1], p1[2])
886 p1=p2 889 p1=p2
887 if doubleLastPosition: 890 if doubleLastPosition and self.length() > 1:
888 diff.addPosition(diff[-1]) 891 diff.addPosition(diff[-1])
889 return diff 892 return diff
890 893
891 def getIntersections(self, S1, lane = None): 894 def getIntersections(self, S1, lane = None):
892 '''Returns a list of the indices at which the trajectory 895 '''Returns a list of the indices at which the trajectory