def draw_debug(ax, triangulation, usr_vertexes=None, sleep_time=0):
    if usr_vertexes is None:
        usr_vertexes = []
    tr.plot(ax, **triangulation)
    for vert in usr_vertexes:
        ax.scatter(*vert, color='r', linewidths=5)
    if sleep_time:
        time.sleep(sleep_time)
def compare(ax1, vertexes, ax2, triangulation, usr_vertexes=None):
    if usr_vertexes:
        usr_vert = np.array(usr_vertexes)
        ax1.scatter(*usr_vert.T, color='r', linewidths=5)
        ax2.scatter(*usr_vert.T, color='r', linewidths=5)
    tr.plot(ax1, **vertexes)
    lim = ax1.axis()
    tr.plot(ax2, **triangulation)
    ax2.axis(lim)
    plt.tight_layout()
Beispiel #3
0
 def plot(self):
     """ Creates very basic plot of the pslg.
     """
     for c in self.C:
         plot(self.P[c[0]], self.P[c[1]], 'b-')
     plt.show()
Beispiel #4
0
import matplotlib.pyplot as plt

import triangle as tr

box1 = tr.get_data('bbox.1')
box2 = tr.triangulate(box1, 'rpa')
tr.plot(plt.axes(), **box2)
plt.show()
Beispiel #5
0
import matplotlib.pyplot as plt
import numpy as np

import triangle as tr

pts = [[0, 0], [0, 1], [0.5, 0.5], [1, 1], [1, 0]]
pts = np.array(pts)

vertices, edges, ray_origins, ray_directions = tr.voronoi(pts)
ax = plt.axes()
tr.plot(ax, vertices=pts)
lim = ax.axis()
tr.plot(ax, vertices=vertices, edges=edges,
        ray_origins=ray_origins, ray_directions=ray_directions)
ax.axis(lim)

plt.show()
Beispiel #6
0
import matplotlib.pyplot as plt

import triangle as tr

dots = tr.get_data('dots')
pts = dots['vertices']
segs = tr.convex_hull(pts)

tr.plot(plt.axes(), vertices=pts, segments=segs)

plt.show()
Beispiel #7
0
g += 1
segments[g] = [f - 3, f - 2]
g += 1
segments[g] = [f - 2, f - 1]
g += 1
segments[g] = [f - 1, f - 4]
g += 1
segments = segments[0:g, :]

# Create Dictionary
poly = {'holes': holes, 'vertices': corners, 'segments': segments}

t = tr.triangulate(poly, 'pc')
# tr.compare(plt, poly, t)
plt.axis('on')
tr.plot(plt.axes(), **t)

plt.xlim(0, 100)
plt.ylim(0, 50)

triList = t['triangles']
corners = t['vertices']
nodes = {}
triGraph = {}

# # find and plot centers of triangles (remember nodes closest to start and goal )
startNodeIndex = 0
sVal = xlen
goalNodeIndex = 0
gVal = xlen
Beispiel #8
0
import matplotlib.pyplot as plt

import triangle as tr

spiral = tr.get_data('spiral')

t = tr.triangulate(spiral, 'a.2')
ax1 = plt.subplot(111)
tr.plot(ax1, **t)

plt.show()
Beispiel #9
0
import matplotlib.pyplot as plt

import triangle as tr

box1 = tr.get_data('bbox.1')
box2 = tr.triangulate(box1, 'rpa0.2')
box3 = tr.triangulate(box2, 'rpa0.05')
box4 = tr.triangulate(box3, 'rpa0.0125')

plt.figure(figsize=(15, 5))

ax1 = plt.subplot(131, aspect='equal')
tr.plot(ax1, **box2)

ax2 = plt.subplot(132, sharex=ax1, sharey=ax1)
tr.plot(ax2, **box3)

ax2 = plt.subplot(133, sharex=ax1, sharey=ax1)
tr.plot(ax2, **box4)

plt.show()
Beispiel #10
0
import matplotlib.pyplot as plt

import triangle as tr

face = tr.get_data('face.1')
tr.plot(plt.axes(), **face)
plt.show()
Beispiel #11
0
import matplotlib.pyplot as plt

import triangle as tr

A = tr.get_data('A')
ax = plt.axes()
tr.plot(ax, **A)
plt.show()
Beispiel #12
0
import matplotlib.pyplot as plt

import triangle as tr

ax = plt.axes()
A = tr.get_data('A')
t = tr.triangulate(A, 'p')
tr.plot(ax, **t)
plt.show()
Beispiel #13
0
import matplotlib.pyplot as plt

import triangle as tr

spiral = tr.get_data('spiral')
a = tr.triangulate(spiral)
b = tr.triangulate(spiral, 'q')
c = tr.triangulate(spiral, 'q32.5')

plt.figure(figsize=(5, 6))
ax1 = plt.subplot(221)
tr.plot(ax1, **spiral)

ax2 = plt.subplot(222)
tr.plot(ax2, **a)

ax3 = plt.subplot(223)
tr.plot(ax3, **b)

ax4 = plt.subplot(224)
tr.plot(ax4, **c)

plt.tight_layout()
plt.show()
Beispiel #14
0
import matplotlib.pyplot as plt

import triangle as tr

plt.figure(figsize=(8, 7))

la = tr.get_data('la')
ax1 = plt.subplot(311)
tr.plot(ax1, **la)

t = tr.triangulate(la, 'pq')
ax2 = plt.subplot(312, sharex=ax1, sharey=ax1)
tr.plot(ax2, **t)

t = tr.triangulate(la, 'pqa')
ax2 = plt.subplot(313, sharex=ax1, sharey=ax1)
tr.plot(ax2, **t)

plt.show()