# Draw Flows Package Version 1.0
with(plots):
x_sel := a -> evalb(lhs(a)=x(t)):
y_sel := a -> evalb(lhs(a)=y(t)):
flow_rect2 := proc(sys,point,side,eps)
local i,j,sys_ic,old_point,new_point,
proc_ic,res,new_gr,old_gr;
for i from 0 to 1 do
for j from 0 to 1 do
old_point[i,j] := evalm(point+side*[0,j]+side*[i,0]);
od;
od;
for i from 0 to 1 do
for j from 0 to 1 do
sys_ic[i,j] :=
sys union{x(0)=old_point[i,j][1],y(0)=old_point[i,j][2]};
proc_ic[i,j] := dsolve(sys_ic[i,j],{x(t),y(t)},numeric);
res[i,j] := proc_ic[i,j](eps);
new_point[i,j] := [rhs(op(select(x_sel,res[i,j]))),rhs(op(select(y_sel,res[i,j])))]
od;
od;
old_gr :=polygonplot([old_point[0,0],old_point[0,1],old_point[1,1],old_point[1,0]],color=green);
new_gr :=polygonplot([new_point[0,0],new_point[0,1],new_point[1,1],new_point[1,0]],color=red);
{new_gr,old_gr};
end:
flow_pict2 := proc(sys,point,side,eps)
display(flow_rect2(sys,point,side,eps),scaling=constrained)
end:
help_draw_flows := proc();
printf(`\n\t\t\t\tDraw Flows Package Version 1.0\n`);
printf(`\nThis set of functions aids in transforming two dimensional\n`);
printf(`rectangles by the flows of vector fields on R^2.\n`);
printf(`\n`);
printf(`A basic example is:\n`);
printf(`\n`);
printf(`\t\tsys := {D(x)(t)= y(t) + sin(x(t),D(y)(t)= -x(t)+y(t)};\n`);
printf(`\t\tflow_rect2(sys,[.1,.1], .05, .03);\n`);
printf(`\n`);
printf(`to flow the corners of a square of side .05 with lower left\n`);
printf(`corner at [.1,.1] by time .03 using the vector field corresponding to sys.\n`);
printf(`The corners are then filled in to form a quadrilateral.\n`);printf(`\n`);
printf(`The result is then displayed.\n`);
printf(`\n`);
end:
help_draw_flows();