X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Ftests%2Foa%2Fgraph.py;h=48e9cc3a5c658a7d1d3f10d77b4875b512258d91;hp=b7e5853bb663f4b4731b9536f85b476b5c4a4054;hb=17aadc4c8c3e60c2b5e6bbba91c8542849addbd7;hpb=57c8774dea2b516aec344a046f562aeac979d24e diff --git a/projects/microb2010/tests/oa/graph.py b/projects/microb2010/tests/oa/graph.py index b7e5853..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--') @@ -275,6 +331,8 @@ def graph(filename): 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)