home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / Biomorph 0.77 / README < prev   
Encoding:
Text File  |  1994-05-06  |  4.1 KB  |  106 lines  |  [TEXT/ALFA]

  1. Biomorph 0.77 was the latest in a long stream of fractal-generating
  2. programs.  It was never finished but nonetheless has some neat features:
  3. namely, the ability to accept plug-in codes for other functions.  The
  4. Add Resource/Delete Resource menu options were never implemented, so
  5. adding codes is done through ResEdit or other means.
  6.  
  7. I hereby give away all aspects of this code for any use whatsoever.
  8. In return, the recipient agrees to accept the code as-is, with no
  9. warranty of any kind.  This code was done by a Mac hacker with more
  10. experience in UNIX & X than Mac.
  11.  
  12. 5/94 Brent Burton
  13. brentb@math.tamu.edu
  14. --------------------------
  15.  
  16. Introduction
  17. ------------
  18.  
  19.     Welcome to the world of "biomorphs."  Biomorphs are a graphical represen-
  20.  tation of an iterated function of two complex variables.  They do not differ
  21.  much (in theory) from other common fractals, such as the Mandelbrot set, but
  22.  the algorithm used to define them is a little different.
  23.  
  24.     Biomorphs have been investigated by A.K. Dewdney in his "Computer
  25.  Recreations" column in _Scientific_American_.  His specific article dealing
  26.  with biomorphs appeared in a late 1989 or early 1990 issue.  Also, there is a
  27.  book entitled, _The_Blind_Watchmaker_ that investigates evolutionary develop-
  28.  ment of biomorphs through an included program.  ( I'm sorry for the vagueness
  29.  above;  I don't remember the issue date and since I never have seen the pro-
  30.  gram, I don't know who wrote it.)
  31.  
  32.     Biomorphs get their name because of the interesting images generated that
  33.  have an eery similarity to natural simple creatures.  Protozoa, amoebas and
  34.  other similar creatures with their cillia and other physical structures are
  35.  easily obtainable with the biomorph algorithm and "adequately complex" gener-
  36.  ating functions.
  37.  
  38.  
  39. Generation  (Basic ideas)
  40. ----------
  41.  
  42.     Images of Mandelbrot sets are fairly easy to generate by the following
  43.  algorithm:
  44.  
  45.  define a maximum number of iterations (250, say);
  46.  for (each point in the image region to draw) do:
  47.  {
  48.     z0 = (0,0);
  49.     C  = (real_value, imag_value);  /* of the current location in region */
  50.  
  51.     while (TRUE)
  52.     {
  53.         z = z0^2 + C;
  54.         if (magnitude(z) > 2.0) or (number of iterations > maximum iterations)
  55.         then 
  56.          {  plot_point (real_value, imag_value, color based on # iterations);
  57.             exit the while loop;
  58.           }
  59.         z0 = z;        (old value of z is now the last z calculated)
  60.     }
  61.  }
  62.  
  63.  The basic idea above is used in the generation of biomorphs.  However, the
  64.  conditions are a little different; they are more specific.
  65.  In the original algorithm presented by A.K.Dewdney, the maximum iteration
  66.  number was 10 and the magnitude squared of the complex variable had a limit
  67.  of 100.  The algorithm is:
  68.  
  69.  for (each point in the image region) do
  70.  {
  71.     z0 = make_complex( real_value, imag_value);    (of the current point)
  72.     z = z0;       /* saves one iteration by directly assigning it. */
  73.     z.mag=0;      /* initial value */
  74.  
  75.     num_iterations = 1;
  76.     while ( num_iterations <=10  AND
  77.             real_part(z) <= 10.0 AND
  78.             imag_part(z) <= 10.0 AND
  79.             magnitude(z) <= 100 )       /* magnitude is really squared here. */
  80.     {
  81.       z = f(z0, C);                     /* some function of old z value and C */
  82.       z.mag = z.r*z.r + z.i*z.i;        /* sqrt is not taken for speed. */
  83.       num_iterations++;
  84.     }
  85.  
  86.     if ( |z.r| <10.0  OR  |z.i| < 10.0 ) then
  87.       paint the current pixel black;       /* biomorphs are generally B/W */
  88.  }
  89.  
  90.  
  91.    The generating function f(z0, C) is the most important aspect in
  92.  generating biomorphs.  (As distributed, my program uses the function:
  93.  
  94.      z = z0^3 - z0 + C;
  95.  
  96.  [The best idea for changing the function would be to allow the user to
  97.  type in the function to use and then parsing that function.  However,
  98.  this is very complex (I didn't know about yacc and lex when I wrote
  99.  this) and recompilation was much easier for a different function.]
  100.  
  101.  You can achieve drastically different images by tweaking the above algorithm's
  102.  conditions, like increasing the iterations and in-/de-creasing the magnitude
  103.  and boundaries.
  104.  
  105.  
  106.