network.add_edge(b, e) network.add_edge(c, e) network.add_edge(d, e) # compute the residual forces in the current geometry for node in network.nodes(): a = network.node_attributes(node, 'xyz') r = [0, 0, 0] for nbr in network.neighbors(node): b = network.node_attributes(nbr, 'xyz') edge = node, nbr if not network.has_edge(*edge): edge = nbr, node force = network.edge_attribute(edge, 'f') length = network.edge_length(*edge) r[0] += force * (b[0] - a[0]) / length r[1] += force * (b[1] - a[1]) / length r[2] += force * (b[2] - a[2]) / length network.node_attributes(node, ['rx', 'ry', 'rz'], r) # visualize the geometry layer = "ITA20::L5::FormFinding" artist = NetworkArtist(network, layer=layer) artist.draw_nodes(color={ node: (255, 0, 0) for node in network.nodes_where({'is_anchor': True}) })
for node in network.nodes(): point = network.node_coordinates(node) for nbr in tree.nearest_neighbors(point, 4, distance_sort=True): if nbr[2] < 1e-6: continue if not network.has_edge(node, nbr[1], directed=False): network.add_edge(node, nbr[1]) start = network.get_any_node() goal = network.get_any_node() path = network.shortest_path(start, goal) edges = [(u, v) if network.has_edge(u, v) else (v, u) for u, v in pairwise(path)] artist = NetworkArtist(network, layer="ITA20::Network") artist.clear_layer() artist.draw_nodes(color={start: (255, 0, 0), goal: (0, 0, 255)}) artist.draw_edges(color={edge: (0, 255, 0) for edge in edges}) for u, v in edges: o = network.edge_midpoint(u, v) n = network.edge_direction(u, v) h = network.edge_length(u, v) cylinder = Cylinder([(o, n), 0.02], h) artist = CylinderArtist(cylinder, color=(0, 255, 0), layer="ITA20::Network") artist.draw(show_vertices=False)