insert_parabola fixed to work when the current site and new site are at the same y-value.
insert_parabola fixed to work when the current site and new site are at the same y-value.

file:a/voronoi.py -> file:b/voronoi.py
--- a/voronoi.py
+++ b/voronoi.py
@@ -23,6 +23,9 @@
         self.point=point
 
     def value(self,x,ypp):
+        if self.point[1]==ypp: # Vertical edge!
+            return None
+
         return ((self.point[0]-x)**2-ypp**2+self.point[1]**2)/(2*(self.point[1]-ypp))
 
     def debug(self,ypp):
@@ -338,32 +341,50 @@
         self.insert_parabola(leaf,par)
 
     def insert_parabola(self,node,parabola):
-        intersection=(parabola.point[0],node.parabola.value(parabola.point[0],parabola.point[1]))
-
-        newnode=Node()
-        newnode.parabola=parabola
-
-        curleaf1=node.clone()
-        curleaf2=node.clone()
-
-        edge1=Edge(intersection,node.parabola.point,parabola.point)
-        edge2=Edge(intersection,parabola.point,node.parabola.point)
-        self.internal_edges.append((edge1,edge2))
-
-        edge_node2=Node()
-        edge_node2.set_left(newnode)
-        edge_node2.set_right(curleaf2)
-        edge_node2.edge=edge2
-        
-        node.set_left(curleaf1)
-        node.set_right(edge_node2)
-        node.edge=edge1
-
-        # Check circle events
-        if curleaf1.prev_parabola()!=None and curleaf1.next_parabola()!=None:
-            self.circle_check(curleaf1)
-        if curleaf2.prev_parabola()!=None and curleaf2.next_parabola()!=None:
-            self.circle_check(curleaf2)
+        if parabola.point[1]!=node.parabola.point[1]:
+            intersection=(parabola.point[0],node.parabola.value(parabola.point[0],parabola.point[1]))
+
+            newnode=Node()
+            newnode.parabola=parabola
+
+            curleaf1=node.clone()
+            curleaf2=node.clone()
+
+            edge1=Edge(intersection,node.parabola.point,parabola.point)
+            edge2=Edge(intersection,parabola.point,node.parabola.point)
+            self.internal_edges.append((edge1,edge2))
+
+            edge_node2=Node()
+            edge_node2.set_left(newnode)
+            edge_node2.set_right(curleaf2)
+            edge_node2.edge=edge2
+        
+            node.set_left(curleaf1)
+            node.set_right(edge_node2)
+            node.edge=edge1
+
+            # Check circle events
+            if curleaf1.prev_parabola()!=None and curleaf1.next_parabola()!=None:
+                self.circle_check(curleaf1)
+            if curleaf2.prev_parabola()!=None and curleaf2.next_parabola()!=None:
+                self.circle_check(curleaf2)
+        else:
+            intersection=((parabola.point[0]+node.parabola.point[0])/2,
+                          (parabola.point[1]+node.parabola.point[1])/2)
+
+            newnode=Node()
+            newnode.parabola=parabola
+            
+            curleaf=node.clone()
+
+            edge=Edge(intersection,node.parabola.point,parabola.point)
+            edge.start=None
+            self.internal_edges.append(edge)
+
+            node.set_left(curleaf)
+            node.set_right(newnode)
+            node.edge=edge
+
 
     def circle_check(self,circle_node):
 #        print 'circle_check'