Page MenuHomec4science

test_Voronoi.py
No OneTemporary

File Metadata

Created
Tue, Jun 25, 16:31

test_Voronoi.py

#!/usr/bin/env python
from pNbody import ic
from numpy import *
import tessel
import Ptools as pt
import plot
import sys
import time
random.seed(0) # 2 for two points
n = 500000
nb = ic.plummer(n,1,1,1,eps=0.1,rmax=1.)
pos = nb.pos
mass = nb.mass
#pos = random.random((n,3))
#mass = pos[:,0]+pos[:,1]
#pos[0] = [0.5,0.5,0]
#pos[1] = [0.5,0.25,0]
#pos[2] = [0.25,0.5,0]
#pos[3] = [0.75,1.0,0]
t1 = time.time()
tessel.ConstructDelaunay(pos,mass)
t2 = time.time()
#tessel.info()
TriangleList = tessel.GetTriangles()
print len(TriangleList),"triangles","in",(t2-t1),"s"
'''
i = 0
for Triangle in TriangleList:
P1 = Triangle['coord'][0]
P2 = Triangle['coord'][1]
P3 = Triangle['coord'][2]
#plot.draw_triangle(P1,P2,P3)
#cm = 1/3.*(P1+P2+P3)
#pt.text(cm[0],cm[1],Triangle['id'],fontsize=12,horizontalalignment='center',verticalalignment='center')
for P in pos:
plot.draw_points([P],'b')
'''
t1 = time.time()
segments = tessel.GetVoronoi()
t2 = time.time()
print len(segments),"segments","in",(t2-t1),"s"
sys.exit()
for segment in segments:
#print segment[0],segment[1]
plot.draw_line(segment[0],segment[1],'r')
pt.axis([-1,1,-1,1])
pt.show()

Event Timeline