///withoutPrompt function draw_chain_from_angles(a,r,job,rt) // a the angles , a(i,j) is the angle of node i at time t(j) // r the segments half length if argn(2)<3 then job=0,end if argn(2)<4 then rt = 0.01;end n2=size(a,2); x=[0*ones(1,n2);cumsum(2*diag(r)*cos(a),1)]; y=[0*ones(1,n2);cumsum(2*diag(r)*sin(a),1)]; draw_chain_from_coordinates(x,y,job,rt) endfunction function draw_chain_from_coordinates(x,y,job,rt) // x(i,j), y(i,j) is the coordinate of node i at time t(j) // r the segments half length if argn(2)<3 then job=0,end if argn(2)<4 then rt = 0.01;end [n1,n2]=size(x); b = maxi(maxi(abs(x)),maxi(abs(y))); xbasc();set figure_style new; /// \sleftarrow{\normalfont new graphics mode } a=gca() /// \sleftarrow{\normalfont we want to set } a.data_bounds=[-1,-1;1,0]*b;/// \sleftarrow{\normalfont the graphics boundaries } a.isoview="on";/// \sleftarrow{\normalfont and use an isoview mode } xset('pixmap',1); /// \sleftarrow{\normalfont double buffer mode } drawlater() /// \sleftarrow{\normalfont wait {for} graphics display } colors= 1:n1-1; colors(8)=n1; xsegs([x(1:$-1,1)';x(2:$,1)'],[y(1:$-1,1)';y(2:$,1)'],colors) /// \sleftarrow{\normalfont draw} p=gce();p.thickness=4; /// \sleftarrow{\normalfont \verb+p+ is used to keep track of \verb+xsegs+ data } if job==1 then xpoly(x($,1)*ones(2,1),y($,1)*ones(2,1),'lines'); /// \sleftarrow{\normalfont {end}point trajectory} t=gce();t.line_style=2; end drawnow() /// \sleftarrow{\normalfont perform drawing } xset('wshow') /// \sleftarrow{\normalfont update display with double buffer } ind=[1;(2:n1-1)'.*.ones(2,1);n1] realtimeinit(rt); /// \sleftarrow{\normalfont set time unit: smaller values will accelerate the animation } for j=1:n2, realtime(j) /// \sleftarrow{\normalfont wait to time \verb+j+ before continuing } drawlater() p.data = [x(ind,j),y(ind,j)]; /// \sleftarrow{\normalfont update \verb+xsegs+ data } if job==1 then t.data=[t.data;[x($,j),y($,j)]],end/// \sleftarrow{\normalfont update \verb+xpoly+ data } drawnow() /// \sleftarrow{\normalfont since objects are updated, graphics is cleared and redrawn } xset('wshow') /// \sleftarrow{\normalfont update display with double buffer } end endfunction ///\withPrompt{}