{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.insert(0, \"..\") # this is necessary if flexrilog (https://github.com/Legersky/flexrilog)\n", " # is not installed, only downloaded\n", "from flexrilog import BracedPframework" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rectangular grid\n", "\n", "We try the functionality on a normal grid with some braced rectangles.\n", "\n", "First we construct a braced grid with a parallelogram placement." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "grid = BracedPframework(edges=[[0, 1], [0, 5], [1, 2], [1, 6], [2, 3], [2, 7], [3, 4], [3, 8], [4, 9], [5, 6], \n", " [5, 10], [6, 7], [6, 11], [7, 8], [7, 12], [8, 9], [8, 13], [9, 14], [10, 11], \n", " [10, 15], [11, 12], [11, 16], [12, 13], [12, 17], [13, 14], [13, 18], [14, 19], \n", " [15, 16], [15, 20], [16, 17], [16, 21], [17, 18], [17, 22], [18, 19], [18, 23], \n", " [19, 24], [20, 21], [20, 25], [21, 22], [21, 26], [22, 23], [22, 27], [23, 24], \n", " [23, 28], [24, 29], [25, 26], [26, 27], [27, 28], [28, 29]],\n", " placement={0: (0, 0), 1: (1, 0), 2: (3, 0), 3: (11/2, 0), 4: (7, 0), 5: (0, 1), 6: (1, 1),\n", " 7: (3, 1), 8: (11/2, 1), 9: (7, 1), 10: (0, 5/2), 11: (1, 5/2), 12: (3, 5/2), \n", " 13: (11/2, 5/2), 14: (7, 5/2), 15: (0, 4), 16: (1, 4), 17: (3, 4), 18: (11/2, 4),\n", " 19: (7, 4), 20: (0, 6), 21: (1, 6), 22: (3, 6), 23: (11/2, 6), 24: (7, 6), \n", " 25: (0, 7), 26: (1, 7), 27: (3, 7), 28: (11/2, 7), 29: (7, 7)},\n", " braces=[[10, 6], [16, 12], [12, 8], [18, 14], [23, 19], [27, 23], [6, 2]])\n", "grid.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We construct the *ribbon graph* of ``grid``.\n", "An edge from each ribbon is used as a name instead of the full ribbon." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grid.ribbon_graph()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, we construct the *bracing graph* of ``grid``.\n", "It is disconnected. Hence, the braced P-framework is flexible." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grid.bracing_graph()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We find the cartesian NAC-colorings of the graph." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('# NACs: ', len(grid.cartesian_NAC_colorings()))\n", "delta = grid.cartesian_NAC_colorings()[0].conjugated()\n", "show(delta.plot())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use the unique NAC-coloring to construct a flex of the framework." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grid_motion = grid.flex_from_cartesian_NAC(delta)\n", "grid_motion.animation_SVG(edge_partition='NAC', vertex_labels=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Braced P-framework\n", "\n", "Now we construct a P-framework using the constructions Add4-cycle and Close4-cycle. \n", "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`)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G = BracedPframework([[0,1]], placement={0: (0,0),1: (1,0)})\n", "\n", "G.add_parallelogram(0,1, 1, -90)\n", "# the first two parameters specify the vertices of an existing edge,\n", "# the last two a distance and angle at which the new edge is placed\n", "G.add_parallelogram(2,3, 0.5, -45)\n", "G.add_parallelogram(1,3, 0.5, 30)\n", "G.add_parallelogram(7,3, 1.5, -18)\n", "G.close_parallelogram(5,3,9)\n", "# the three parameters specify the vertices of two incident edges\n", "G.close_parallelogram(8,9,10)\n", "G.close_parallelogram(6,7,8)\n", "G.close_parallelogram(0,1,6)\n", "G.add_parallelogram(6,13, 1, 54)\n", "G.add_parallelogram(6,14, 1, 18)\n", "G.close_parallelogram(12,6,16)\n", "G.close_parallelogram(17,16,18)\n", "G.add_parallelogram(12,8, 0.75, 0)\n", "G.close_parallelogram(11,8,21)\n", "G.close_parallelogram(18,12,20)\n", "G.close_parallelogram(23,20,21)\n", "G.close_parallelogram(19,18,23)\n", "G.close_parallelogram(24,21,22)\n", "G.close_parallelogram(25,23,24)\n", "G.close_parallelogram(27,24,26)\n", "G.close_parallelogram(25,27,28)\n", "\n", "show(G.plot())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We brace the P-framework:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "G.add_braces([[3, 4], [5, 9], [8, 10], [18, 20], [19, 23], [23, 27]])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G.plot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G.bracing_graph()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The bracing graph is disconnected, hence, the braced P-framework is flexible." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('# NACs: ', len(G.cartesian_NAC_colorings()))\n", "delta = G.cartesian_NAC_colorings()[0].conjugated()\n", "show(delta.plot())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G_flex = G.flex_from_cartesian_NAC(delta)\n", "G_flex.fix_edge([0,1])\n", "G_flex.animation_SVG(edge_partition='NAC', vertex_labels=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "SageMath 9.0", "language": "sage", "name": "sagemath" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }