diff python/moving.py @ 339:9c1818a71c9c

minor
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 19 Jun 2013 22:56:21 -0400
parents 3950bfe22768
children 74e437ab5f11
line wrap: on
line diff
--- a/python/moving.py	Mon Jun 17 16:26:11 2013 -0400
+++ b/python/moving.py	Wed Jun 19 22:56:21 2013 -0400
@@ -254,6 +254,8 @@
         norm = p.norm2()
         if norm > 0:
             angle = atan2(p.y, p.x)
+        else:
+            angle = 0.
         return NormAngle(norm, angle)
 
     def __add__(self, other):
@@ -458,6 +460,12 @@
             return Trajectory([[a-b for a,b in zip(self.getXCoordinates(),traj2.getXCoordinates())],
                                [a-b for a,b in zip(self.getYCoordinates(),traj2.getYCoordinates())]])
 
+    def differentiate(self):
+        diff = Trajectory()
+        for i in xrange(1, self.length()):
+            diff.addPosition(self[i]-self[i-1])
+        return diff
+
     def norm(self):
         '''Returns the list of the norms at each instant'''
 #        def add(x, y): return x+y