pltpara.red 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. module pltpara; % Computing parametric curve.
  2. % (x,y) = (x(t),y(t))
  3. % or
  4. % (x,y,z) = (x(t),y(t),z(t))
  5. % or
  6. % (x,y,z) = (x(t,u),y(t,u),z(t,u))
  7. % Author: Herbert Melenk, ZIB Berlin.
  8. symbolic procedure plotevalpara1(x);
  9. begin scalar xlo,xhi,ylo,yhi,rx,ry,fcn,fcns,pts;
  10. rx:=plotrange(x,
  11. reval(plot_xrange or '(!*interval!* -10 10)));
  12. xlo:=car rx;
  13. xhi:=cadr rx;
  14. fcns:= reverse plotfunctions!*;
  15. % ry:=plotrange(y, reval(plot_yrange or nil));
  16. if ry then <<ylo:=car ry; yhi:=cadr ry>>;
  17. while fcns do
  18. <<fcn := cddar fcns; fcns := cdr fcns;
  19. pts:=plotevalpara11(fcn,x,xlo,xhi).pts;
  20. >>;
  21. if length fcn=2 then plotdriver(plot!-2exp,'x,'y,list pts,nil)
  22. else plotdriver(plot!-3exp!-reg,'x,'y,'z,list pts) % WN list added
  23. end;
  24. symbolic procedure plotevalpara11(fm,x,xlo,xhi);
  25. begin scalar plotsynerr!*,l,d,d0,u,v,p,fl;
  26. scalar plotderiv!*;
  27. integer nx;
  28. fl:= for each f in fm collect rdwrap f.f;
  29. p:=float (nx:=plot!-points(x));
  30. d:=(d0:=(xhi-xlo))/p;
  31. v:=xlo;
  32. for i:=0:nx do
  33. <<u:= for each f in fl collect plotevalform(car f,cdr f,{x.v});
  34. if plotsynerr!* then typerr(fm,"function to plot");
  35. if smemq('overflow,u) then u:=nil;
  36. l:=u.l;
  37. v:=v+d;
  38. >>;
  39. return reversip l;
  40. end;
  41. symbolic procedure plotevalpara2(x,y);
  42. begin scalar xlo,xhi,ylo,yhi,rx,ry,fcn,fcns,pts;
  43. rx:=plotrange(x,
  44. reval(plot_xrange or '(!*interval!* -10 10)));
  45. xlo:=car rx; xhi:=cadr rx;
  46. fcns:= reverse plotfunctions!*;
  47. ry:=plotrange(y,
  48. reval(plot_yrange or '(!*interval!* -10 10)));
  49. ylo:=car ry; yhi:=cadr ry;
  50. fcn := cddar fcns; fcns := cdr fcns;
  51. if length fcn neq 3 then typerr(cdar fcns,"function to plot");
  52. pts:=plotevalpara21(fcn,x,xlo,xhi,y,ylo,yhi);
  53. plotdriver(plot!-3exp!-reg,'x,'y,'z,list pts) % WN list added
  54. end;
  55. symbolic procedure plotevalpara21(fm,x,xlo,xhi,y,ylo,yhi);
  56. begin scalar plotsynerr!*,l,ll,dx,dy,u,v,p,fl,w;
  57. scalar plotderiv!*;
  58. integer nx,ny;
  59. fl:= for each f in fm collect rdwrap f.f;
  60. p:=float(nx:=plot!-points(x));
  61. dx:=(xhi-xlo)/p;
  62. p:=float(ny:=plot!-points(y));
  63. dy:=(yhi-ylo)/p;
  64. v:=xlo;
  65. for i:=0:nx do
  66. <<w:= ylo; l:=nil;
  67. for j:=0:ny do
  68. <<u:= for each f in fl collect
  69. plotevalform(car f,cdr f,{x.v,y.w});
  70. if plotsynerr!* then typerr(fm,"function to plot");
  71. if smemq('overflow,u) then u:=nil;
  72. l:=u.l;
  73. w:=w+dy
  74. >>;
  75. v:=v+dx;
  76. ll:=l.ll;
  77. >>;
  78. return ll;
  79. end;
  80. endmodule;
  81. end;