{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": true, "input": [ "%pylab inline\n", "%autoreload 2\n", "import equidecompose as e\n", "\n", "# JSAnimation import available at https://github.com/jakevdp/JSAnimation\n", "from JSAnimation import IPython_display" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Triangle -> Rectangle" ] }, { "cell_type": "code", "collapsed": false, "input": [ "tri = e.axis_align(e.random_triangle()).reset_transform()\n", "rect = e.tri2rect(tri)\n", "e.animate(rect, 30)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 22, "text": [ "" ] } ], "prompt_number": 22 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Rectangle -> square" ] }, { "cell_type": "code", "collapsed": false, "input": [ "rect = e.random_rect()\n", "square = e.rect2square(rect)\n", "e.animate(square, 30)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 25, "text": [ "" ] } ], "prompt_number": 25 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Triangle -> Square" ] }, { "cell_type": "code", "collapsed": false, "input": [ "tri = e.axis_align(e.random_triangle()).reset_transform()\n", "r = e.tri2rect(tri)\n", "s = e.rect2square(r)\n", "e.animate(s, 30)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 23, "text": [ "" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Triangle with premade cuts -> Square" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Uncut triangle -> square\n", "tri = e.axis_align(e.random_triangle()).reset_transform()\n", "for i in range(5):\n", " tri = e.random_cut_shape(tri)\n", "r = e.tri2rect(tri)\n", "s = e.rect2square(r)\n", "e.animate(s, 30)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 15, "text": [ "" ] } ], "prompt_number": 15 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Combine 2 squares" ] }, { "cell_type": "code", "collapsed": false, "input": [ "s1 = e.random_square()\n", "_, _, x, _ = s1.bbox()\n", "s2 = e.random_square().translate((x + 5, 0)).reset_transform()\n", "r = e.combine_two_squares(s1, s2)\n", "e.animate(r, 30)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 9, "text": [ "" ] } ], "prompt_number": 9 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Combine many square into one" ] }, { "cell_type": "code", "collapsed": false, "input": [ "squares = [e.random_square() for i in range(5)]\n", "r = e.combine_squares(squares)\n", "e.animate(r, 30)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 10, "text": [ "" ] } ], "prompt_number": 10 }, { "cell_type": "code", "collapsed": false, "input": [ "squares = [e.random_square() for i in range(3)]\n", "r = e.combine_squares(squares)\n", "e.animate(r, 30)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 26, "text": [ "" ] } ], "prompt_number": 26 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Random polygon -> square of same area" ] }, { "cell_type": "code", "collapsed": false, "input": [ "e.random_example(4)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 12, "text": [ "" ] } ], "prompt_number": 12 }, { "cell_type": "code", "collapsed": false, "input": [ "e.random_example(5)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 13, "text": [ "" ] } ], "prompt_number": 13 }, { "cell_type": "code", "collapsed": false, "input": [ "e.random_example(10)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 27, "text": [ "" ] } ], "prompt_number": 27 } ], "metadata": {} } ] }