cleaner code
[imago.git] / intrsc.py
index cead665..00165b1 100644 (file)
--- a/intrsc.py
+++ b/intrsc.py
@@ -1,7 +1,7 @@
-from math import sin, cos, tan
+from math import cos, tan
 from operator import itemgetter
 
 from operator import itemgetter
 
-import Image, ImageDraw
+import ImageDraw
 
 def board(image, lines, show_all, do_something):
     intersections = intersections_from_angl_dist(lines, image.size)
 
 def board(image, lines, show_all, do_something):
     intersections = intersections_from_angl_dist(lines, image.size)
@@ -14,12 +14,12 @@ def board(image, lines, show_all, do_something):
     if show_all:
         do_something(image_g, "intersections")
 
     if show_all:
         do_something(image_g, "intersections")
 
-    board = []
+    board_r = []
     
     for line in intersections:
     
     for line in intersections:
-        board.append([stone_color(image, intersection) for intersection in
+        board_r.append([stone_color(image, intersection) for intersection in
                       line])
                       line])
-    return board
+    return board_r
 
 def intersections_from_angl_dist(lines, size, get_all=False):
     intersections = []
 
 def intersections_from_angl_dist(lines, size, get_all=False):
     intersections = []
@@ -27,7 +27,8 @@ def intersections_from_angl_dist(lines, size, get_all=False):
         line = []
         for (angl2, dist2) in sorted(lines[0], key=itemgetter(1)):
             if abs(angl1 - angl2) > 0.4:
         line = []
         for (angl2, dist2) in sorted(lines[0], key=itemgetter(1)):
             if abs(angl1 - angl2) > 0.4:
-                x =  - ((dist2 / cos(angl2)) - (dist1 / cos(angl1))) / (tan(angl1) - tan(angl2))
+                x =  (- ((dist2 / cos(angl2)) - (dist1 / cos(angl1))) 
+                        / (tan(angl1) - tan(angl2)))
                 y = (tan(angl1) * x) - (dist1 / cos(angl1))
                 if get_all or (-size[0] / 2 < x < size[0] / 2 and 
                     -size[1] / 2 < y < size[1] / 2):
                 y = (tan(angl1) * x) - (dist1 / cos(angl1))
                 if get_all or (-size[0] / 2 < x < size[0] / 2 and 
                     -size[1] / 2 < y < size[1] / 2):