{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This is a supplementary material to the submission **Computing animations of linkages with rotational symmetry** \n", "to *Computational Geometry: Media Exposition - Zürich, Switzerland - June 23-26, 2020*\n", "by Sean Dewar, Georg Grasegger and Jan Legerský.\n", "\n", "The submission contains a video of rotationally symmetric motions of bar-and-joint frameworks and this notebook. \n", "We illustrate how such motions can be created using ``SageMath`` package ``FlexRiLog`` (https://github.com/Legersky/flexrilog, https://doi.org/10.5281/zenodo.3078757 ).\n", "\n", "A cell is executed with ``Shift+Enter`` or pressing Run button." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.insert(0, \"..\") #this is necessary if flexrilog is not installed, only downloaded\n", "from flexrilog import CnSymmetricFlexRiGraph, FlexRiGraph, GraphMotion, CnSymmetricNACcoloring" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# A 5-fold rotationally symmetric graph" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We consider the graph given by the following list of edges:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "edges = [(0, 1), (0, 2), (0, 4), (0, 14), (1, 2), (1, 11), (1, 12), (1, 15), \n", " (1, 18), (1, 23), (1, 24), (2, 3), (2, 7), (3, 4), (3, 5), (3, 7), \n", " (4, 5), (4, 14), (4, 15), (4, 16), (4, 17), (4, 20), (5, 6), (5, 10),\n", " (6, 7), (6, 8), (6, 10), (7, 8), (7, 17), (7, 18), (7, 19), (7, 22),\n", " (8, 9), (8, 13), (9, 10), (9, 11), (9, 13), (10, 11), (10, 19),\n", " (10, 20), (10, 21), (10, 24), (11, 12), (12, 13), (12, 14), (13, 14),\n", " (13, 16), (13, 21), (13, 22), (13, 23), (15, 16), (15, 18), (16, 23),\n", " (17, 18), (17, 20), (19, 20), (19, 22), (21, 22), (21, 24), (23, 24)]\n", "G5 = Graph(edges);\n", "G5.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The graph `G5` is $C_n$-symmetric for $n=5$:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "omega5 = [[(0, 3, 6, 9, 12),\n", " (1, 4, 7, 10, 13),\n", " (2, 5, 8, 11, 14),\n", " (15, 17, 19, 21, 23),\n", " (16, 18, 20, 22, 24)]]\n", "G5 = CnSymmetricFlexRiGraph(G5,\n", " PermutationGroup(omega5),\n", " pos={\n", " 0:[1,0],\n", " 1:[2.5,0],\n", " 2:[4,1.5],\n", " 15:[4,5],\n", " 16:[6,2]\n", " }\n", " )\n", "G5.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The graph `G5` has three $C_5$-symmetric NAC-colorings:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G5.show_all_NAC_colorings(ncols=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We consider the last NAC-coloring:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "delta5 = G5.NAC_colorings()[-1]\n", "delta5.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The construction in Theorem 2 yields a $C_5$-symmetric motion:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "M5 = GraphMotion.CnSymmetricGridConstruction(G5, delta5)\n", "M5.animation_SVG(edge_partition='NAC', fileName='AnimationPentaRotation', totalTime=20, vertex_labels=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One can play with the choice of $a_i$'s and $b_j$'. There is only one orbit of red components and one orbit of blue components (and no partially invariant ones), so $a_i$'s and $b_j$' are determined each by one point:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "M5ab = GraphMotion.CnSymmetricGridConstruction(G5,\n", " delta5,\n", " a_base=[[2,2]], # a different point can be chosen here\n", " b_base=[[1,0]] # or here\n", " )\n", "M5ab.animation_SVG(edge_partition='NAC', fileName='AnimationPentaRotation_different_a_b',\n", " totalTime=20, vertex_labels=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# A 3-fold rotationally symmetric graph" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We consider the graph given by the following list of edges:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "edges3 = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 5), (1, 6), (2, 7), (2, 8),\n", " (3, 4), (3, 9), (3, 10), (4, 11), (4, 12), (5, 6), (5, 7), (5, 13),\n", " (6, 14), (6, 15), (7, 8), (7, 13), (8, 16), (8, 17), (9, 10), (9, 14),\n", " (9, 18), (10, 12), (10, 20), (11, 12), (11, 16), (11, 19), (12, 20), \n", " (13, 21), (13, 22), (14, 15), (14, 18), (15, 23), (15, 24), (16, 17),\n", " (16, 19), (17, 25), (17, 26), (18, 23), (18, 27), (19, 25), (19, 28), \n", " (20, 29), (20, 30), (21, 22), (21, 24), (21, 31), (22, 26), (22, 32), \n", " (23, 24), (23, 27), (24, 31), (25, 26), (25, 28), (26, 32), (27, 29), \n", " (27, 33), (28, 30), (28, 34), (29, 30), (29, 33), (30, 34), (31, 32), \n", " (31, 35), (32, 35), (33, 34), (33, 35), (34, 35)]\n", "G3 = Graph(edges3);\n", "G3.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The graph `G3` is $C_n$-symmetric for $n=3$:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "omega3 = [[(0, 6, 9),\n", " (1, 14, 3),\n", " (2, 15, 10),\n", " (4, 5, 18),\n", " (7, 23, 12),\n", " (8, 24, 20),\n", " (13, 27, 11),\n", " (16, 21, 29),\n", " (19, 22, 33),\n", " (17, 31, 30),\n", " (25, 32, 34),\n", " (26, 35, 28)]]\n", "G3 = CnSymmetricFlexRiGraph(G3,\n", " PermutationGroup(omega3),\n", " pos={\n", " 0:[5,7],\n", " 1:[4,0],\n", " 2:[7,5],\n", " 4:[6,-3],\n", " 7:[8,8],\n", " 8:[10,-2],\n", " 13:[12,12],\n", " 16:[14,5],\n", " 19:[14,-12],\n", " 17:[18,1],\n", " 25:[20,-5],\n", " 26:[22,3],\n", " }\n", " )\n", "G3.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The graph ``G3`` has 21 $C_3$-symmetric NAC-colorings:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(len(G3.NAC_colorings()))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We pick this one:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "delta3 = CnSymmetricNACcoloring(G3, \n", " [[{5, 7}, {26, 22}, {5, 13}, {1, 2}, {27, 23}, {18, 27}, {29, 30}, {24, 31}, \n", " {33, 35}, {9, 10}, {9, 3}, {13, 7}, {11, 4}, {10, 3}, {20, 30}, {32, 22}, \n", " {11, 12}, {24, 21}, {0, 2}, {33, 34}, {14, 15}, {20, 29}, {0, 1}, {21, 31},\n", " {19, 28}, {4, 12}, {25, 28}, {18, 23}, {6, 15}, {8, 16}, {25, 19}, {34, 35},\n", " {6, 14}, {8, 17}, {32, 26}, {16, 17}], \n", " [{17, 25}, {5, 6}, {1, 5}, {8, 2}, {33, 27}, {13, 22}, {18, 14}, {12, 20}, \n", " {8, 7}, {34, 28}, {35, 31}, {16, 19}, {3, 4}, {1, 6}, {13, 21}, {28, 30}, \n", " {10, 12}, {33, 29}, {9, 14}, {10, 20}, {0, 4}, {15, 23}, {25, 26}, {27, 29},\n", " {32, 35}, {2, 7}, {16, 11}, {11, 19}, {32, 31}, {21, 22}, {34, 30}, {24, 23},\n", " {9, 18}, {24, 15}, {17, 26}, {0, 3}]])\n", "delta3.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The construction in Theorem 2 yields a $C_3$-symmetric motion:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "M3 = GraphMotion.CnSymmetricGridConstruction(G3, delta3)\n", "M3.animation_SVG(edge_partition='NAC',\n", " fileName='AnimationTruncatedOctahedralLineGraph_FlexRiLoG',\n", " totalTime=20,\n", " vertex_labels=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One can play with the choice of $a_i$'s and $b_j$'. There are four orbits of red components and four orbits of blue components (and no partially invariant ones), so $a_i$'s and $b_j$' are determined each by four points:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "M3ab = GraphMotion.CnSymmetricGridConstruction(G3,\n", " delta3,\n", " a_base=[[0,1],[0,2],[3,0],[4,0]], # different points can be chosen here\n", " b_base=[[2,0], [3,1], [1,0], [4,0]] # or here\n", " ) \n", "M3ab.animation_SVG(edge_partition='NAC',\n", " fileName='AnimationTruncatedOctahedralLineGraph_FlexRiLoG_different_a_b',\n", " totalTime=20,\n", " vertex_labels=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Taking another NAC-coloring of ``G3``, we obtain a different motion:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "delta3b = CnSymmetricNACcoloring(G3,\n", " [[{5, 7}, {17, 25}, {1, 2}, {27, 23}, {18, 27}, {33, 27}, {13, 22}, {34, 30}, {9, 10},\n", " {5, 13}, {11, 12}, {13, 7}, {11, 4}, {35, 31}, {10, 3}, {16, 19}, {9, 3}, {17, 26}, \n", " {0, 2}, {13, 21}, {14, 15}, {0, 1}, {33, 29}, {4, 12}, {25, 26}, {27, 29}, {32, 35}, \n", " {18, 23}, {6, 15}, {16, 11}, {11, 19}, {32, 31}, {21, 22}, {34, 28}, {28, 30}, {6, 14}],\n", " [{26, 22}, {5, 6}, {1, 5}, {8, 2}, {9, 18}, {18, 14}, {20, 29}, {33, 35}, {29, 30}, \n", " {24, 31}, {12, 20}, {24, 23}, {20, 30}, {10, 20}, {32, 22}, {3, 4}, {24, 21}, {1, 6}, \n", " {33, 34}, {10, 12}, {9, 14}, {21, 31}, {19, 28}, {0, 4}, {15, 23}, {25, 28}, {0, 3},\n", " {2, 7}, {8, 16}, {24, 15}, {25, 19}, {8, 7}, {34, 35}, {8, 17}, {32, 26}, {16, 17}]\n", " ])\n", " \n", "M3anotherNAC = GraphMotion.CnSymmetricGridConstruction(G3, delta3b)\n", "M3anotherNAC.animation_SVG(edge_partition='NAC',\n", " fileName='AnimationTruncatedOctahedralLineGraph_FlexRiLoG_anotherNAC',\n", " totalTime=20,\n", " vertex_labels=False)\n" ] }, { "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" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }