home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GA / GA028.ZIP / HOP.PAS < prev    next >
Pascal/Delphi Source File  |  1986-08-27  |  1KB  |  52 lines

  1. (* Barry Martin's function *)
  2.  
  3. (* Version 1.1 August 27 1986 *)
  4.  
  5. VAR
  6.     a, b, c : real;     { coefficients }
  7.     x0, y0 : real;      { internal coordinates }
  8.                         { converted to plot coordinates x, y below }
  9.  
  10. CONST boredom = 5000;   { how often to change colors }
  11.  
  12.  
  13. Procedure Set_Defaults;
  14. BEGIN
  15.     a := -3.14;
  16.     b := 0.3;
  17.     c := 0.3;
  18.     xmin := -13.0;    { centered viewing window }
  19.     xmax := 7.0;
  20.     ymin := -7.0;
  21.     ymax := 9.0;
  22. END;
  23.  
  24. Procedure Initialize;
  25. BEGIN
  26.     x := 0; x0 := 0;
  27.     y := 0; y0 := 0;
  28. END;
  29.  
  30. Procedure Set_Coefficients;
  31. BEGIN
  32.     Writeln;
  33.     Writeln('Enter Coefficients---');
  34.     Write('A (',a:10:4,'): '); Readln(a);
  35.     Write('B (',b:10:4,'): '); Readln(b);
  36.     Write('C (',c:10:4,'): '); Readln(c);
  37. END;
  38.  
  39. Procedure Next_Iteration;
  40. VAR x1, y1 : real;
  41. BEGIN
  42.     IF x0 < 0.0 THEN
  43.         x1 := y0 + Sqrt(Abs(b * x0 - c))
  44.     ELSE
  45.         x1 := y0 - Sqrt(Abs(b * x0 - c));
  46.     y1 := a - x0;
  47.     x0 := x1;
  48.     y0 := y1;
  49.     x := (x1 + y1);  { rotate 45 degrees }
  50.     y := (x1 - y1);  { fast & lean-- no trig }
  51. END;
  52.