home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / ps / psfractl.ps / psfractal.ps
Encoding:
Internet Message Format  |  1989-03-12  |  4.1 KB

  1. From router!tut!draken!kth!mcvax!uunet!tut.cis.ohio-state.edu!mailrus!purdue!haven!umd5!cgs Sun Mar 12 11:43:34 EET 1989
  2. Article 30 of gnu.ghostscript.bug:
  3. Path: chyde!router!tut!draken!kth!mcvax!uunet!tut.cis.ohio-state.edu!mailrus!purdue!haven!umd5!cgs
  4. >From: cgs@umd5.umd.edu (Chris G. Sylvain)
  5. Newsgroups: gnu.ghostscript.bug
  6. Subject: Sample File (not short)
  7. Keywords: pyramid,'fractal'
  8. Message-ID: <4601@umd5.umd.edu>
  9. Date: 11 Mar 89 19:17:25 GMT
  10. Organization: University of Maryland, College Park
  11. Lines: 133
  12. [...]
  13.    ----- Unsent message follows -----
  14. [...]
  15. %!
  16. % Pyramidal Fractal in PostScript
  17. %
  18. % Draws a 3-D pyramid fractal, as
  19. % seen in a popular text on Fractals
  20. %
  21. % Author: Curt.McDowell@andrew.cmu.edu
  22. % Carnegie-Mellon University
  23. %
  24. 72 72 scale
  25. % User-Adjustable Parameters:
  26. %
  27. % Adjust viewing angle by modifying alpha and beta.
  28. % The pyramid is originally seen level with the front edge.
  29. % It is then rotated around the Z axis by alpha
  30. % (front corner moving left), then around the Y (horizonal)
  31. % axis by beta (top corner moving away).
  32. /alpha          -11   def       /beta           -10   def
  33. /shadeleft      0.95  def       /shaderight     0.5   def
  34. /pagew          8.5   def       /pageh          11    def
  35. /StartSize      1.6   def       /MinSize        0.2   def
  36. 0 -1 translate
  37. /sina alpha sin def             /sinb beta sin def
  38. /cosa alpha cos def             /cosb beta cos def
  39. % Transformation from 3-D coordinates to 2-D
  40. /xform  % x,y,z ==> x',y'
  41. {       /zz exch def
  42.         /yy exch def
  43.         /xx exch def
  44.         yy cosa mul xx sina mul sub
  45.         pagew 2 div mul         % Compute X and
  46.         pagew 2 div add         % leave on stack
  47.         xx sinb mul cosa mul yy sina mul sinb mul
  48.         add zz cosb mul add
  49.         pageh 2 div mul         % Compute Y and
  50.         pageh 2 div add         % leave on stack
  51. } def
  52. % Constants
  53. /sqr3o4   3 sqrt    4 div       def
  54. /sqr3o2   3 sqrt    2 div       def
  55. /sqr3o6   3 sqrt    6 div       def
  56. /sqr6o3   6 sqrt    3 div       def
  57. /sqr3o12  3 sqrt    12 div      def
  58. /sqr6o6   6 sqrt    6 div       def
  59. /pyramid    % x,y,z,size ==> --
  60. {       /size exch def /z exch def /y exch def /x exch def
  61.         % (ax, ay) = Left bottom point
  62.         x y z
  63.         xform /ay exch def /ax exch def
  64.         % (bx, by) = bottom front point
  65.         sqr3o2 size mul x add   size 2 div y add   z
  66.         xform /by exch def /bx exch def
  67.         % (cx, cy) = Right bottom point
  68.         x   size y add   z
  69.         xform /cy exch def /cx exch def
  70.         % (dx, dy) = top point
  71.         sqr3o6 size mul x add   size 2 div y add   sqr6o3 size mul z add
  72.         xform /dy exch def /dx exch def
  73.         % Fill the 2 visible faces with different shades
  74.         ax ay moveto    bx by lineto    dx dy lineto    closepath
  75.         shadeleft       setgray         fill
  76.         cx cy moveto    bx by lineto    dx dy lineto    closepath
  77.         shaderight      setgray         fill
  78.         % Draw the 5 visible segments
  79.         0 setgray 0.1 72 div setlinewidth
  80.         ax ay moveto    bx by lineto    cx cy lineto    dx dy lineto
  81.         closepath       dx dy moveto    bx by lineto    stroke
  82. } def
  83. % Recursive routine to build a pyramid out of subpyramids
  84. /buildsave { x y z size } def
  85. /buildrest { /size exch def /z exch def /y exch def /x exch def } def
  86. /build  % x,y,z,size ==> --
  87. {       /size exch def /z exch def /y exch def /x exch def
  88.         size MinSize lt
  89.         {       buildsave
  90.                 x   y   z   size   pyramid
  91.                 buildrest
  92.         }
  93.         {       buildsave
  94.                 x   y   z   size 2 div   build
  95.                 buildrest
  96.                 buildsave
  97.                 x   size 2 div y add   z   size 2 div   build
  98.                 buildrest
  99.                 buildsave
  100.                 sqr3o12 size mul x add   size 4 div y add
  101.                 sqr6o6 size mul z add   size 2 div   build
  102.                 buildrest
  103.                 sqr3o4 size mul x add   size 4 div y add
  104.                 z   size 2 div   build
  105.         } ifelse
  106. } def
  107. 0   StartSize -2 div   StartSize sqr6o6 mul -2 div   StartSize   build
  108. showpage
  109. -- 
  110. --==---==---==--
  111. .. And hast thou slain the Jabberwock? ..
  112.    ARPA: cgs@umd5.UMD.EDU     BITNET: cgs%umd5@umd2
  113.    UUCP: ..!uunet!umd5.umd.edu!cgs
  114.