Beispiel #1
0
min_x = min(vertices,key=lambda v: v.x).x
min_y = min(vertices,key=lambda v: v.y).y
max_x = max(vertices,key=lambda v: v.x).x
max_y = max(vertices,key=lambda v: v.y).y

dx = max_x-min_x
dy = max_y-min_y

v1 = Vertex(min_x-dx*100,min_y-dy*100)
v2 = Vertex(min_x-dx*100,max_y+dy*200)
v3 = Vertex(max_x+dx*200,min_y-dy*100)

dt = Triangulation(v1,v2,v3,fast_locate=True)

for vertex in vertices:
    dt.insert_site(vertex)

#dt.remove_bounds()

root = tk.Tk()

def draw_faces():
    for face in dt.faces:
        if face.conflict:
            vis.add_drawable(Polygon2D(face.vertices(),fill="green"))
def draw_skeleton():
    for triangle in dt.get_triangles():
        prev = None
        for vertex in triangle:
            if prev:
                vis.add_drawable(Line2D(prev,vertex))