X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=06-tour-shapes%2Ftour-creation-for-background.ipynb;h=e9848a5be14cc87742c55a7185ab4a446cc3505b;hb=a411357b201d8391e5e7c23893fca8705fd4cced;hp=7fe0db26c9d102eaf82da3a41ee425f522ba49a3;hpb=fda89d02980df6c79d05dfdc8db9bea3d7856254;p=ou-summer-of-code-2017.git diff --git a/06-tour-shapes/tour-creation-for-background.ipynb b/06-tour-shapes/tour-creation-for-background.ipynb index 7fe0db2..e9848a5 100644 --- a/06-tour-shapes/tour-creation-for-background.ipynb +++ b/06-tour-shapes/tour-creation-for-background.ipynb @@ -271,6 +271,28 @@ " min(s.y for s in trace))" ] }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'Direction' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m plot_wh = {Direction.UP: (0, 1), Direction.LEFT: (-1, 0),\n\u001b[0m\u001b[1;32m 2\u001b[0m Direction.DOWN: (0, -1), Direction.RIGHT: (1, 0)}\n", + "\u001b[0;31mNameError\u001b[0m: name 'Direction' is not defined" + ] + } + ], + "source": [ + "plot_wh = {Direction.UP: (0, 1), Direction.LEFT: (-1, 0),\n", + " Direction.DOWN: (0, -1), Direction.RIGHT: (1, 0)}" + ] + }, { "cell_type": "code", "execution_count": 16, @@ -279,9 +301,14 @@ }, "outputs": [], "source": [ - "def plot_trace(trace, colour='k', xybounds=None, fig=None, subplot_details=None, filename=None):\n", + "def plot_trace(trace, colour='k', highlight_start=True,\n", + " xybounds=None, fig=None, subplot_details=None, filename=None):\n", " plt.axis('on')\n", " plt.axes().set_aspect('equal')\n", + " \n", + " if highlight_start:\n", + " plt.axes().add_patch(plt.Circle((trace[0].x, trace[0].y), 0.2, color=colour))\n", + " \n", " for s, t in chunks(trace, 2):\n", " w, h = plot_wh[t.dir]\n", " plt.arrow(s.x, s.y, w, h, head_width=0.1, head_length=0.1, fc=colour, ec=colour, length_includes_head=True)\n", @@ -515,7 +542,9 @@ { "cell_type": "code", "execution_count": 24, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def square_tour(a=80):\n", @@ -526,7 +555,9 @@ { "cell_type": "code", "execution_count": 25, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def cross_tour(a=50, b=40):\n", @@ -537,7 +568,9 @@ { "cell_type": "code", "execution_count": 26, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def quincunx_tour(a=60, b=30, c=50):\n", @@ -548,7 +581,9 @@ { "cell_type": "code", "execution_count": 27, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "heart_points = [Step(60, 50, Direction.UP), Step(50, 90, Direction.UP),\n",