! ! Plotting of arrows from a vector field data file ! ! True Basic version written by H. Nakanishi ! program flow option nolet library "sgfunc.trc" library "sglib.trc" dim x(0),y(0),z1(0),z2(0),r(0) ! ! Use subs to do the work ! call init(if$,rmin,afac,aoff,x,y,z1,z2,r,n) call disp(if$,rmin,afac,aoff,x,y,z1,z2,r,n) get key z end ! sub init(if$,rmin,afac,aoff,x(),y(),z1(),z2(),r(),n) ! ! Initialize variables ! mat redim x(1000),y(1000),z1(1000),z2(1000),r(1000) input prompt "Flow: input file name -> ": if$ open #1: name if$, organization text, create old rmin=0 rmax=0 i=1 do ask #1: pointer place$ if place$ = "END" then exit do input #1: x(i),y(i),z1(i),z2(i) r(i)=sqr(z1(i)^2+z2(i)^2) if r(i)rmax then rmax=r(i) i=i+1 loop close #1 n=i-1 mat redim r(n),x(n),y(n),z1(n),z2(n) print "max vector length = ",rmax,", min = ",rmin if rmax <> rmin then input prompt "map the max lengths to -> ": amax input prompt "map the min lengths to -> ": amin afac=(amax-amin)/(rmax-rmin) aoff=amin else input prompt "map the arrow length to -> ": amin afac=0 aoff=amin amax=amin end if end sub sub disp(if$,rmin,afac,aoff,x(),y(),z1(),z2(),r(),n) set background color "white" call setcanvas("white") set color "black" clear call settitle("Vector Field Diagram") call sethlabel("X") call setvlabel("Y") for i=1 to n r0=sqr(z1(i)^2+z2(i)^2) a0=afac*(r0-rmin)+aoff if r0 <> 0 then z1(i)=z1(i)*a0/r0 z2(i)=z2(i)*a0/r0 end if next i call vectorgraph(x,y,z1,z2,1,3,"black") ! make vector plot end sub