diff 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
line wrap: on
line diff
--- a/python/moving.py	Wed Sep 17 17:29:19 2014 -0400
+++ b/python/moving.py	Thu Sep 18 15:36:57 2014 -0400
@@ -614,6 +614,9 @@
     def length(self):
         return self.__len__()
 
+    def empty(self):
+        return self.__len__() == 0
+
     def __getitem__(self, i):
         if isinstance(i, int):
             return Point(self.positions[0][i], self.positions[1][i])
@@ -884,7 +887,7 @@
             p2 = self[i]
             diff.addPositionSYL(p2[0]-p1[0], p2[1]-p1[1], p1[2])
             p1=p2
-        if doubleLastPosition:
+        if doubleLastPosition and self.length() > 1:
             diff.addPosition(diff[-1])
         return diff