def show_constraints(form, force):
    viewer = Viewer(form, force, delay_setup=False)
    viewer.draw_form(vertexlabel={key: key for key in form.vertices()},
                    edgelabel={uv: index for index, uv in enumerate(form.edges())},
                    vertexsize=0.2,
                    forces_on=False,
                    vertexcolor={key: '#FF0000' for key in form.vertices_where({'is_fixed_x': True})})
    viewer.draw_force(vertexcolor={key: '#FF0000' for key in force.vertices_where({'is_fixed_x': True})})
    viewer.show()

    viewer = Viewer(form, force, delay_setup=False)
    viewer.draw_form(vertexlabel={key: key for key in form.vertices()},
                    edgelabel={uv: index for index, uv in enumerate(form.edges())},
                    vertexsize=0.2,
                    forces_on=False,
                    vertexcolor={key: '#0000FF' for key in form.vertices_where({'is_fixed_y': True})})
    viewer.draw_force(vertexcolor={key: '#0000FF' for key in force.vertices_where({'is_fixed_y': True})})
    viewer.show()

    viewer = Viewer(form, force, delay_setup=False)
    viewer.draw_form(vertexlabel={key: key for key in form.vertices()},
                    edgelabel={uv: str(form.edge_attribute(uv, 'target_vector')) for uv in form.edges()},
                    vertexsize=0.2,
                    # forces_on=False,
                    vertexcolor={key: '#000000' for key in form.vertices_where({'is_fixed': True})})
    viewer.draw_force(vertexcolor={key: '#000000' for key in force.vertices_where({'is_fixed': True})},
                    edgelabel={uv: str(force.edge_attribute(uv, 'target_vector')) for uv in force.edges()})
    viewer.show()

    viewer = Viewer(form, force, delay_setup=False)
    viewer.draw_form(vertexlabel={key: key for key in form.vertices()},
                    edgelabel={uv: str(form.edge_attribute(uv, 'target_force')) for uv in form.edges()},
                    vertexsize=0.2,
                    # forces_on=False,
                    vertexcolor={key: '#000000' for key in form.vertices_where({'is_fixed': True})})
    viewer.draw_force(vertexcolor={key: '#000000' for key in force.vertices_where({'is_fixed': True})},
                    edgelabel={uv: str(force.dual_edgelength(uv)) for uv in force.edges()})
    viewer.show()
Exemplo n.º 2
0
def view_form_force(form, force, forcescale=0.5, edge_label=True):
    if edge_label:
        form_edge_label = {uv: index for index, uv in enumerate(form.edges())}
        force_edge_label = force_edge_labels
    else:
        form_edge_label = None
        force_edge_label = None

    viewer = Viewer(form, force, delay_setup=False)
    viewer.draw_form(edgelabel=form_edge_label,
                     forces_on=True,
                     forcescale=forcescale,
                     vertexcolor={key: '#000000' for key in form.vertices_where({'is_fixed': True})})
    viewer.draw_force(edgelabel=force_edge_label)
    viewer.show()
Exemplo n.º 3
0
def show(i):
    c = 10
    c += 1
    nsi = ns[i] * c
    # store lines representing the current null space mode
    form_lines = []
    for u, v in form.edges():
        form_lines.append({
            'start':
            [x + y for x, y in zip(form.vertex_coordinates(u, 'xy'), nsi[u])],
            'end':
            [x + y for x, y in zip(form.vertex_coordinates(v, 'xy'), nsi[v])],
            'width':
            1.0,
            'color':
            '#cccccc',
            'style':
            '--'
        })

    form_lines = form_lines + constraint_lines
    # display the original configuration
    # and the configuration after modifying the force diagram

    viewer = Viewer(form, force, delay_setup=False)
    viewer.draw_form(
        lines=form_lines,
        forces_on=False,
        vertexlabel={key: key
                     for key in form.vertices()},
        external_on=False,
        vertexsize=0.2,
        vertexcolor={key: '#000000'
                     for key in fixed},
        edgelabel={uv: index
                   for index, uv in enumerate(form.edges())})

    viewer.draw_force(
        vertexlabel={key: key
                     for key in force.vertices()},
        vertexsize=0.2,
        edgelabel={uv: index
                   for index, uv in enumerate(force.edges())})

    viewer.show()
Exemplo n.º 4
0
force.vertex[1]['is_param'] = True
force.vertex[2]['is_param'] = True
force.vertex[3]['is_param'] = True
force.vertex[4]['is_param'] = True
force.vertex[5]['is_param'] = True
force.vertex[6]['is_param'] = True

form.vertex[0]['is_fixed'] = True
form.vertex[1]['is_fixed'] = True
form.vertex[2]['is_fixed'] = True
form.vertex[3]['is_fixed'] = True
form.vertex[4]['is_fixed'] = True
form.vertex[5]['is_fixed'] = True
form.vertex[6]['is_fixed'] = True

graphstatics.form_update_from_force(form, force)
loadpath.optimise_loadpath(form, force)

viewer = Viewer(form, force, delay_setup=False)

viewer.draw_form(forcescale=5,
                 vertexlabel={key: key
                              for key in form.vertices()},
                 vertexsize=0.2)
viewer.draw_force(vertexlabel={key: key
                               for key in force.vertices()},
                  vertexsize=0.2)

viewer.show()
Exemplo n.º 5
0
# 2. set applied load
# ------------------------------------------------------------------------------

# choose an independent edge and set the magnitude of the applied load
# the system is statically determinate, thus choosing one edge is enough
form.edge_force(0, -30.0)

# update force densities of form and force diagrams
graphstatics.form_update_q_from_qind(form)
graphstatics.force_update_from_form(force, form)

# ------------------------------------------------------------------------------
# 3. display force and form diagrams
# ------------------------------------------------------------------------------

viewer = Viewer(form, force, delay_setup=False, figsize=(12, 7.5))

left = list(form.vertices_where({'x': 0.0, 'y': 0.0}))[0]
right = list(form.vertices_where({'x': 6.0, 'y': 0.0}))[0]

viewer.draw_form(
    vertexsize=0.15,
    vertexcolor={key: '#000000'
                 for key in (left, right)},
    vertexlabel={key: key
                 for key in form.vertices()},
    edgelabel={uv: index
               for index, uv in enumerate(form.edges())})

viewer.draw_force(vertexsize=0.15,
                  vertexlabel={key: key