Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import openvoronoi as ovd
  4. import math
  5.  
  6. if __name__ == "__main__":
  7.     far = 1.0
  8.     vd = ovd.VoronoiDiagram(far,120)
  9.  
  10.  
  11.     r = 0.9
  12.     # input points (vertices/sites)
  13.     id_list = []
  14.     #fails with even n, fine with odd n
  15.     #it semms due to collinear line segments
  16.     #n = 99 #fine
  17.     n = 100 #fails
  18.     for i in range(n):
  19.         a = math.pi*i/n*2.0
  20.         x = r*math.cos(a)
  21.         y = r*math.sin(a)
  22.         id_list.append(vd.addVertexSite(ovd.Point(x, y)))
  23.         print "add point", i, a, x, y, id_list[-1]
  24.  
  25.     for i in range(n):
  26.         print "add line", i, ":", id_list[i-1], id_list[i]
  27.         # on first iteration negative index, but that's ok
  28.         vd.addLineSite(id_list[i-1], id_list[i])
  29.     print "VD check: ", vd.check()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement