Exemplo n.º 1
0
    numSeeds = 11
    radius = 20
    a, b = 5, 4
    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--')

    # Вершини
Exemplo n.º 2
0
from delaunay import Delaunay
from cust_points import Point
import matplotlib.pyplot as plt

if __name__ == "__main__":
    liste = []
    liste.append(Point(0, 0))
    liste.append(Point(0, 1))
    liste.append(Point(1, 1))
    liste.append(Point(1, 2))
    liste.append(Point(2, 2))
    liste.append(Point(2, 0))
    delaunay = Delaunay()
    delaunay.appliquer(liste)
    first = []
    second = []
    for p in liste:
        first.append(p.x)
        second.append(p.y)
    firstCenter = []
    secondCenter = []
    for t in delaunay.triangles:
        pt = t.centreCirconscrit()
        firstCenter.append(pt.x)
        secondCenter.append(pt.y)
        trix = [t.one.x, t.two.x, t.three.x, t.one.x]
        triy = [t.one.y, t.two.y, t.three.y, t.one.y]
        plt.plot(trix, triy, color='#004000')
    for (k, v) in delaunay.aretes.items():
        for a in v:
            arx = [a.x.x, a.y.x]
Exemplo n.º 3
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()