Exemplo n.º 1
0
    border = [[radius * 0, radius * 0], [radius * 0, radius * b],
              [radius * a, radius * 0], [radius * a, radius * b]]
    #seeds = (radius-1) * np.random.random((numSeeds, 2))
    distribution = chaospy.J(chaospy.Uniform(0, a), chaospy.Uniform(0, b))
    samples = distribution.sample(numSeeds, rule="hammersley")
    print(list(samples.T))
    border.extend(list(radius * samples.T))
    print(border)
    #seeds = [[0,0], [0,1], [0,2], [1,0], [1,1], [1,2], [2,0], [2,1], [2,2]]
    seeds = border

    center = np.mean(seeds, axis=0)
    dt = Delaunay(center, (50 + a) * radius)

    for s in seeds:
        dt.add_point(s)

    fig, ax = plt.subplots()
    ax.margins(0.1)
    ax.set_aspect('equal')
    plt.axis([-1, radius * a + 1, -1, radius * b + 1])

    # Грані
    cx, cy = zip(*seeds)
    dt_tris = dt.export_triangles()
    ax.triplot(matplotlib.tri.Triangulation(cx, cy, dt_tris), 'bo--')

    # Вершини

    for i, v in enumerate(seeds):
        plt.annotate(i, xy=v)
Exemplo n.º 2
0

# обработка ввода точки в комплексную точку
def get_point():
    s = input()
    if not s:
        return
    return complex(*map(int, s.split()))


print(
    "Введите граничный треугольник (внутри которого будет строиться триангуляция)."
)
print("Введите координаты трёх точек через ';' в формате: a b; c d; e f")
print("Например: 0 0; 1000 0; 500 866")
start_points = get_triangle()
delaunay = Delaunay(start_points)
delaunay.plot()
while True:
    print("\nВводите координаты новых точек через пробел в формате: a b")
    print(
        "Можно вводить только те точки, которые помещаются в начальный треугольник"
    )
    print("Например: 10 10")
    print("Для выхода в любой момент нажмите Enter.")
    point = get_point()
    if not point:
        break
    delaunay.add_point(point)
    delaunay.plot()