#!/usr/bin/python import numpy as np import polyhedron import tetrahedron import plotter poly1 = polyhedron.Polyhedron( faces=np.array([[[0., 0., 0.], [0., 1., 0.], [1., 0., 0.]], [[0., 0., 0.], [0.5, 0.5, 1.], [0., 1., 0.]], [[0., 0., 0.], [0.5, 0.5, 1.], [1., 0., 0.]], [[1., 0., 0.], [0., 1., 0.], [0.5, 0.5, 1.]]])) poly2 = tetrahedron.Tetrahedron(a=[2., 2., 2.], b=[3., 2., 2.], c=[2.5, 3., 2.], d=[2.5, 2.5, 3.]) plt = plotter.Plotter() poly1.plot(plt) poly1.plotAllPoints(plt) poly2.plot(plt) poly2.plotAllPoints(plt) plt.draw()
#!/usr/bin/python import numpy as np import voronizator import tetrahedron voronoi = voronizator.Voronizator() maxEmptyArea = 0.1 poly1 = tetrahedron.Tetrahedron(a=[0.1, 0.1, 0.1], b=[0.1, 0.9, 0.1], c=[0.9, 0.1, 0.1], d=[0.5, 0.5, 0.9], maxEmptyArea=maxEmptyArea) poly2 = tetrahedron.Tetrahedron(a=[-0.5, 0.1, 0.1], b=[-0.5, 0.9, 0.1], c=[-0.9, 0.5, 0.1], d=[-0.5, 0.5, 1.5], maxEmptyArea=maxEmptyArea) poly3 = tetrahedron.Tetrahedron(a=[0.5, 1., 0.5], b=[0.7, 0.5, 0.5], c=[0.7, 0.7, 1.], d=[0.9, 0.7, 0.5], maxEmptyArea=maxEmptyArea) Vs = np.array([0., 0., 0.]) #Ve = np.array([1.,1.,1.]) Ve = np.array([0.5, 0.6, 0.5]) voronoi.addPolyhedron(poly1) voronoi.addPolyhedron(poly2)
#!/usr/bin/python import numpy as np import voronizator import tetrahedron import plotter voronoi = voronizator.Voronizator() voronoi.addPolyhedron( tetrahedron.Tetrahedron(a=[0.1, 0.1, 0.1], b=[0.3, 0.3, 0.1], c=[0.4, 0.2, 0.2], d=[0.1, 0.2, 0.2])) #make test graph ns = (0., 0., 0.) n1 = (0.25, 0.15, 0.18) n2 = (0.25, 0.2, 0.3) n3 = (0.25, 0.25, 0.18) n4 = (0.15, 0.1, 0.3) ne = (0.4, 0.4, 0.4) voronoi._graph.add_edge(ns, n1, weight=np.linalg.norm(np.array(ns) - np.array(n1))) voronoi._graph.add_edge(n1, n2, weight=np.linalg.norm(np.array(n1) - np.array(n2))) voronoi._graph.add_edge(n2,
ok = False while not ok: print('.', end='', flush=True) if not fixedRadius: radius = random.uniform(minRadius,maxRadius) center = np.array([random.uniform(minX+radius,maxX-radius), random.uniform(minY+radius,maxY-radius), random.uniform(minZ+radius,maxZ-radius)]) points = [] for pt in range(4): elev = random.uniform(-math.pi/2., math.pi/2.) azim = random.uniform(0., 2.*math.pi) points[:0] = [center+np.array([ radius*math.cos(elev)*math.cos(azim), radius*math.cos(elev)*math.sin(azim), radius*math.sin(elev)])] newObstacle = tetrahedron.Tetrahedron(a = points[0], b = points[1], c = points[2], d = points[3], distributePoints = True, maxEmptyArea = maxEmptyArea) ok = True if avoidCollisions: for obstacle in obstacles: if newObstacle.intersectPolyhedron(obstacle): ok = False break if ok: voronoi.addPolyhedron(newObstacle) if avoidCollisions: obstacles[:0] = [newObstacle] print(' done', flush=True)
#!/usr/bin/python import numpy as np import voronizator import tetrahedron import plotter voronoi = voronizator.Voronizator() poly1 = tetrahedron.Tetrahedron(a=[0.1, 0.1, 0.1], b=[0.1, 0.9, 0.1], c=[0.9, 0.1, 0.1], d=[0.5, 0.5, 0.9]) poly2 = tetrahedron.Tetrahedron(a=[-0.5, 0.1, 0.1], b=[-0.5, 0.9, 0.1], c=[-0.9, 0.5, 0.1], d=[-0.5, 0.5, 1.5]) poly3 = tetrahedron.Tetrahedron(a=[0.5, 1., 0.5], b=[0.7, 0.5, 0.5], c=[0.7, 0.7, 1.], d=[0.9, 0.7, 0.5]) Vs = np.array([0., 0., 0.]) Ve = np.array([1., 1., 1.]) voronoi.addPolyhedron(poly1) voronoi.addPolyhedron(poly2) voronoi.addPolyhedron(poly3) #voronoi.addBoundingBox([-2.,-2.,-2.], [3.,3.,3.]) voronoi.setPolyhedronsSites()
#!/usr/bin/python import numpy as np import voronizator import tetrahedron import plotter voronoi = voronizator.Voronizator() maxEmptyArea = 0.1 poly1 = tetrahedron.Tetrahedron(a=np.array([0.1, 0.1, 0.1]), b=np.array([0.1, 0.9, 0.1]), c=np.array([0.9, 0.1, 0.1]), d=np.array([0.5, 0.5, 0.9]), maxEmptyArea=maxEmptyArea) poly2 = tetrahedron.Tetrahedron(a=np.array([-0.5, 0.1, 0.1]), b=np.array([-0.5, 0.9, 0.1]), c=np.array([-0.9, 0.5, 0.1]), d=np.array([-0.5, 0.5, 1.5]), maxEmptyArea=maxEmptyArea) poly3 = tetrahedron.Tetrahedron(a=np.array([0.5, 1., 0.5]), b=np.array([0.7, 0.5, 0.5]), c=np.array([0.7, 0.7, 1.]), d=np.array([0.9, 0.7, 0.5]), maxEmptyArea=maxEmptyArea) plt = plotter.Plotter() Vs = np.array([0., 0., 0.]) #Ve = np.array([1.,1.,1.]) Ve = np.array([0.5, 0.6, 0.5])