Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import openvoronoi as ovd
- import math
- if __name__ == "__main__":
- far = 1.0
- vd = ovd.VoronoiDiagram(far,120)
- r = 0.9
- # input points (vertices/sites)
- id_list = []
- #fails with even n, fine with odd n
- #it semms due to collinear line segments
- #n = 99 #fine
- n = 100 #fails
- for i in range(n):
- a = math.pi*i/n*2.0
- x = r*math.cos(a)
- y = r*math.sin(a)
- id_list.append(vd.addVertexSite(ovd.Point(x, y)))
- print "add point", i, a, x, y, id_list[-1]
- for i in range(n):
- print "add line", i, ":", id_list[i-1], id_list[i]
- # on first iteration negative index, but that's ok
- vd.addLineSite(id_list[i-1], id_list[i])
- print "VD check: ", vd.check()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement