diff python/moving.py @ 91:daa05fae1a70

modified the type of the result of interval lengths to float, added comments
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 09 Jun 2011 16:03:17 -0400
parents f84293ad4611
children a5ef9e40688e
line wrap: on
line diff
--- a/python/moving.py	Thu Jun 09 11:27:31 2011 -0400
+++ b/python/moving.py	Thu Jun 09 16:03:17 2011 -0400
@@ -30,7 +30,7 @@
 
     def length(self):
         '''Returns the length of the interval'''
-        return max(0,self.last-self.first)
+        return float(max(0,self.last-self.first))
 
     def getList(self):
         return [self.first, self.last]
@@ -52,7 +52,7 @@
 
 
 class TimeInterval(Interval):
-    '''Temporal interval
+    '''Temporal interval based on frame numbers (hence the modified length method)
     may be modified directly by setting first and last'''
 
     def __init__(self, first=0, last=-1):
@@ -75,7 +75,7 @@
 
     def length(self):
         '''Returns the length of the interval'''
-        return max(0,self.last-self.first+1)
+        return float(max(0,self.last-self.first+1))
 
 # class BoundingPolygon:
 #     '''Class for a polygon bounding a set of points
@@ -272,6 +272,7 @@
         return [hypot(x,y) for x,y in zip(self.positions[0], self.positions[1])]
 
     def cumulatedDisplacement(self):
+        'Returns the sum of the distances between each successive point'
         displacement = 0
         for i in xrange(self.length()-1):
             displacement += Point.distanceNorm2(self.__getitem__(i),self.__getitem__(i+1))
@@ -282,7 +283,8 @@
 
     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'''
+        intersects with the segment of extremities p1 and p2 
+        the list is empty if there is no crossing'''
         indices = []
 
         for i in xrange(self.length()-1):