Extract the graph nodes' coordinates from a graphic window when N moving nodes are defined after Nf fixed nodes (VANET).
[Nx,Ny] = NL_F_XYExtractionVanet(F,N,Nf)
Graphic window ID.
Quantity of moving nodes.
Quantity of fixed nodes.
X-coordinates.
Y-coordinates.
NL_F_XYExtractionVanet extracts the graph nodes' coordinates from the graphic window defined by its handle F when N moving nodes are defined after
fixed nodes. It is used for the VANET scenario when roads are defined before the nodes.
w=1;//window index scf(w);//creation of a graphic window clf(w); f=gcf(); f.figure_name='VANET' ; //f.pixmap='on'; //set the pixmap mode plot2d(0,0,-1,"011"," ",style=5,rect=[0,0,1000,1000]);//creation of the network boundaries 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=n1+n2+n3+n4;//quantity of moving nodes 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=[NL_M_VanetNextWayPoint(i1) NL_M_VanetNextWayPoint(i2) NL_M_VanetNextWayPoint(i3) NL_M_VanetNextWayPoint(i4)]; destx=[P1x(NL_M_VanetNextWayPoint(i1)) P2x(NL_M_VanetNextWayPoint(i2)) P3x(NL_M_VanetNextWayPoint(i3)) P4x(NL_M_VanetNextWayPoint(i4))]; desty=[P1y(NL_M_VanetNextWayPoint(i1)) P2y(NL_M_VanetNextWayPoint(i2)) P3y(NL_M_VanetNextWayPoint(i3)) P4y(NL_M_VanetNextWayPoint(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]=NL_F_RandIntNiNjNf(n,nf);//connection extremal nodes vm=10; r=10; rf=15;//display radius of fixed nodes rs=15;//display radius of the moving nodes belonging to the connection under studies 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 NL_M_GraphAnimation(nodex(nf+1:$),nodey(nf+1:$),r,1,w);//fixed nodes in black (1)red (5) NL_M_GraphAnimation(nodex(1:nf),nodey(1:nf),rf,5,w);//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; //f.pixmap='off'; [nodx,nody]=NL_F_XYExtractionVanet(f,n,nf)//Application of NL_M_XYExtractionVanet | ![]() | ![]() |