Fri 29 Nov 2024 04:30:50 PM CET

This commit is contained in:
sbosse 2024-11-29 16:31:08 +01:00
parent f8e4ff381d
commit 61025b7ca7

View File

@ -0,0 +1,159 @@
{
"metadata": {
"name": "",
"signature": "sha256:93a4bc0a8c10cda2b046ddec701b7579a4ab116bfc7ab026f65073ed6ef9a967"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from quadtree import ellipseMatrix\n",
"import time\n",
"from matplotlib.patches import Ellipse\n",
"from pylab import figure, show, rand"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%run -p test_packing.py"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"0 50.0 184304.092036\n",
"1 38.0 183802.842426\n",
"2 29.0 183302.956059\n",
"3 22.0 182804.429226\n",
"4 17.0 182307.258231\n",
"5"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 13.0 181811.439386\n",
"6"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 10.0 181316.969013\n",
"7"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 7.0 180823.843445\n",
"8"
]
}
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"print \"draw\"\n",
"start = time.time()\n",
"\n",
"for c in Objs:\n",
" ellipseMatrix(c.y(), c.x(), c.a(), c.b(), c.theta(), Image, Label, XX, YY)\n",
" \n",
"print time.time()-start"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"plt.figure()\n",
"plt.imshow(Image)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"ells = [Ellipse(xy=[c.x(), c.y()], width=2*c.a(), height=2*c.b(), angle=c.theta()*180.0/np.pi)\n",
" for c in Objs]\n",
"\n",
"fig = figure()\n",
"ax = fig.add_subplot(111, aspect='equal')\n",
"for e in ells:\n",
" ax.add_artist(e)\n",
" e.set_clip_box(ax.bbox)\n",
" #e.set_alpha(rand())\n",
" #e.set_facecolor([1.0,0,0])\n",
" #e.set_edgecolor([1.0,0,0])\n",
" e.set_facecolor(rand(3))\n",
" \n",
"ax.set_xlim(0, 2000)\n",
"ax.set_ylim(0, 2000)\n",
"\n",
"show()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}