home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1989 / 05 / praxis / plotdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-02-09  |  1.7 KB  |  65 lines

  1. (* ------------------------------------------------------ *)
  2. (*                    PLOTDEMO.PAS                        *)
  3. (*     Demonstrationsprogramm für die Plotter-Units       *)
  4. (* ------------------------------------------------------ *)
  5. program DEMO;
  6.  
  7. uses
  8.   HPGL, PLGRAPH;
  9.  
  10. var
  11.   f, x, y, x1, y1        : Vektor;
  12.   xmin, xmax, ymin, ymax : real;
  13.   n                      : word;
  14.  
  15. function f1(x : real) : real;
  16. begin
  17.   f1:=  sin(2 * x) + 2 * cos(x);
  18. end;
  19.  
  20. function f2(x : real) : real;
  21. begin
  22.   f2 := 2 * cos(2 * x) - 2 * sin(x);
  23. end;
  24.  
  25. procedure Beispiel1;
  26. var i : byte; a, b, dx : real;
  27. begin
  28.   n := 50; a := -2*PI; b := 2*PI;
  29.   dx:=(b-a)/(n-1);                     (* Werte berechnen *)
  30.   for i := 1 to n do begin
  31.     x[i] := a + ( i - 1) * dx;         (* Funktion f1(x)  *)
  32.     y[i] := f1(x[i]);
  33.     x1[i] := x[i];                     (* Ableitung f2(x) *)
  34.     y1[i] := f2(x[i]);
  35.   end;
  36.  
  37.   OpenGraphik('PRN');   (* oder z.B.: 'C:Test.Dat' *)
  38.  
  39.   GraphikWindow(20, round(uAXmAX / 2 - 20 ),
  40.                 20, round(vAXMAX / 2 - 20));
  41.  
  42.   Extrema(x, n, xmin, xmax);
  43.   Extrema(y, n, ymin, ymax);
  44.  
  45.   Uscale(xmin, xmax, ymin, ymax, true, true, 5);
  46.  
  47.   XAxis(xmin, xmax, 'x', P_DefaultFont, P_FontSize);
  48.   YAxis(ymin, ymax, 'f(x)', P_DefaultFont, P_FontSize);
  49.  
  50.   XGrid(0);   Ygrid(0);  XGrid(1);   YGrid (1);
  51.  
  52.   Curve(x, y, n, P_NormalLn, P_NormStep, Yellow);
  53.   Curvex(x, y, n, red);
  54.  
  55.   Curve(x1, y1, n, P_CenterLn, P_NormStep, LightRed);
  56.   (* Curvex(x1, y1, n, red); *)
  57. end;
  58.  
  59. begin
  60.   Beispiel1;
  61. end.
  62. (* ------------------------------------------------------ *)
  63. (*                 Ende von PLOTDEMO.PAS                  *)
  64.  
  65.