fix transposition bug
[imago.git] / src / intrsc.py
index cbf922a..977ad84 100644 (file)
@@ -30,6 +30,11 @@ def board(image, lines, show_all, do_something):
     # TODO refactor show_all, do_something
     # TODO refactor this into smaller functions
     lines = [dst_sort(l) for l in lines]
     # TODO refactor show_all, do_something
     # TODO refactor this into smaller functions
     lines = [dst_sort(l) for l in lines]
+    an0 = (sum([l[0] for l in lines[0]]) / len(lines[0]) - pi / 2)
+    an1 = (sum([l[0] for l in lines[1]]) / len(lines[1]) - pi / 2)
+    if an0 > an1:
+        lines = [lines[1], lines[0]]
+
     intersections = intersections_from_angl_dist(lines, image.size)
 
     if show_all:
     intersections = intersections_from_angl_dist(lines, image.size)
 
     if show_all:
@@ -129,10 +134,11 @@ def intersection(l1, l2):
     y = (c1 * a2 - a1 * c2) / delim
     return x, y
 
     y = (c1 * a2 - a1 * c2) / delim
     return x, y
 
+# TODO remove the parameter get_all
 def intersections_from_angl_dist(lines, size, get_all=True):
     """Take grid-lines and size of the image. Return intersections."""
 def intersections_from_angl_dist(lines, size, get_all=True):
     """Take grid-lines and size of the image. Return intersections."""
-    lines1 = map(lambda l: to_general(l, size), lines[1])
     lines0 = map(lambda l: to_general(l, size), lines[0])
     lines0 = map(lambda l: to_general(l, size), lines[0])
+    lines1 = map(lambda l: to_general(l, size), lines[1])
     intersections = []
     for l1 in lines1:
         line = []
     intersections = []
     for l1 in lines1:
         line = []