Extract the coordinates of network nodes from a graphic window when n moving nodes are defined after nf fixed nodes for a VANET.
[nodex,nodey]=MobilityXYExtractionB(f,n,nf)
graphic window ID.
quantity of moving nodes
quantity of fixed nodes.
nodes x-coordinates
nodes y-coordinates
MobilityXYExtractionB extracts the coordinates of network nodes (nodex,nodey) from a graphic window when n moving nodes are defined after nf fixed nodes. It is used for the VANET scenario when roads are defined before nodes.
scf(1);//creation of a graphic window clf(1); f=gcf(); f.figure_name='MANET' ; f.pixmap='on'; //set the pixmap mode //creation of the network boundaries plot2d(0,0,-1,"011"," ",style=5,rect=[0,0,1000,1000]); xgrid; P1x=[100 900 900 100]; P1y=[100 100 900 900]; P2x=[130 870 870 130]; P2y=[130 130 870 870]; P3x=[160 160 840 840]; P3y=[160 840 840 160]; P4x=[190 190 810 810]; P4y=[190 810 810 190]; n1=15; n2=15; n3=15; n4=15; N=[n1 n2 n3 n4]; //n=50;//quantity of moving nodes n=n1+n2+n3+n4; nf=4; i1=int(4*rand(1,n1))+1; i2=int(4*rand(1,n2))+1; i3=int(4*rand(1,n3))+1; i4=int(4*rand(1,n4))+1; indc=[i1 i2 i3 i4]; nodex=[145 145 855 855 P1x(i1) P2x(i2) P3x(i3) P4x(i4) ]; nodey=[145 855 855 145 P1y(i1) P2y(i2) P3y(i3) P4y(i4) ]; Dind=[nextdestination(i1) nextdestination(i2) nextdestination(i3) nextdestination(i4)]; destx=[P1x(nextdestination(i1)) P2x(nextdestination(i2)) P3x(nextdestination(i3)) P4x(nextdestination(i4))]; desty=[P1y(nextdestination(i1)) P2y(nextdestination(i2)) P3y(nextdestination(i3)) P4y(nextdestination(i4))]; xfpolys([[P1x P1x(1)]+[-15 15 15 -15 -15]]',[[P1y P1y(1)]+[-15 -15 15 15 -15]]',31);//12 f.children.children(1).children.thickness=1; xfpolys([[P1x P1x(1)]+[15 -15 -15 15 15]]',[[P1y P1y(1)]+[15 15 -15 -15 15]]',31);//12 f.children.children(1).children.thickness=1; xfpolys([[P2x P2x(1)]+[15 -15 -15 15 15]]',[[P2y P2y(1)]+[15 15 -15 -15 15]]',30);//16 f.children.children(1).children.thickness=1; xfpolys([[P3x P3x(1)]+[15 15 -15 -15 15]]',[[P3y P3y(1)]+[15 -15 -15 15 15]]',30);//16 f.children.children(1).children.thickness=1; xfpolys([[P4x P4x(1)]+[15 15 -15 -15 15]]',[[P4y P4y(1)]+[15 -15 -15 15 15]]',8);//8 f.children.children(1).children.thickness=1; show_pixmap(); initdestx=destx; initdesty=desty; //simulation scenario [ndep,nfin]=MobilityRandom_i_j_nf(n,nf);//connection extremal nodes v=vm*rand(1,n);//velocity d=sqrt((nodex(1:n)-destx).^2+(nodey(1:n)-desty).^2);//initialization of the distance vector //display the initial state MobilityGraph2Plot(nodex(nf+1:$),nodey(nf+1:$),r,1);//fixed nodes in black (1)red (5) MobilityGraph2Plot(nodex(1:nf),nodey(1:nf),rf,5);//fixed nodes in green (3) show_pixmap();//display f=gcf();//get the figure properties i=ndep-nf;//emission node in purple (6) f.children.children(2).children(n-i+1).data(3:4)=[rs rs];//node i f.children.children(2).children(n-i+1).foreground=3;//node i f.children.children(2).children(n-i+1).background=3;//node i show_pixmap();//display t=0; Tnodes=zeros(1,n);//initialization of breaking time parameters he=[];//link head vector ta=[];//link tail vector col=[3 5 2 6]; cb=1; [nodx,nody]=MobilityXYExtractionB(f,n,nf);//Application of MobilityXYExtractionB nodx nody | ![]() | ![]() |