X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Ftests%2Foa%2Fgraph.py;h=48e9cc3a5c658a7d1d3f10d77b4875b512258d91;hp=7ba6948ff85124cc7f40b8cdcb966676f2e0d5ae;hb=17aadc4c8c3e60c2b5e6bbba91c8542849addbd7;hpb=a15451f8535228e9193b5dc042929ca0a7f79d9c diff --git a/projects/microb2010/tests/oa/graph.py b/projects/microb2010/tests/oa/graph.py index 7ba6948..48e9cc3 100644 --- a/projects/microb2010/tests/oa/graph.py +++ b/projects/microb2010/tests/oa/graph.py @@ -166,6 +166,40 @@ def build_path(ptlist): x, y = zip(*poly.vertices) return x,y +def nearest_corn(x, y): + OFFX=150 + OFFY=222 + STEPX=450 + STEPY=500 + + x -= OFFX + x += STEPX/2 + x /= STEPX + + y -= OFFY + y += STEPY/2 + if (x & 1) == 1: + y -= STEPY/2 + y /= STEPY + + i = (x * 2) + j = (y * 2) + (x & 1) + if i >= WAYPOINTS_NBX: + return None + if j >= WAYPOINTS_NBY: + return None + + if (i & 1) == 0: + y = OFFSET_CORN_Y + else: + y = OFFSET_CORN_Y + STEP_CORN_Y/2 + y += (j * STEP_CORN_Y) + + x = OFFSET_CORN_X + (i * STEP_CORN_X) + + return x, y + + def build_area(ax): # area x,y = build_poly([(0,0), (3000,0), (3000,2100), (0,2100)]) @@ -180,6 +214,8 @@ def build_area(ax): x,y = build_poly([(740,0), (740,500), (2260,500), (2260,0)]) ax.plot(x, y, 'g--') + """ + # courbes a 2 balles x,y = build_path([(375,0), (375,2050)]) ax.plot(x, y, 'r-') @@ -197,6 +233,26 @@ def build_area(ax): x,y = build_path([(600,1972), (600+bcoef, 1972-acoef)]) ax.plot(x, y, 'r-') + p = PatchCollection([Circle((2400,972), 225)], + cmap=matplotlib.cm.jet, + alpha=0.5, facecolor=(1.,0.,0.)) + ax.add_collection(p) + + """ + + """ + #courbes a 2 balles 50 + for xx in range(0, 3000, 100): + print xx + for yy in range(0, 2100, 100): + pouet = nearest_corn(xx, yy) + if pouet == None: + continue + xxx, yyy = pouet + x,y = build_path([(xx,yy), (xxx,yyy)]) + ax.plot(x, y, 'r-') + """ + # limit #x,y = build_poly([(250,250), (2750,250), (2750,1850), (250,1850)]) #ax.plot(x, y, 'g--') @@ -268,13 +324,15 @@ def build_area(ax): def graph(filename): fig = plt.figure() - ax = fig.add_subplot(111) + ax = fig.add_subplot(111, aspect='equal') build_area(ax) ax.grid(color = (0.3, 0.3, 0.3)) ax.set_xlim(-100, 3100) ax.set_ylim(-100, 2200) + #ax.set_xlim(0, 825) + #ax.set_ylim(1472, 1972) #ax.set_title('spline paths') #plt.show() fig.savefig(filename)