home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / fractz.zip / READ.ME < prev    next >
Text File  |  1994-01-19  |  16KB  |  280 lines

  1.          
  2.                                    FRACTZ
  3.  
  4.          
  5.  I. Introduction 
  6.          
  7.  FRACTZ is a fractal drawing program for the OS/2 Presentation Manager.  It is 
  8.  the result of a project I undertook solely for the purpose of learning how to 
  9.  program for OS/2.  There are PM programming details within FRACTZ that had me 
  10.  stumped for weeks on end.  The answers are out there, but finding them can be 
  11.  difficult and time consuming.  It is for this reason that I decided to donate 
  12.  it to the public, lock-stock-and-barrel, in the hopes of smoothing the bumps 
  13.  for anyone thinking of taking the same venture.  I also hope that some are 
  14.  inspired by the beauty in fractals.  They are an amazing area where science 
  15.  meets art.  
  16.  
  17.          
  18.  II.  Legal 
  19.          
  20.  The executable file, the C source code, and the assorted ancillary files are 
  21.  free, but I retain the ownership and copyright.  The program is designed to 
  22.  run on any machine running OS/2 2.0 or higher, but it carries no guarantee of 
  23.  any kind.  
  24.          
  25.  
  26.  III.  The Beginning 
  27.          
  28.  I am a fan of OS/2 and I am a programmer, but I'm not professionally into PM 
  29.  programming.  It was something I wanted to learn, so about a year ago I 
  30.  purchased both the IBM and Borland OS/2 compilers.  I also needed a project 
  31.  to start up my learning ramp.  I've always admired the beauty of fractals and 
  32.  have been long time fan of FRACTINT.  For those that don't know, FRACTINT is 
  33.  a free DOS fractal drawing program that has been worked on by numerous 
  34.  people.  Collectively they are known as the Stone Soup Group.  The name 
  35.  springs from an interesting parable, which I'll leave up to you to find and 
  36.  read.  There are now versions of FRACTINT for Windows and even OS/2.  
  37.          
  38.  Another reason for choosing a fractal program was that I already had some DOS 
  39.  C code that I had started on some years ago, but had given up as being too 
  40.  much work.  You will probably see some remnants of this program in FRACTZ, 
  41.  like in the identifier "int".  Lastly, and most importantly from a technical 
  42.  point, I owned and had almost memorized the Waite book "Fractal Creations" by 
  43.  Tim Wegner and Mark Peterson.  These are two Stone Soup Group members and it 
  44.  is the definitive book for doing fractals on a PC.  A second edition of this 
  45.  book is now out.  I haven't seen it, but I understand it is much improved, 
  46.  although I don't see how.  Lastly, I would like to mention Bert Tyler.  He is 
  47.  the guy that shook the bushes that started the stampede.  Some of his 
  48.  personal suggestions are incorporated into FRACTZ.  
  49.          
  50.  The Stone Soup Group hangs out on Compuserve in the GRAPHDEV forum, and I 
  51.  have gone to them on more than several occasions for technical details.  They 
  52.  are always willing to help.  One thing I need to mention is that the ASCII 
  53.  text color maps that are in the FRACTZ package came from FRACTINT.  I am 
  54.  including them with the permission of the Stone Soup Group.  That is 
  55.  something I couldn't do if FRACTZ wasn't free.  
  56.                                          
  57.          
  58.  IV.  The PM program and Some Caveats 
  59.          
  60.  As I wrote this program, I did not envision it going anywhere.  It was 
  61.  strictly a learning effort on my part.  For that reason, it may not work 
  62.  properly on your machine.  I use a 486/33DX which has a Tseng ET4000 running 
  63.  at 800X600 resolution with 256 colors.  The .EXE file has in-line FPU code 
  64.  and I don't know what it will do on a machine without an FPU.  I wouldn't 
  65.  attempt this without an FPU anyway.  A similar statement holds about using 
  66.  it with a different numbers of colors or resolution.  It should work, but I 
  67.  just don't know.  I didn't write it to run on different machines and have 
  68.  never seen it attempted.  
  69.          
  70.  Unfortunately, the fractal calculations are incredibly slow.  This is 
  71.  something which I attribute to a number of reasons.  The first is that I used 
  72.  type "complex" to ease the coding burden.  (FRACTINT, on the other hand, 
  73.  makes use of type long int.)  Type "complex" is one of the reasons it is a 
  74.  C++ program, although it is not OOP.  I looked at some compiled code and was 
  75.  horrified, but that is another subject.  Secondly, to reach a color depth of 
  76.  255, you may need to iterate up to 256 times at each pixel.  Thus, it may be 
  77.  necessary to evaluate a complex expression some 800X600X256 times in the 
  78.  worst case.  Take that number and multiply by the horrendous machine code and 
  79.  you will understand the problem.  
  80.          
  81.  One nice thing about OS/2 of course, is that you can just move the fractal 
  82.  window out of the way and go on about other things.  However, I need to bring 
  83.  up a word of caution here.  If you change the aspect ratio of the window, the 
  84.  fractal will tear.  I know it is possible to bit-blast from one sized 
  85.  rectangle to another, but in this case, you will actually change the equation 
  86.  of the fractal while it is in the process of being computed.  That's why it's 
  87.  a no-no.  There may be a way of doing this without tearing the fractal, but I 
  88.  think it would involve calculating out-of-window points and I don't think 
  89.  that would be a good idea.  
  90.          
  91.          
  92.  V. Technical 
  93.          
  94.  I can only give a sampling on fractals, as you really need a book.  All of 
  95.  the fractals in FRACTZ are what is known as "escape-time" fractals with one 
  96.  or two also possessing "finite-attracters".  One of the most famous is the 
  97.  Mandelbrot.  It's entire description is contained in this one "simple" 
  98.  equation:  
  99.          
  100.      z = z*z + c
  101.          
  102.  This is an iterative equation with both z and c being complex numbers of the 
  103.  form (x+iy), i.e.  they correspond to points on the screen (or window) of 
  104.  your CRT.  The point, c, is the independent variable which comes from 
  105.  scanning horizontally in x then vertically in y. The first z point, z0, is 
  106.  taken to be the origin, or (0,0).  Thus, given a c (a particular pixel), one 
  107.  simply computes z1, z2, z3....  until one of two things happen.  1) You 
  108.  escape outside a circle of radius = 2 (hence the "escape-time" name) or 2) 
  109.  you never escape and are cut-off by some other criteria for maximum number of 
  110.  iterations.  This is called MAXITER and it is usually taken as some number 
  111.  say of at least 100.  The default in FRACTZ is the color depth, 255.  Thus, 
  112.  the color of a pixel (or more accurately the index into the RGB color table) 
  113.  is simply the number of iterations it takes to escape.  If it hits MAXITER 
  114.  without escaping, it is a color of your choosing.  
  115.          
  116.  The Mandelbrot equation never converges, but some escape-time equations do.  
  117.  Such equations actually have a finite number of roots that will be found with 
  118.  the above iteration scheme.  These are the finite-attracters, and there are 
  119.  a few of these in FRACTZ.  This fractal type simply adds one more cutoff 
  120.  criterion of "have I converged on a root?".  
  121.          
  122.  I'm sure one can see from the above expression why I chose type complex, but 
  123.  the simplicity totally belies what's hidden within.  Clearly, it is also easy 
  124.  to add additional fractal formulas, being largely a matter of adding a 
  125.  one-line case to a switch statement.  
  126.          
  127.  
  128.  VI.  Operation 
  129.          
  130.  I don't have an installation procedure.  I would recommend installing FRACTZ 
  131.  in its own directory and using a program template to create a desktop object.  
  132.  FRACTZ will look for the color maps (*.MAP files) in its own directory.  Not 
  133.  finding any will cause it to generate a random map, and that map is not very 
  134.  pretty.  Also, remember you will be unzipping .C, .RC, etc.  so there are a
  135.  good number of files.  There are even some bitmap files I created with 
  136.  FRACTZ.  I use one for my shutdown screen.  The program comes up running.  
  137.  In fact, you can't stop it.  The (background) fractal engine thread runs 
  138.  full-speed all the time and is drawing to a memory PS.  There is another 
  139.  small thread that wakes up from a DosSleep every few seconds and blasts the 
  140.  bits from a memory PS to the VDT.  Hence it appears to jump every time this 
  141.  thread wakes up.  
  142.          
  143.  There is no real help once you are up and running.  I only hope the menus and 
  144.  dialogs are obvious enough.  Having previous experience with FRACTINT would 
  145.  be a big help here.  
  146.          
  147.  First, the mouse operations:  
  148.          
  149.     1. LMB (left mouse button) diagonal drag creates a "zoom box".  This will
  150.     be the new window when you release the button.  A tiny box will act as a
  151.     cancel.
  152.          
  153.     2. LMB double-click clears the window to black and restarts the
  154.     calculation.
  155.          
  156.     3. RMB click will start a Julia fractal with initial conditions based on
  157.     the (x,y) location of the mouse pointer.  Again, pick an interesting (e.g.
  158.     ragged) area to click.
  159.          
  160.  There are not very many fractal types to choose from in the menu, but I think 
  161.  you will be surprised at how much you can do with these.  Notice that you can 
  162.  save-to/restore-from a BMP (bitmap file) at any time.  Look at some of the 
  163.  ones that I supplied.  This will not destroy any preceding calculations as 
  164.  they are being written to a memory PS.  These bitmaps are the 2.x variety and 
  165.  you can look at any 2.x bitmap.  I did not bother supporting 1.x bitmap, 
  166.  although it shouldn't be hard to add.  Note that you cannot restart a 
  167.  calculation from a BMP file, although it is something I have considered 
  168.  adding.  For now, you can only "un-view" it to get back to where you were.  
  169.          
  170.  The next menu item is the display option.  By all means check out the 
  171.  "orbits" option, but turn out the lights first.  I was really surprised by 
  172.  how well this turned out.  Books rarely mention this feature because the 
  173.  "neatness" is all in the dynamics.  Also, it is hard to do without multiple 
  174.  presentation spaces, so thanks IBM.  Take a look before you zoom in or you 
  175.  may not see much.  That is not because the "fractoids" aren't there, but 
  176.  probably because they are orbiting over your neighbor's house or even over 
  177.  another city.  These orbits come straight from the fractal engine and this 
  178.  option will slow it down a lot, but it's worth it.  
  179.          
  180.  The "change colors" option comes from my somewhat feeble attempt to imitate 
  181.  FRACTINT's color cycling option.  FRACTINT grabs the hardware video registers 
  182.  to create a dazzling color show.  That is something I couldn't do, but I left 
  183.  this option in anyway.  Basically, it runs small color wavelets up and down 
  184.  the RGB table to produce somewhat smooth and somewhat random time-color 
  185.  variations.  
  186.          
  187.  The Settings option produces the only dialog box in FRACTZ.  This is a hard 
  188.  option to get across in a README, so I hope probing around will be more 
  189.  fruitful than what I can say here.  The Box Coordinates define the scale of 
  190.  the fractal and are XL, XR, YB, YT for x-left, x-right, y-bottom, y-top.  
  191.  Normally, you don't enter these.  They start at some default and change as 
  192.  you zoom in.  
  193.          
  194.  The perturbations, called Real Pert.(dX) and Imag. Pert.(dY) in the
  195.  dialog box, are a way of throwing a twist into the fractal calculations.  
  196.  Again, I would suggest the book (or the C source) to see what they really do.  
  197.  It is not necessary to mess with them except in the case of the Lambda 
  198.  fractal.  For that, start with some- thing close to what is in the "hint 
  199.  box".  
  200.          
  201.  The "Maxiter" that is in the dialog box is the iteration cutoff and has 
  202.  already been discussed.  It defaults to the (my) color depth of 255.  
  203.  Changing it to something like 150 will speed things up, but reduce the number 
  204.  of colors.  The Bailout term is the radius of the bailout circle where 
  205.  calculations are stopped.  That is, the fractoid has "escaped" if abs(z) > 
  206.  bailout.  Please note - the FRACTINT authors (and the book) use "bailout" to 
  207.  mean the square of the radius so that they can avoid a square root operation.  
  208.  I.E.  FRACTINT tests if (x**2 + y**2 > bailout).  Thus you will see their 
  209.  value of bailout is 4 where I use 2. 
  210.          
  211.  The dialog item "Inside" is what sets the RGB color if the iteration hits 
  212.  Maxiter before escaping.  The term "inside" comes from the lake-like feature 
  213.  in the center of the Mandelbrot fractal.  Any iteration that starts within 
  214.  the lake will not escape.  "Inside" means inside the lake and the default 
  215.  value is 1 which is blue.  However, if you switch to 3-D mode, I would 
  216.  suggest making the value 255.  This will switch the lake to a mountain 
  217.  plateau.  
  218.          
  219.  There is a check box called "use potential".  I think this is a method based 
  220.  on some formula from potential theory, but whatever the case, the purpose is 
  221.  to smooth out a fractal image for making 3-D renderings.  The idea is that 
  222.  instead of using the count value when a fractoid escapes, you use the 
  223.  logarithm of the radius after it escapes.  Sorry, I never did get this to 
  224.  work properly.  
  225.          
  226.  The next two regions of the dialog box are for doing spherical projections 
  227.  and 3-D surfaces.  You can also do 3-D spheres.  The purpose of the 
  228.  "covers-180" versus "covers-360" determines how much of the spherical fractal 
  229.  you want to see.  180 degrees will show all, but will show as a hemisphere if 
  230.  you also select 3-D.  
  231.           
  232.  The box labeled "Ceiling Ht."  is what scales the height of the fractal in 
  233.  3-D.  FRACTZ uses color as the height, so some number larger than 255 is 
  234.  required in order to see the full picture.  I have used values greater than 
  235.  2,000 in order to "flatten" the mountains.  
  236.          
  237.  Lastly come the rotation angles.  Alpha, beta, and phi are the rotation 
  238.  angles about x,y, and z using the right-hand rule (this z is perpendicular to 
  239.  the x-y plane.  It is not the complex z).  However, before doing the 
  240.  rotation, I flipped the fractal to view it edge on.  In other words, for 
  241.  rotation angles of (0,0,0), you would see the fractal with the x-axis 
  242.  horizontal and increasing to the right, the z-axis (color) would be vertical 
  243.  and increasing upward, and the y-axis would be normal to the screen and 
  244.  increasing in the direction you are viewing.  By doing this, I get best 
  245.  results by keeping all angles somewhat small, about (+/-) 15-20 degrees or 
  246.  so.  This is somehow more palatable to me than using rotation angles like 75 
  247.  degrees.  
  248.          
  249.  If you switch into 3-D, you need to start with a completely clear, black 
  250.  window.  Double click the left mouse button to do this as it does not happen 
  251.  automatically.  It used to, but I shot myself in the foot too many times.  
  252.  The reason it needs black is that the 3-D option uses a ray tracing technique 
  253.  to not have background objects write over foreground objects.  When the 
  254.  program encounters a 3-D black pixel, it means "I haven't been here yet", 
  255.  which is something it needs to know in order to work properly.  By the way, I 
  256.  think the Julia fractals have the most interesting 3-D shapes.  I should also 
  257.  mention here that a phi-rotation is a rotation about the polar axis in 
  258.  spherical coordinates.  
  259.          
  260.  The last menu item is choice of color map.  Unlike what FRACTINT does, I 
  261.  elected to hard code the file names right into the code.  Yes, I know, this 
  262.  is not a good programming practice, but it is particularly effective.  
  263.  These are small files, and because we all have a good diskcache, you get 
  264.  almost immediate response with one click.  These maps are a work of art in 
  265.  themselves and my hat is off to the Stone Soup Group again.  They can bring 
  266.  out surprising details you just can't see any other way.  Always try some of 
  267.  the color maps if you feel like you are getting bored.  
  268.          
  269.  Well, enough has been said.  I hope it is understandable and that someone can 
  270.  make use of this.  If you have any questions, I will be glad to answer what I 
  271.  can.  I am usually around OS2DF1 on Compuserve.  
  272.          
  273.  
  274.  Tom Stokes
  275.  
  276.  1/19/94
  277.          
  278.  CIS id 73770,3577 
  279.          
  280.