Example #1
0
poly3 = polygon.Polygon(vertexes=np.array([[0.6,0.4],[0.8,0.6],[1.,0.4],[1.,0.6],[0.7,1.]]), maxEmptyLen=maxEmptyLen)

fig = plt.figure(frameon=False)
ax = fig.gca()

#Vs = np.array([-0.1,0.5])
#Ve = np.array([1.1,0.5])

scene.addPolygon(poly1)
scene.addPolygon(poly2)
scene.addPolygon(poly3)

#scene.addBoundingBox([-1.,-1.], [2.,2.], maxEmptyLen=.2)
scene.addBoundingBox([-0.25,-0.25], [1.25,1.25], maxEmptyLen=.2)

voronoi = voronizator.Voronizator(scene)

voronoi.makeVoroGraph(prune=False)
#path = voronoi.createShortestPath(Vs, Ve, attachMode='near', minEdgeLen=0.05, maxEdgeLen=0.08, optimizeVal='maxCurvatureLength')
#voronoi.calculateShortestPath(Vs, Ve, 'all')

voronoi.plotSites(ax)
scene.plot(ax)
#voronoi.plotGraph(ax, edges=False, labels=True)
#voronoi.plotGraph(ax, pathExtremes=True)
voronoi.plotGraph(ax)
#path.plot(ax,plotInnerVertexes=True,plotSpline=False)

#ax.set_xlim(-1., 2.)
#ax.set_ylim(-1., 2.)
ax.set_xlim(-0.27, 1.27)
Example #2
0
if len(sys.argv) == 2:
    fileName = sys.argv[1]

else:
    fileName = input('Insert file name: ')

minX = -1
minY = -1
minZ = -1
maxX = 3
maxY = 2
maxZ = 2
maxEmptyArea = 0.5

voronoi = voronizator.Voronizator()
points = np.array([[1., 0., 1.], [1., 1., 0], [0.2, 0.8, 0.2], [0., 1., 1.],
                   [0.4, 0.8, 0.9], [1.5, 0.5, 0.5], [0., 0., 0.],
                   [1., 1., 1.], [0.6, 0.1, 0.7], [2., 0.5, 0.5], [0., 1., 0.],
                   [0.2, 0.5, 0.3], [0., 0., 1.], [1., 0., 0.]])

newObstacle = convexHull.ConvexHull(points=points,
                                    distributePoints=True,
                                    maxEmptyArea=maxEmptyArea)
voronoi.addPolyhedron(newObstacle)

voronoi.addBoundingBox([minX, minY, minZ], [maxX, maxY, maxZ],
                       maxEmptyArea,
                       verbose=True)

voronoi.setPolyhedronsSites(verbose=True)
Example #3
0
#!/usr/bin/python

import numpy as np
import voronizator
import tetrahedron
import uuid
import plotter

voronoi = voronizator.Voronizator(bsplineDegree=2)

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
aId = uuid.uuid4()
startId = aId
a = np.array([0., 0., 0.])
bId = uuid.uuid4()
b = np.array([0.25, 0.15, 0.18])
voronoi._graph.add_node(aId, coord=a)
voronoi._graph.add_node(bId, coord=b)
voronoi._graph.add_edge(aId, bId, weight=np.linalg.norm(a - b))

aId = bId
a = b
bId = uuid.uuid4()
b = np.array([0.25, 0.2, 0.22])
voronoi._graph.add_node(aId, coord=a)