diff python/moving.py @ 381:387cc0142211

script to replay event annotations
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 19 Jul 2013 11:58:35 -0400
parents f1a1923ddff9
children 0ce2210790b1
line wrap: on
line diff
--- a/python/moving.py	Fri Jul 19 09:11:57 2013 -0400
+++ b/python/moving.py	Fri Jul 19 11:58:35 2013 -0400
@@ -520,15 +520,15 @@
             displacement += Point.distanceNorm2(self.__getitem__(i),self.__getitem__(i+1))
         return displacement
 
-    def similarOrientation(self, refDirection, cosineThreshold):
-        '''Indicates whether the majority of the trajectory elements (vectors for velocity) 
+    def similarOrientation(self, refDirection, cosineThreshold, minProportion = 0.5):
+        '''Indicates whether the minProportion (<=1.) (eg half) of the trajectory elements (vectors for velocity) 
         have a cosine with refDirection is smaller than cosineThreshold'''
         count = 0
-        halfLength = float(self.length())/2
+        lengthTreshold = float(self.length())*minProportion
         for p in self:
             if p.similarOrientation(refDirection, cosineThreshold):
                 count += 1
-            if count > halfLength:
+            if count > lengthThreshold:
                 return True
         return False