#!/usr/bin/env python # coding: utf-8 # In[ ]: import sys sys.path.insert(0, "..") # this is necessary if flexrilog (https://github.com/Legersky/flexrilog) # is not installed, only downloaded from flexrilog import BracedPframework # ## Rectangular grid # # We try the functionality on a normal grid with some braced rectangles. # # First we construct a braced grid with a parallelogram placement. # In[ ]: grid = BracedPframework(edges=[[0, 1], [0, 5], [1, 2], [1, 6], [2, 3], [2, 7], [3, 4], [3, 8], [4, 9], [5, 6], [5, 10], [6, 7], [6, 11], [7, 8], [7, 12], [8, 9], [8, 13], [9, 14], [10, 11], [10, 15], [11, 12], [11, 16], [12, 13], [12, 17], [13, 14], [13, 18], [14, 19], [15, 16], [15, 20], [16, 17], [16, 21], [17, 18], [17, 22], [18, 19], [18, 23], [19, 24], [20, 21], [20, 25], [21, 22], [21, 26], [22, 23], [22, 27], [23, 24], [23, 28], [24, 29], [25, 26], [26, 27], [27, 28], [28, 29]], placement={0: (0, 0), 1: (1, 0), 2: (3, 0), 3: (11/2, 0), 4: (7, 0), 5: (0, 1), 6: (1, 1), 7: (3, 1), 8: (11/2, 1), 9: (7, 1), 10: (0, 5/2), 11: (1, 5/2), 12: (3, 5/2), 13: (11/2, 5/2), 14: (7, 5/2), 15: (0, 4), 16: (1, 4), 17: (3, 4), 18: (11/2, 4), 19: (7, 4), 20: (0, 6), 21: (1, 6), 22: (3, 6), 23: (11/2, 6), 24: (7, 6), 25: (0, 7), 26: (1, 7), 27: (3, 7), 28: (11/2, 7), 29: (7, 7)}, braces=[[10, 6], [16, 12], [12, 8], [18, 14], [23, 19], [27, 23], [6, 2]]) grid.plot() # We construct the *ribbon graph* of ``grid``. # An edge from each ribbon is used as a name instead of the full ribbon. # In[ ]: grid.ribbon_graph() # Now, we construct the *bracing graph* of ``grid``. # It is disconnected. Hence, the braced P-framework is flexible. # In[ ]: grid.bracing_graph() # We find the cartesian NAC-colorings of the graph. # In[ ]: print('# NACs: ', len(grid.cartesian_NAC_colorings())) delta = grid.cartesian_NAC_colorings()[0].conjugated() show(delta.plot()) # We use the unique NAC-coloring to construct a flex of the framework. # In[ ]: grid_motion = grid.flex_from_cartesian_NAC(delta) grid_motion.animation_SVG(edge_partition='NAC', vertex_labels=False) # ## Braced P-framework # # Now we construct a P-framework using the constructions Add4-cycle and Close4-cycle. # Notice that contrary to the paper, we construct a parallelogram placement for the graph at the same time (hence `parallelogram` in the names of the methods instead of `4-cycle`). # In[ ]: G = BracedPframework([[0,1]], placement={0: (0,0),1: (1,0)}) G.add_parallelogram(0,1, 1, -90) # the first two parameters specify the vertices of an existing edge, # the last two a distance and angle at which the new edge is placed G.add_parallelogram(2,3, 0.5, -45) G.add_parallelogram(1,3, 0.5, 30) G.add_parallelogram(7,3, 1.5, -18) G.close_parallelogram(5,3,9) # the three parameters specify the vertices of two incident edges G.close_parallelogram(8,9,10) G.close_parallelogram(6,7,8) G.close_parallelogram(0,1,6) G.add_parallelogram(6,13, 1, 54) G.add_parallelogram(6,14, 1, 18) G.close_parallelogram(12,6,16) G.close_parallelogram(17,16,18) G.add_parallelogram(12,8, 0.75, 0) G.close_parallelogram(11,8,21) G.close_parallelogram(18,12,20) G.close_parallelogram(23,20,21) G.close_parallelogram(19,18,23) G.close_parallelogram(24,21,22) G.close_parallelogram(25,23,24) G.close_parallelogram(27,24,26) G.close_parallelogram(25,27,28) show(G.plot()) # We brace the P-framework: # In[ ]: G.add_braces([[3, 4], [5, 9], [8, 10], [18, 20], [19, 23], [23, 27]]) # In[ ]: G.plot() # In[ ]: G.bracing_graph() # The bracing graph is disconnected, hence, the braced P-framework is flexible. # In[ ]: print('# NACs: ', len(G.cartesian_NAC_colorings())) delta = G.cartesian_NAC_colorings()[0].conjugated() show(delta.plot()) # In[ ]: G_flex = G.flex_from_cartesian_NAC(delta) G_flex.fix_edge([0,1]) G_flex.animation_SVG(edge_partition='NAC', vertex_labels=False) # In[ ]: