def __init__(self, max, figureName=None): SetVisitor.__init__(self) self.frame = IntervalVector(2, max*Interval(-1, 1)) self.figureName = figureName if figureName != None: vibes.newFigure(figureName) vibes.setFigureProperties({'x': 0, 'y': 0, 'width': 500, 'height': 500})
def test_Set2(self): vibes.beginDrawing() vibes.newFigure("set-sep") f = Function("x", "y", "x^2+(y+1)^2 - 4") set = Set(f, CmpOp.LEQ, 0.2) to_vibes = ToVibes(5) set.visit(to_vibes) vibes.endDrawing()
def test_Set2(self): vibes.beginDrawing (); vibes.newFigure("set-sep"); f = Function("x", "y", "x^2+(y+1)^2 - 4") set = Set(f,CmpOp.LEQ, 0.2) to_vibes = ToVibes(5) set.visit(to_vibes); vibes.endDrawing();
def export_data(Y, T): vibes.newFigure('Data') vibes.setFigureProperties({'x': 0, 'y': 0, 'width': 1000, 'height': 1000}) print("#" * 50) print("Data to use") for i, (y, t) in enumerate(zip(Y[::-1], T[::-1])): # print(" %d & %s & %s \\\\ \\hline"%(i+1,t,y)) print("\\draw[boxColor] (%f, %f) rectangle (%f, %f);" % (t[0], y[0], t[1], y[1])) # vibes.drawBox(t[0], t[1], y[0], y[1], 'k[lightGray]') print("#" * 50)
def __init__(self, max, figureName=None): SetVisitor.__init__(self) self.frame = IntervalVector(2, max * Interval(-1, 1)) self.figureName = figureName if figureName != None: vibes.newFigure(figureName) vibes.setFigureProperties({ 'x': 0, 'y': 0, 'width': 500, 'height': 500 })
def test_Paving2(self): P = IntervalVector(2, [-4, 4]) A = Paving(P, YES) # B = Paving(P,BoolInterval(YES)); f = Function("x", "y", "x^2 + y^2 - 4") # pdc = PdcFwdBwd(f, CmpOp.LEQ) pdc = myPdc() A.Sivia(pdc, op_And, 0.3) vibes.beginDrawing() vibes.newFigure('Test') A.visit(ToVibes(10)) vibes.endDrawing()
def test_Paving2(self): P = IntervalVector(2, [-4, 4]) A = Paving(P,YES); # B = Paving(P,BoolInterval(YES)); f = Function("x", "y", "x^2 + y^2 - 4") # pdc = PdcFwdBwd(f, CmpOp.LEQ) pdc = myPdc() A.Sivia(pdc,op_And,0.3); vibes.beginDrawing() vibes.newFigure('Test') A.visit(ToVibes(10)) vibes.endDrawing()
def test_Set3(self): fx = Function("x", "y", "(x^2-[64,81],y^2-[64,81])") sepx = SepFwdBwd(fx, CmpOp.LEQ) set = Set(2) sepx.contract(set, 8.0) vibes.beginDrawing() vibes.newFigure("set-example") to_vibes = ToVibes(5) set.visit(to_vibes) vibes.endDrawing() set.save("set-example")
def test_Set3(self): fx = Function("x","y","(x^2-[64,81],y^2-[64,81])"); sepx = SepFwdBwd(fx,CmpOp.LEQ); set = Set(2); sepx.contract(set,8.0); vibes.beginDrawing (); vibes.newFigure("set-example"); to_vibes = ToVibes(5) set.visit(to_vibes); vibes.endDrawing(); set.save("set-example");
def test_Paving3(self): P = IntervalVector(2, [-4, 4]) pdc = myPdc() A = Paving(P,YES); A.Sivia(pdc,op_And,0.3); vibes.beginDrawing() vibes.newFigure("test3") # P = IntervalVector(2, [-4, -3.9]) A.visit(ToVibes(10)) vibes.drawBox(P[0][0], P[0][1], P[1][0], P[1][1], 'r') print(P) A.ctcOutside(P) print(P) vibes.drawBox(P[0][0], P[0][1], P[1][0], P[1][1], 'g')
def test_Paving3(self): P = IntervalVector(2, [-4, 4]) pdc = myPdc() A = Paving(P, YES) A.Sivia(pdc, op_And, 0.3) vibes.beginDrawing() vibes.newFigure("test3") # P = IntervalVector(2, [-4, -3.9]) A.visit(ToVibes(10)) vibes.drawBox(P[0][0], P[0][1], P[1][0], P[1][1], 'r') print(P) A.ctcOutside(P) print(P) vibes.drawBox(P[0][0], P[0][1], P[1][0], P[1][1], 'g')
#------------------------------------------------------------------------ def sivia(X): X0 = X vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='black[blue]',figure='sivia_easibex_vibes') X = Cout(X) vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='magenta[red]',figure='sivia_easibex_vibes') #X = Cin(X) #b=inside(X); #if b==[1 1]: vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='magenta[red]',figure='sivia_easibex_vibes') #elif b==[0 0]: vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='black[blue]',figure='sivia_easibex_vibes') #elif (i_Width(X)<0.1): vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='yellow[yellow]',figure='sivia_easibex_vibes') if (i_Width(X) < 0.25): vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='yellow[yellow]',figure='sivia_easibex_vibes') #if (i_decrease(X,X0)<0.1): vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='yellow[yellow]',figure='sivia_easibex_vibes') else: X1,X2 = i_Bisect(X) sivia(X1) sivia(X2) # ---------------------- main ---------------------------- print(vibes.channel, vibes.current_fig) vibes.beginDrawing() vibes.newFigure("sivia_easibex_vibes") X=[[-4,4],[-4,4]] #X=[[-0.4,0.4],[-0.4,0.4]] vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='g[black]',figure='sivia_easibex_vibes') #X=[[0,0.4],[-0.4,0.4]] #vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='yellow[yellow]',figure='sivia_easibex_vibes') #X=[[-0.4,0],[-0.4,0.4]] #vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='magenta[red]',figure='sivia_easibex_vibes') sivia(X) vibes.endDrawing()
if __name__ == '__main__': from pyibex import Function, SepFwdBwd funcs_dict = { "SepMini": Function("x", "y", "(x - 1/2.)^2 + abs(2*y) - 1/4."), "SepNonMini": Function("x", "y", "x^2 + abs(2*y) - x"), } funcs_dict = {"SepNonMini": Function("x", "y", "x^2 + abs(2*y) - x")} # funcs_dict = { "SepNonMini" : Function("x", "y", "x^2 + y^2 + x - x + x^3 - x^3") } vibes.beginDrawing() X0 = IntervalVector(2, [-6, 6]) for name, func in funcs_dict.items(): vibes.newFigure(name) sep = SepFwdBwd(func, [3, 5]) vibes.setFigureSize(600, 600) # pySIVIA(X0, sep, 0.1, use_patch=True, color_out='#888888[#DDDDDD]', # color_in='#888888[#444444]', color_maybe='#AAAAAA[w]') # pySIVIA(X0, sep, 0.1, **siviaParams) # pySIVIA(X0, sep, 0.1, use_patch=True) S = pySepPaving(X0, sep, 0.1) S.root.reunite() vibes.newFigure("Reunite") S.root.draw() with open("tets.paving", "wb") as fid: S.root.write(fid) S2 = pySepPaving.fromFile("tets.paving")
seps = [] # empty list of separator # iterate over landmarks and distances for (m_x, m_y), d in zip(landmarks, dist): # create the constraint function f = Function("x_1", "x_2", "(x_1 - %f)^2 + (x_2 - %f)^2"%(m_x, m_y)) # create the fwdbwf separator f(x) in d sep = SepFwdBwd(f, sqr(d)) seps.append(sep) # create the separator using the QIntersection sep = SepQInterProjF(seps) sep.q = 0 # init drawing area vibes.beginDrawing() vibes.newFigure('Result') vibes.setFigureProperties({'x': 0, 'y': 0, 'width': 1000, 'height': 1000}) #configure pySIVIA output params = {'color_in': '#888888[#444444]', 'color_out': '#888888[#DDDDDD]', 'color_maybe': '#888888[w]', 'use_patch' : True} # create the initial box X0 = [-10, 10] x [-10, 10] X0 = IntervalVector([[-12, 11], [-6, 17]]) # '#888888[#DDDDDD]' # run SIVIA (res_in, res_out, res_y) = pySIVIA(X0, sep, 0.1, **params) vibes.drawAUV(robot[0], robot[1], 1, np.rad2deg(0.3)) for (x, y), d in zip(landmarks, dist):
X = np.array([[0, 0, 0, 0.5]]).T # [x, y, theta, v].T a = np.array([[-5, -5]]).T # landmark t0 = 0 tmax = 60 dt = 0.1 # step of the simulation T = np.arange(t0, tmax, dt) tm = 0.3 # period between two SIVIAs i = 0 # number of SIVIAs already computed P = pyibex.IntervalVector(2, [-20,20]) # SIVIA init box vibes.beginDrawing() vibes.newFigure("correction") time.sleep(2) for t in T: print(t) u = np.array([[0,0.3]]).T # command X += dt*f(X, u) # Euler's scheme if t > tm*(i+1): # SIVIA d = getDistanceFromLandmark(X) fCorr = pyibex.Function("x","y","({0}-x)^2 + ({1}-y)^2".format(a[0,0], a[1,0])) if i == 0: # first SIVIA ctc = pyibex.CtcFwdBwd(fCorr, sqr(d)) else: fPred = pyibex.Function('x', 'y', '(x - {0}*{1}*cos({2}), y - {0}*{1}*sin({2}))'.format(tm, X[3,0], X[2,0])) ctc_pred = pyibex.CtcInverse(ctc, fPred)
""" Simple example of the projection of a sphere """ from pyibex import * from vibes import vibes f = Function("x1", "x2", "y", "x1^2+x2^2+y^2") S1 = SepFwdBwd(f, Interval(4, 9)) Y = IntervalVector([[-1, 1]]) #S2=SepCtcPairProj(S1,Y,0.01) S2 = SepProj(S1, Y, 0.01) X0 = IntervalVector([[-10, 10], [-10, 10]]) vibes.beginDrawing() vibes.newFigure('Proj') vibes.setFigureSize(500, 500) pySIVIA(X0, S2, 0.1, use_patch=True) vibes.axisEqual()
dv = 0.5 dtheta = 0.01 t0 = 0 tmax = 60 dt = 0.1 # step of the simulation T = np.arange(t0, tmax, dt) tm = 1 # period between two SIVIAs i = 0 # number of SIVIAs already computed P = IntervalVector(2, [-20, 20]) # SIVIA init box vibes.beginDrawing() vibes.newFigure("prediction") time.sleep(2) for t in T: print(t) """measurement step""" # velocity v_noise = dv * (2 * np.random.rand() - 1) v_measured = X[3, 0] + v_noise v = Interval(v_measured - dv, v_measured + dv) # heading theta_noise = dtheta * (2 * np.random.rand() - 1) theta_measured = X[2, 0] + theta_noise theta = Interval(theta_measured - dtheta, theta_measured + dtheta)
X[0][1], X[1][0], X[1][1], color='yellow[yellow]', figure='sivia_easibex_vibes') #if (i_decrease(X,X0)<0.1): vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='yellow[yellow]',figure='sivia_easibex_vibes') else: X1, X2 = i_Bisect(X) sivia(X1) sivia(X2) # ---------------------- main ---------------------------- print(vibes.channel, vibes.current_fig) vibes.beginDrawing() vibes.newFigure("sivia_easibex_vibes") X = [[-4, 4], [-4, 4]] #X=[[-0.4,0.4],[-0.4,0.4]] vibes.drawBox(X[0][0], X[0][1], X[1][0], X[1][1], color='g[black]', figure='sivia_easibex_vibes') #X=[[0,0.4],[-0.4,0.4]] #vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='yellow[yellow]',figure='sivia_easibex_vibes') #X=[[-0.4,0],[-0.4,0.4]] #vibes.drawBox(X[0][0],X[0][1],X[1][0],X[1][1],color='magenta[red]',figure='sivia_easibex_vibes') sivia(X) vibes.endDrawing()
# SIVIA test for Gascogne Golf img = cv2.imread('Gascogne2.png',0) #Read the image of the Gascogne Golf in the gray color retval, img_bin = cv2.threshold(img, 254, 1, cv2.THRESH_BINARY_INV) #Binarisation of the image imgIntegral = cv2.integral(img_bin) #Calcul of the integral of the image j_max,i_max=imgIntegral.shape #Dimension of the image pdcGascogne = ImageToBoxes(imgIntegral,i0,j0,echellePixel) #Creation of an object of the class PavageGascogne #Area of calcul / First box for SIVIA algorithm X0=IntervalVector([[-i0*echellePixel, (-i0+i_max-1)*echellePixel], [(j0-j_max+1)*echellePixel, j0*echellePixel]]) imgOut=np.zeros((j_max, i_max),dtype="uint8") #Definition of the draw window: vibes.beginDrawing() vibes.newFigure('Robotique') vibes.setFigureProperties(dict(x=600, y=200, width=j_max, height=i_max)) vibes.axisLimits(X0[0].lb(),X0[0].ub(),X0[1].lb(),X0[1].ub()) #Loop for i in range(100): for r in range(nbsRobots): m[r][0] = Interval(position[i][r][1]).inflate(PositionIncertitude) #x m[r][1] = Interval(position[i][r][2]).inflate(PositionIncertitude) #y t = m[i][0][0] #SIVIA test for Robots secure area whith incertitude pdcRobots = IncertitudeRobots(m,r**2) # SIVIA test for Trail
from vibes import vibes from pyIbex import PixelMap2D, CtcPixelMap, IntervalVector, Interval from scipy import misc import numpy as np """ Example : image contractor """ # Generate the image using vibes # Only use for drawing vibes.beginDrawing() vibes.newFigure('Map') vibes.setFigureProperties({'x': 0, 'y': 0, 'width': 500, 'height': 500}) vibes.drawCircle(4, 4, 3, '[k]') vibes.drawLine([[-3, -1], [7, -1]], '[k]') vibes.drawLine([[7, -1], [7, 1]], '[k]') vibes.axisLimits(-4, 8, -4, 8) # Read the image and extract the last layer img = misc.imread('./img.png')[:, :, 3] # normalize in order to have a binary image. img = img / np.max(img) if np.max(img) != 1: print("Error, img must be a binary image") # convert img into a unsigned int64 image type img = img.astype(np.uint64) # vertical flip to inverse the y axis img = np.flipud(img) # PixelMap2D constructor takes :
#exmaple.py from vibes import vibes print(vibes.channel, vibes.current_fig) vibes.beginDrawing() vibes.newFigure("test") vibes.drawBox(0,1,4,6,color='[#FF12FFA0]', figure='test') vibes.drawText(12, 12, 'My Text', 0.1, 'b[r]') vibes.axisAuto() vibes.drawBox(0.5,2,4,7,color='[#00FFFF66]', figure='test') vibes.drawBox(-1,0,-4,-6,color='r', figure='test') vibes.drawLine([[0,0], [4,4]]) vibes.drawEllipse(3, 5, 1, 3, 45) vibes.drawEllipse(5, 5, 3, 3, 0, angles=[30,60], color='g') vibes.drawCircle(0, 0, 5) vibes.drawAUV(0,0, 2, 3, color='r[yellow]') vibes.drawPie([0,0], [3,4], [45, 90]) vibes.newGroup("Pie", figure="test", format='[cyan]') vibes.drawPie([0,0], [5,9], [-120, -40], group="Pie") # vibes.drawPie([0,0], [5,9], [-120, -40], "[b]") vibes.drawPie([5,2], [1,2], [160, 220]) #, 'g[y]') # vibes.clearGroup("Pie", figure="test")
vibes.drawBox(xx[0], xx[1], yy[0], yy[1], 'b') # if key in actions: # x, y, th = actions[key]( x,y,th ) # fct = actions.get(key, lambda x,y,th:x,y,th) stdscr.clear() stdscr.addstr(1, 10, "Pressed %s %d" % (lower_key, key)) stdscr.addstr(1, 25, str(curses.ascii.ctrl(key))) stdscr.addstr(1, 40, str(curses.ascii.ascii(key))) stdscr.addstr(1, 40, str(curses.ascii.alt(key))) stdscr.addstr(3, 20, "x : %s\t\t%s" % (x, xx)) stdscr.addstr(4, 20, "y : %s\t\t%s" % (y, yy)) stdscr.addstr(5, 20, "theta : %s\t\t%s" % (th, thh)) if key == ord("t"): fout.write("%s %s %s -> %s %s %s\n" % (x, y, th, xx, yy, thh)) stdscr.refresh() curses.endwin() fout.write("#===================== END ===============\n") if __name__ == '__main__': vibes.beginDrawing() vibes.newFigure("Debut Catan2") vibes.setFigureSize(500, 500) vibes.drawBox(-5, 5, -5, 5) vibes.axisAuto() wrapper(main)
from vibes import vibes from pyIbex import PixelMap2D, CtcPixelMap, IntervalVector, Interval from scipy import misc import numpy as np """ Example : image contractor """ # Generate the image using vibes # Only use for drawing vibes.beginDrawing() vibes.newFigure('Map') vibes.setFigureProperties({'x': 0, 'y': 0, 'width': 500, 'height': 500}) vibes.drawCircle(4, 4, 3, '[k]') vibes.drawLine([[-3, -1], [7, -1]], '[k]') vibes.drawLine([[7, -1], [7, 1]], '[k]') vibes.axisLimits(-4,8,-4,8) # Read the image and extract the last layer img = misc.imread('./img.png')[:,:,3] # normalize in order to have a binary image. img = img/np.max(img) if np.max(img) != 1: print("Error, img must be a binary image") # convert img into a unsigned int64 image type img = img.astype(np.uint64) # vertical flip to inverse the y axis img = np.flipud(img)
sep = SepInter(seps) X0 = IntervalVector(2, Interval(0, 1.2)) X0[1] = Interval(0, 0.5) return sep, X0, 0.01 if __name__ == '__main__': vibes.beginDrawing() sep, X0, eps = test_paramEstim(True) # init drawing area vibes.newFigure('Result') vibes.setFigureProperties({'x': 0, 'y': 0, 'width': 1000, 'height': 1000}) #configure pySIVIA output params = { 'color_in': '#888888[#444444]', 'color_out': '#888888[#DDDDDD]', 'color_maybe': '#888888[q]', 'use_patch': True } # run SIVIA (res_in, res_out, res_y) = pySIVIA(X0, sep, eps, use_patch=True, display_stats=True ) #, color_out='transparent', color_in='transparent')
import numpy as np import math as m from pyIbex import * from vibes import vibes import time from SaveLoadData import * if __name__ == '__main__': A=[1,1] B=[0,-1] C=[-1,0] vibes.beginDrawing() vibes.newFigure('TestCase1') vibes.setFigureProperties({'x': 0, 'y': 0,'width': 500, 'height': 500}) vibes.axisLimits(-25, 25, -25, 25) t,dt,Field,inc,dif,x,y,xmp,ymp,xm,ym = loadData("rot1.pckl") t,dt,Field,inc,dif,x2,y2,xmp,ymp,xm,ym = loadData("rot2.pckl") time.sleep(15) for i in range(len(t)): vibes.drawCircle(x[i], y[i], 1, 'black[green]') vibes.drawCircle(x2[i], y2[i], 1, 'black[red]') vibes.drawCircle(xm, ym, 0.4, 'black[blue]') vibes.drawArrow([20, 15], [15, 15], 1, 'black[black]') vibes.drawArrow([20, 10], [15, 10], 1, 'black[black]') vibes.drawArrow([20, 5], [15, 5], 1, 'black[black]') vibes.drawArrow([20, 0], [15, 0], 1, 'black[black]') vibes.drawArrow([20, -5], [15, -5], 1, 'black[black]') time.sleep(0.001)
color_maybe) res_y.append(X) elif (X.is_empty() is False): (X1, X2) = lf.bisect(X) stack.append(X1) stack.append(X2) print('number of separation %d / number of boxes %d' % (k, len(res_in) + len(res_out) + len(res_y))) return (res_in, res_out, res_y) if __name__ == '__main__': from pyibex import * f = Function('x', 'y', 'x^2 + y^2') ctc = CtcFwdBwd(f, sqr(Interval(3, 4))) sep = SepFwdBwd(f, sqr(Interval(3, 4))) params = { 'color_in': 'r[g]', 'color_out': 'b[#AACC00]', 'color_maybe': 'k[y]', 'use_patch': False } box = IntervalVector(2, [-5, 5]) vibes.beginDrawing() pySIVIA(box, ctc, 0.1, draw_boxes=True, save_result=False, **params) vibes.newFigure('test2') pySIVIA(box, sep, 0.1, draw_boxes=True, save_result=False, **params) vibes.endDrawing()
v3=0 p1=math.pi p2=0 p3=math.pi/2 # commande u1=[1,0] u2=[1,0] u3=[1,0] # simulation h=0.7 vibes.beginDrawing() vibes.newFigure('Zone de non detection') vibes.setFigureProperties({'x':500, 'y':100, 'width':800, 'height':800}) # # test unitaire # m= [[cx1 , cy1 ],[cx2, cy2],[cx3, cy3]] # pdc = test3(m) # #vibes.clearFigure() # SIVIA(X0, pdc, 0.5) # # for m_ in m: # vibes.drawCircle(m_[0].mid(), m_[1].mid(), 0.2, '[k]') # vibes.drawArrow([-15, -15], [-15, -10], 1, 'w[w]') # vibes.drawArrow([-15, -15], [-10, -15], 1, 'w[w]') for t in range(10):
#exmaple.py from vibes import vibes print(vibes.channel, vibes.current_fig) vibes.beginDrawing() vibes.newFigure("test") vibes.drawBox(0, 1, 4, 6, color='[#FF12FFA0]', figure='test') vibes.drawText(12, 12, 'My Text', 0.1, 'b[r]') vibes.axisAuto() vibes.drawBox(0.5, 2, 4, 7, color='[#00FFFF66]', figure='test') vibes.drawBox(-1, 0, -4, -6, color='r', figure='test') vibes.drawLine([[0, 0], [4, 4]]) vibes.drawEllipse(3, 5, 1, 3, 45) vibes.drawEllipse(5, 5, 3, 3, 0, angles=[30, 60], color='g') vibes.drawCircle(0, 0, 5) vibes.drawAUV(0, 0, 2, 3, color='r[yellow]') vibes.drawPie([0, 0], [3, 4], [45, 90]) vibes.newGroup("Pie", figure="test", format='[cyan]') vibes.drawPie([0, 0], [5, 9], [-120, -40], group="Pie") # vibes.drawPie([0,0], [5,9], [-120, -40], "[b]") vibes.drawPie([5, 2], [1, 2], [160, 220]) #, 'g[y]') # vibes.clearGroup("Pie", figure="test") vibes.drawPie([0, 0], [1, 2], [160, 220]) #, 'g[y]')
vibes.drawPie((0,0), (1e-5,5), thh*180./math.pi, "b") vibes.drawBox(xx[0], xx[1], yy[0], yy[1], 'b') # if key in actions: # x, y, th = actions[key]( x,y,th ) # fct = actions.get(key, lambda x,y,th:x,y,th) stdscr.clear() stdscr.addstr(1, 10, "Pressed %s %d"%(lower_key, key)) stdscr.addstr(1,25,str(curses.ascii.ctrl(key))) stdscr.addstr(1,40,str(curses.ascii.ascii(key))) stdscr.addstr(1,40,str(curses.ascii.alt(key))) stdscr.addstr(3, 20, "x : %s\t\t%s"%(x,xx)) stdscr.addstr(4, 20, "y : %s\t\t%s"%(y,yy)) stdscr.addstr(5, 20, "theta : %s\t\t%s"%(th, thh)) if key == ord("t"): fout.write("%s %s %s -> %s %s %s\n"%(x,y,th, xx, yy, thh)) stdscr.refresh() curses.endwin() fout.write("#===================== END ===============\n"); if __name__ == '__main__': vibes.beginDrawing() vibes.newFigure("Debut Catan2") vibes.setFigureSize(500,500) vibes.drawBox(-5,5,-5,5) vibes.axisAuto() wrapper(main)
def newFigure(name): vibes.newFigure(name) vibes.setFigureProperties({'x':0, 'y':0, 'width':1024, 'height':500, 'viewbox':'equal'}) vibes.axisLimits(x_min-offset, x_max+offset, y_min-offset, y_max+offset) vibes.drawBox(x_min-offset, x_max+offset, y_min-offset, y_max+offset, "white[white]")
(x, y) = yield vibes.drawCircle(x, y, 1, "g[m]") (x, y) = yield vibes.drawEllipse(x, y, 2, 1, 45, color="r[darkCyan]") (x, y) = yield vibes.drawLine([[x - 0.5, y - 1], [x + 1, y + 0.5]], "k") (x, y) = yield vibes.drawPie((x - 2, y - 2), (1, 2.5), [20, 70], "y[cyan]") (x, y) = yield vibes.drawPolygon([[x - 1, y - 1], [x, y + 1], [x + 1, y - 1]], "k[orange]") (x, y) = yield vibes.drawRing(x, y, 1, 2, '[red]') # (x,y) = yield vibes.drawPie( (x, y), (1,2), [0,360] , "y[cyan]") (x, y) = yield vibes.drawVehicle(x, y, 20, 1, "[darkBlue]") (x, y) = yield vibes.drawPoint(x, y, 1, "[k]") (x, y) = yield vibes.drawText(x, y, "Text", 1) vibes.beginDrawing() vibes.newFigure("example") vibes.setFigureProperties({"x": 100, "y": 100, "width": 500, "height": 500}) dd = shapeGen() dd.send(None) # dd.next() for x in range(0, 14, 4): for y in range(0, 14, 4): try: dd.send((y, -x)) except StopIteration: # print("stop iter") break vibes.axisEqual()
phi = Tube(tdomain, h / 2, Interval()) phi.set(interval, Interval(0, h / 2)) out.append(integrate_box(phi, v, theta, h / 2)) return union(out), out if __name__ == "__main__": h = 1 / 20 phi = Interval(-np.pi / 2, np.pi / 2) alpha = 0.01 deltat = 300 vibes.beginDrawing() vibes.newFigure("MagMap") vibes.setFigureProperties({ "x": 200, "y": 200, "width": 600, "height": 600 }) vibes.axisLimits(-h, deltat * h, -np.pi / 2, np.pi / 2) for k in range(deltat): v = Interval(1.0) theta = Interval(0.4 * np.sin(k / 20)) I, out = integrate(phi, alpha, v, theta, h) lb, ub = I.lb(), I.ub() vibes.drawBox(k * h, (k + 1) * h, lb, ub, "darkCyan[darkCyan]") phi = Interval(lb, ub)
(y / 500)**2)) + 6 * np.exp(-((x + 600) / 300)**2 - ((y - 400) / 300)**2) - 20 plt.subplot(121) cont = plt.contour(x, y, h, 10) plt.clabel(cont, inline=1, fontsize=8) plt.axis('equal') h0 = -17 dh = 0.3 ### generate the slice image for an altitude h0 ### hBin = ((h < h0 + dh) * (h > h0 - dh)).astype(int) plt.subplot(122) plt.imshow(hBin, extent=[-1000, 1000, -1000, 1000], origin='lower') plt.title("h0 = " + str(h0) + ", dh = " + str(dh)) plt.show() ### create the contractor associated with the slice hBin = np.flipud( hBin) # flip the slice (the origin for an image is the top-left corner) hOut = hBin.cumsum(0).cumsum(1) # compute the integral image ctc = CtcRaster(hOut.T, -1000, 1000, 4, -4) ### results on Vibes ### vibes.beginDrawing() vibes.newFigure('CtcImage') P = IntervalVector(2, [-1000, 1000]) pySIVIA(P, ctc, 30) vibes.axisEqual()
(x,y) = yield vibes.drawAUV(x,y,45,2, 'k[y]') (x,y) = yield vibes.drawBox(x-1,x+1,y-2,y+2, "[b]") (x,y) = yield vibes.drawBoxesUnion([[x-1,x,y-2,y], [x-0.5,x+1,y-0.5,y+2]], "[r]") (x,y) = yield vibes.drawCircle(x,y,1, "g[m]") (x,y) = yield vibes.drawEllipse(x,y,2,1,45, color="r[darkCyan]") (x,y) = yield vibes.drawLine([[x-0.5, y-1], [x+1, y+0.5]], "k") (x,y) = yield vibes.drawPie( (x-2, y-2), (1,2.5), [20,70] , "y[cyan]") (x,y) = yield vibes.drawPolygon([[x-1,y-1], [x, y+1], [ x+1, y-1]], "k[orange]") (x,y) = yield vibes.drawRing(x,y, 1,2, '[red]') # (x,y) = yield vibes.drawPie( (x, y), (1,2), [0,360] , "y[cyan]") (x,y) = yield vibes.drawVehicle( x, y, 20, 1, "[darkBlue]") (x,y) = yield vibes.drawPoint( x,y, 1, "[k]") (x,y) = yield vibes.drawText( x,y, "Text", 1) vibes.beginDrawing() vibes.newFigure("example") vibes.setFigureProperties( { "x": 100,"y": 100,"width": 500,"height": 500} ) dd =shapeGen() dd.send(None) # dd.next() for x in range(0,14,4): for y in range(0,14,4): try: dd.send((y,-x)) except StopIteration: # print("stop iter") break vibes.axisEqual()