home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / elan / intgraph / peano.eln < prev    next >
Text File  |  1988-10-11  |  2KB  |  108 lines

  1.  
  2. PROC approximation north (INT CONST n):
  3.      IF n <> 0
  4.      THEN
  5.        approximation east  (n-1);
  6.        line segment east;
  7.        approximation north (n-1);
  8.        line segment north;
  9.        approximation north (n-1);
  10.        line segment west;
  11.        approximation west  (n-1)
  12.       FI
  13. ENDPROC approximation north;
  14.  
  15. PROC approximation east (INT CONST n):
  16.      IF n <> 0
  17.      THEN
  18.        approximation north (n-1);
  19.        line segment north;
  20.        approximation east  (n-1);
  21.        line segment east;
  22.        approximation east  (n-1);
  23.        line segment south;
  24.        approximation south (n-1)
  25.      FI
  26. ENDPROC approximation east;
  27.  
  28. PROC approximation south (INT CONST n):
  29.      IF n <> 0
  30.      THEN
  31.        approximation west  (n-1);
  32.        line segment west;
  33.        approximation south (n-1);
  34.        line segment south;
  35.        approximation south (n-1);
  36.        line segment east;
  37.        approximation east  (n-1)
  38.      FI
  39. ENDPROC approximation south;
  40.  
  41. PROC approximation west (INT CONST n):
  42.      IF n <> 0
  43.      THEN
  44.        approximation south  (n-1);
  45.        line segment south;
  46.        approximation west   (n-1);
  47.        line segment west;
  48.        approximation west   (n-1);
  49.        line segment north;
  50.        approximation north  (n-1)
  51.      FI
  52. ENDPROC approximation west;
  53.  
  54. PROC line segment north:
  55.    draw (x, y + d)
  56. ENDPROC line segment north;
  57.  
  58. PROC line segment south:
  59.    draw (x, y - d)
  60. ENDPROC line segment south;
  61.  
  62. PROC line segment east:
  63.    draw (x + d, y)
  64. ENDPROC line segment east;
  65.  
  66. PROC line segment west:
  67.    draw (x - d, y)
  68. ENDPROC line segment west;
  69.  
  70. PROC draw (REAL CONST xp, yp):
  71.    draw (round (scale * xp * aspect),
  72.          graphics y limit - round (scale * yp));
  73.    x := xp;
  74.    y := yp
  75. ENDPROC draw;
  76.  
  77. PROC move (REAL CONST xp, yp):
  78.    move (round (scale * xp * aspect),
  79.          graphics y limit - round (scale * yp));
  80.    x := xp;
  81.    y := yp
  82. ENDPROC move;
  83.  
  84. program:
  85.    ask order;
  86.    draw curve;
  87.    end program.
  88.  
  89. ask order:
  90.    enter graphics mode;
  91.    INT VAR n :: ask int ("Peano curve of order? ").
  92.  
  93. draw curve:
  94.    REAL VAR x, y;
  95.    REAL CONST
  96.           d :: 1.0 / 2.0 ** n,
  97.           scale :: real (min (graphics x limit,
  98.                          graphics y limit - line height));
  99.    move (d / 2.0, d / 2.0);
  100.    approximation east (n).
  101.  
  102.  
  103. end program:
  104.    wait for confirmation (graphics x limit DIV 2, 1);
  105.    leave graphics mode.
  106.  
  107. 
  108.