WQStools: colors, hlpWQStools, GP,GP2, GP3,PT,PP,DL,ARRW, DV,MM
>
WQStools := table([]):
WQStools[version_date] := `6/20/99`:
>
WQStools[hlpWQStools] := proc()
lprint(`graph paper: GP(llcorner, width, height, resolution,TMfont)`);
lprint(`graph paper 2: GP2(optional llhc, width, height, xres,yres,clrs,xlabl,ylabl, TMfont)`);
lprint(`graph paper 3: GP3(optional llhc, width, height, depth,xres,yres,zres,clrs,xlabl,ylabl,zlabl, TMfont)`);
lprint(`plot point: PP(location,optional radius,clr,name)`);
lprint(`draw line: DL(A,B, optional thknss, styl,clr)`);
lprint(`put text: PT(location,txt, optional fntsize,clr)`);
lprint(`draw arrow: ARRW(A,B, optional colr,DH or SH, mul ,hdwidth,hdlngth)`);
lprint(`draw vector: DV(A,B,optional name, clr)`);
lprint(`make movie: MM(partslist,time_interval,numframes)`);
lprint(`where partslist is a list of functions of time, each`);
lprint(`of which returns a plot structure.`);
end:
>
WQStools[colors] := proc()
print(`aquamarine black blue navy coral cyan brown gold green gray grey khaki magenta maroon orange pink plum red sienna tan turquoise violet wheat white yellow`) end:
>
WQStools[GP]:=proc(llhc,width,height,res,TMfont) local V,H,i:
V := seq(plot([[llhc[1]+i/res,
llhc[2]],[llhc[1]+i/res,llhc[2]+height]],
color=black),i=0..width*res):
>
H :=seq(plot([[llhc[1] ,llhc[2]+i/res],
[llhc[1]+width,llhc[2]+i/res]],color=black),
i=0..height*res):
if TMfont=`NTM` then
plots[display]([V,H],scaling=constrained,
xtickmarks =[], ytickmarks =[]):
elif
TMfont=0 then
plots[display]([V,H],scaling=constrained,
xtickmarks =[], ytickmarks =[],axes=none):
else
>
plots[display]([V,H],scaling=constrained, xtickmarks =[seq(i, i=llhc[1]..llhc[1]+width)], ytickmarks =
[seq(i, i=llhc[2]..llhc[2]+height)], axesfont=[TIMES,BOLD,TMfont]):
fi:
end:
>
WQStools[GP2]:=proc()
local llhc, width, height, xres,yres,clrs,xlabl,ylabl, TMfont,V, H, i;
llhc := [-5,-5]:width:=10:height:=10:xres:=1:yres:=1:
clrs :=[black,black]:xlabl:=`x`: ylabl:=`y`:TMfont:=NTM:
if nargs >=1 then llhc:=args[1] fi;
if nargs >=2 then width:=args[2] fi;
if nargs >=3 then height:= args[3] fi;
if nargs >=4 then xres:= args[4] fi;
if nargs >=5 then yres:= args[5] fi;
if nargs >=6 then clrs:= args[6] fi;
if nargs >=7 then xlabl:= args[7] fi;
if nargs >=8 then ylabl:= args[8] fi;
if nargs >=9 then TMfont:= args[9] fi;
V := plot([seq(
[[llhc[1] + i*xres, llhc[2]], [llhc[1] + i*xres, llhc[2] + height]],
i = 0 .. width/xres)],color = clrs[1]);
H := plot([seq(
[[llhc[1], llhc[2] + i*yres], [llhc[1] + width, llhc[2] + i*yres]],
i = 0 .. height/yres)],color = clrs[2]);
if TMfont = NTM then plots[display]([V, H], xtickmarks = [seq(llhc[1]+i*xres,i=0..width/xres)], ytickmarks = [seq(llhc[2]+i*yres,i=0..height/xres)])
elif TMfont = 0 then plots[display]([V, H], xtickmarks = [], ytickmarks = [], axes = none)
else plots[display]([V, H],labels=[xlabl,ylabl], xtickmarks = [seq(llhc[1]+i*xres,i=0..width/xres)], ytickmarks = [seq(llhc[2]+i*yres,i=0..height/yres)],
axesfont = [TIMES, BOLD, TMfont],
labelfont=[TIMES,BOLD,TMfont])
fi
end:
>
>
WQStools[DL]:=proc(A,B)
local thknss, styl,clr;
thknss := 3; styl := 2: clr := blue:
if nargs >= 3 then thknss := args[3] fi;
if nargs >= 4 then styl := args[4] fi;
if nargs >= 5 then clr := args[5] fi;
if nops(A) =3 and nops(B)=3 then
plots[polygonplot3d]([A,B],style = line, linestyle=styl,thickness=thknss,color=clr):
elif
nops(A) =2 and nops(B)=2 then
plots[polygonplot]([A,B],style = line, linestyle=styl,thickness=thknss,color=clr)
else RETURN(`bad data`) fi:
end:
>
WQStools[PT]:= proc(location)
#location,txt,fntsize,clr
local txt, fntsize, clr;
txt := args[2]:
fntsize := 12;
clr := black;
if nargs > 2 then fntsize := args[3] fi:
if nargs > 3 then clr := args[4] fi:
if nops(location)=3 then
plots[textplot3d]([location[1],location[2],location[3],txt],
font=[TIMES,BOLD,fntsize], color=clr)
else
plots[textplot]([op(1,location),op(2,location),txt],
font=[TIMES,BOLD,fntsize], color=clr)
fi:
end:
WQStools[PP]:=proc(location)
local radius, clr,plts,pos;
radius := .1; clr := black;
if nargs >= 2 then radius := args[2] fi;
if nargs >=3 then clr := args[3] fi;
if nops(location) = 2 then
plts :=plottools[disk](location,radius,color=clr):
else
plts :=plottools[icosahedron](location,radius,color=clr)
fi:
if nargs >= 5 then
plts := plts,PT(location+args[5],args[4] )
elif nargs >= 4 then
plts := plts,PT(location+[seq(0,i=1..nops(location)-1),1.25*radius],args[4] ) fi:
plots[display]([plts]);
end:
>
WQStools[ARRW]:=proc(A,B)
local TMP1,TMP2,joe,AA,sally,len,shaftthickness,hdwdth,hdlngth,
colr,dh,mul,hl,hw:
len := linalg[norm]((B-A),2):
colr := black: dh := SH:
if nargs >= 3 then colr := args[3] fi;
if nargs >= 4 then dh := args[4] fi;
if nargs >= 5 then mul := args[5] else mul := .01 fi;
if nargs >= 6 then hl := args[6] else hl := 5 fi;
if nargs >= 7 then hw := args[7] else hw := .1 fi;
shaftthickness:=mul*len: hdwdth:= hl*shaftthickness:
hdlngth:= hw:
AA:=args[1]: if AA=[0,0,0] then AA:=[0,0,.000001]fi:
if nops(A)=2 and nops(B) =2 and dh = `SH` then
plottools[arrow](A,B,shaftthickness,hdwdth,hdlngth,color=colr):
elif nops(A)=2 and nops(B) =2 and dh = `DH` then
TMP1:=
plottools[arrow](A+(2/3.)*(B-A),B,shaftthickness,
hdwdth,hdlngth,color=colr):
TMP2:= plottools[arrow](A+(1/3.)*(B-A),A,shaftthickness,
hdwdth,hdlngth,color=colr):
plots[display]({TMP1,TMP2}):
elif nops(A)=3 and nops(B) =3 and dh = `SH` then
plottools[arrow](AA,B,shaftthickness,hdwdth,
hdlngth,color=colr):
elif nops(AA)=3 and nops(B) =3 and dh = `DH` then
joe:=
expand(AA+((2/3.)*(B-AA))):
TMP1:= plottools[arrow](joe,B,shaftthickness,
hdwdth,hdlngth,color=colr):
sally:=expand(AA+((1/3.)*(B-AA))):
TMP2:= plottools[arrow](sally,AA,shaftthickness,
hdwdth,hdlngth,color=colr):
plots[display]({TMP1,TMP2}):
fi:
end:
>
WQStools[DV]:=proc(A,B)
local name,len,tang,nor,mid,clr,plts;
clr := black:
if nargs >= 4 then clr := args[4] fi:
plts := WQStools[ARRW](A,B,clr):
if nargs >= 3 then name := args[3];
if nops(A) = 3 then len:= evalf(sqrt((B[3]-A[3])^2+(B[2]-A[2])^2+(B[1]-A[1])^2))
else len:= evalf(sqrt((B[2]-A[2])^2+(B[1]-A[1])^2));
fi;
tang := (B-A)/len:
if nops(A)=2 then
nor := [-tang[2],tang[1]] else
nor := [-tang[2],tang[1],0] fi;
mid := (A+3*B)/4 + .07*len*nor;
plts := plts,WQStools[PT](mid,name) fi;
plots[display]([plts],scaling=constrained)
end:
WQStools[GP3]:=proc()
local llhc, width, height,depth, xres,yres,zres,clrs,
xlabl,ylabl, zlabl,TMfont,V, H, K, i,j,levs,verts;
llhc := [0,0,0]:width:=10:height:=10:
depth := 10: xres:=width/3:yres:=height/3: zres := depth/3:
clrs :=[black,red,blue]:xlabl:=`x`: ylabl:=`y`:zlabl := `z`: TMfont:=NTM:
if nargs >=1 then llhc:=args[1] fi;
if nargs >=2 then width:=args[2] fi;
if nargs >=3 then height:= args[3] fi;
if nargs >=4 then depth:= args[4] fi;
if nargs >=5 then xres:= args[5] fi;
if nargs >=6 then yres:= args[6] fi;
if nargs >=7 then zres:= args[7] fi;
if nargs >=8 then clrs:= args[8] fi;
if nargs >=9 then xlabl:= args[9] fi;
if nargs >=10 then ylabl:= args[10] fi;
if nargs >=11 then TMfont:= args[11] fi;
levs := NULL:
for j from 0 to depth/zres do
levs := levs, seq(
[[llhc[1] + i*xres, llhc[2],llhc[3]+j*zres], [llhc[1] + i*xres, llhc[2] + height,llhc[3]+j*zres]],
i = 0 .. width/xres) :
>
od:
V := plots[polygonplot3d]({levs},style=wireframe,color = clrs[1]);
levs := NULL:
for j from 0 to depth/zres do
levs := levs, seq(
[[llhc[1], llhc[2] + i*yres ,llhc[3]+j*zres], [llhc[1] + width, llhc[2] + i*yres,llhc[3]+j*zres]],
i = 0 .. height/yres) :
>
od:
H := plots[polygonplot3d]({levs},style=wireframe,color = clrs[2]);
verts := NULL:
for i from 0 to width/xres do for j from 0 to height/yres do
verts := verts,[[llhc[1]+i*xres,llhc[2]+j*yres,llhc[3]],
[llhc[1]+i*xres,llhc[2]+j*yres,llhc[3]+depth]]:
K := plots[polygonplot3d]({verts},style=wireframe,color = clrs[3]) od od;
if TMfont = NTM then plots[display]([V, H,K], tickmarks = map(round,[width/xres, height/yres, depth/zres]),axes=normal)
elif TMfont = 0 then plots[display]([V, H,K],axes = none)
else plots[display]([V, H,K],labels=[xlabl,ylabl,zlabl],
tickmarks = [width/xres, height/yres, depth/zres] ,
axesfont = [TIMES, BOLD, TMfont],
labelfont=[TIMES,BOLD,TMfont],axes=normal)
fi
end:
WQStools[MM] := proc(partslist,tinter,numframes)
local i,step,speed,opt ;
speed := 1:
step := (tinter[2]-tinter[1])/(numframes-1):
if nargs >= 3 then speed := args[3] fi:
if nargs >= 4 then
plots[display]([seq(plots[display](
partslist(tinter[1]+floor(i/speed)*step)),i=0..speed*(numframes-1))],insequence=true,scaling=constrained)
else
plots[display]([seq(plots[display](
partslist(tinter[1]+floor(i/speed)*step)),i=0..speed*(numframes-1))],insequence=true) fi:
end:
> with(WQStools);
Warning, the name ARRW has been redefined
> colors();
> hlpWQStools();
graph paper: GP(llcorner, width, height, resolution,TMfont)
graph paper 2: GP2(optional llhc, width, height, xres,yres,clrs,xlabl,ylabl, TMfont)
graph paper 3: GP3(optional llhc, width, height, depth,xres,yres,zres,clrs,xlabl,ylabl,zlabl, TMfont)
plot point: PP(location,optional radius,clr,name)
draw line: DL(A,B, optional thknss, styl,clr)
put text: PT(location,txt, optional fntsize,clr)
draw arrow: ARRW(A,B, optional colr,DH or SH, mul ,hdwidth,hdlngth)
draw vector: DV(A,B,optional name, clr)
make movie: MM(partslist,time_interval,numframes)
where partslist is a list of functions of time, each
of which returns a plot structure.
> plots[display]([GP3(),ARRW([1,2,10],[8,6,2],magenta,DH)]);
> plots[display](ARR([2,3,3],[4,3,4]));
>
> DV( [1,2,10] , [8,6,2] );
> plots[display]([PP([6,3,4],.15,green,"jim",[0,.5,.2]), WQStools[GP3]([5,2,3],9,6,4,9,3,2)]);;
>
plots[display]([DL([-2,1],[0,-2],3,2,blue),PP([3,2],.05,red),PP([3.5,4],.05,blue),
drawvect([3,2],[3.5,4])]);
> printlevel:=1;
> WQStools[hlpWQStools]();
>
>
A1:=ARRW([0,0],[1,1],magenta,`DH`,.05,3,.1):
plots[display](A1,scaling=constrained);