-- Vector plot example -- Gareth Rees wgr2@cam.ac.uk -- 11 March 2007 -- This example generates and then plots the flow field around a sphere -- in a uniformly flowing incompressible irrotational fluid include "vectorplot" mod(a,b)=a-b*trunc(a/b) -- make uniform grid array of xp and yp values xp[i]=(trunc((i-1)/40)-19.5)*0.1 dim[1601] yp[i]=(mod(i-1,40)-19.5)*0.1 dim[1601] -- field due to dipole at (0,0) xd:=xp: yd:=yp: rd:=sqrt(xd*xd+yd*yd): xp2:=(2-3*yd*yd/rd/rd)/4/pi/rd^3: yp2:=3*xd*yd/4/pi/rd^5: -- add field due to steady flow xp2:=xp2-1/2/pi: -- specify extent of plot Xmin=-2; Xmax=2; Ymin=-2; Ymax=2 -- Make a background image from rd[] Zmin=.04; Zmax=2.7 rimg[i,j] = 2.8-rd[(i-1)*40+j] dim[40,40] image rimg -- Plot vector field using the include file Tracecolor:=1: plotline A -- show the sphere on the plot too Tracecolor:=2: B[i]={cos(i),sin(i)} dim[360] plotline B