home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sonderh1 / circink.pas < prev    next >
Pascal/Delphi Source File  |  1987-03-13  |  2KB  |  50 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                           CIRCINK.PAS                                   *)
  3. (*         Inkrementeller Kreisalgorithmus fuer die Graphikserie           *)
  4. (*-------------------------------------------------------------------------*)
  5.  
  6. PROCEDURE do_circle (x_center, y_center, radius: INTEGER);
  7.  
  8. CONST Pi = 3.1415926;
  9.  
  10. VAR dtheta,                             (* Winkel-Schrittweite             *)
  11.     cosinus_dtheta,                     (* Cosinus der Winkel-Schrittweite *)
  12.     sinus_dtheta,                       (* Sinus der Winkel-Schrittweite   *)
  13.     x, y,                               (* Berechnete Koordinaten          *)
  14.     x_alt,                              (* x-Wert des vorherigen Punkts    *)
  15.     y_ende           : REAL;            (* y-Wert Endkoord. Achtel-Kreis   *)
  16.  
  17.     xi, yi,                             (* Auf Integer gerundete Koord.    *)
  18.     AspRX,                              (* round(Aspect_Ratio*x)           *)
  19.     AspRY            : INTEGER;         (* round(Aspect_Ratio*y)           *)
  20.  
  21. BEGIN                                                   (* Initialisierung *)
  22.   dtheta := 1.0 / radius;
  23.   cosinus_dtheta := Cos(dtheta);
  24.   sinus_dtheta := Sin(dtheta);
  25.   x := 0;                                   (* Koordianten-Initialisierung *)
  26.   y := radius;
  27.   y_ende := Sin(Pi/4) * radius;
  28.   WHILE y >= y_ende DO
  29.   BEGIN                                      (* Punkte symmetrisch plotten *)
  30.     AspRX := Round(Aspect_Ratio*x);
  31.     AspRY := Round(Aspect_Ratio*y);
  32.     xi := Round(x);
  33.     yi := Round(y);
  34.     Point_System(x_center + xi, y_center + AspRY);
  35.     Point_System(x_center - xi, y_center + AspRY);
  36.     Point_System(x_center + xi, y_center - AspRY);
  37.     Point_System(x_center - xi, y_center - AspRY);
  38.     Point_System(x_center + yi, y_center + AspRX);
  39.     Point_System(x_center - yi, y_center + AspRX);
  40.     Point_System(x_center + yi, y_center - AspRX);
  41.     Point_System(x_center - yi, y_center - AspRX);
  42.     x_alt := x;                           (* Neue x- und y-Werte berechnen *)
  43.     x := (x*cosinus_dtheta - y*sinus_dtheta);
  44.     y := (y*cosinus_dtheta + x_alt*sinus_dtheta);
  45.   END;
  46. END;
  47.  
  48. (*-------------------------------------------------------------------------*)
  49. (*                          Ende von CIRCINK.PAS                           *)
  50.