diff python/ubc_utils.py @ 44:be3ae926e4e8

added simple intersection description, function to load collision points
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 31 Jul 2010 23:39:17 -0400
parents 6d11d9e7ad4e
children e27598865af3
line wrap: on
line diff
--- a/python/ubc_utils.py	Wed Jul 14 14:02:11 2010 -0400
+++ b/python/ubc_utils.py	Sat Jul 31 23:39:17 2010 -0400
@@ -59,3 +59,24 @@
     file.close()
     return objects
    
+def loadCollisionPoints(filename, nPoints = -1):
+    '''Loads collision points and returns a dict
+    with keys as a pair of the numbers of the two interacting objects'''
+    file = utils.openCheck(filename)
+    if (not file):
+        return []
+
+    points = {}
+    num = 0
+    lines = getLines(file)
+    while (lines != []) and ((nPoints<0) or (num<nPoints)):
+        parsedLine = [int(n) for n in lines[0].split(' ')]
+        protagonistNums = (parsedLine[0], parsedLine[1])
+        points[protagonistNums] = [[float(n) for n in lines[1].split(' ')],
+                                   [float(n) for n in lines[2].split(' ')]]
+
+        num+=1
+        lines = getLines(file)
+
+    file.close()
+    return points