diff python/utils.py @ 569:0057c04f94d5

work in progress on intersections (for PET)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 06 Aug 2014 17:53:38 -0400
parents ee45c6eb6d49
children e24eeb244698
line wrap: on
line diff
--- a/python/utils.py	Tue Aug 05 17:45:36 2014 -0400
+++ b/python/utils.py	Wed Aug 06 17:53:38 2014 -0400
@@ -4,6 +4,7 @@
 #from numpy import *
 #from pylab import *
 from datetime import time, datetime
+from math import sqrt
 
 __metaclass__ = type
 
@@ -241,7 +242,11 @@
     return ceil(v*tens)/tens
 
 def inBetween(bound1, bound2, x):
-    return bound1 <= x <= bound2 or bound2 <= x<= bound1
+    return bound1 <= x <= bound2 or bound2 <= x <= bound1
+
+def pointDistanceL2(x1,y1,x2,y2):
+    ''' Compute point-to-point distance (L2 norm, ie Euclidean distance)'''
+    return sqrt((x2-x1)**2+(y2-y1)**2)
 
 def crossProduct(l1, l2):
     return l1[0]*l2[1]-l1[1]*l2[0]