home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / fractal112 / !Fractal / Help / Quaternion < prev    next >
Text File  |  1996-10-09  |  2KB  |  46 lines

  1. Quaternion : Invented by William Hamilton, 1843
  2. ----------
  3. A Quaternion is a 4d equivalent of a complex number, written as:
  4.      Q = a+bi+cj+dk
  5. where i, j and k are imaginary numbers. They are used here in a similar way
  6. to Julia sets with Q -> Q²+q where q is a quaternion constant, made up of
  7. q0, q1, q2 and q3 in this routine. The routine maps out a 2-dimensional
  8. slice using x=a and y=c, with the values of b and d being set to choose
  9. which slice of the 4d plane we are drawing.
  10.  
  11. The initial values chosen for q0 and q2 are the same as those for the Julia
  12. Set, and you will note the image is superficially very similar. Changing q1,
  13. q3, b or d however allows different planes to be examined, giving a great
  14. area to investigate.
  15.  
  16. As with the Julia set, the best way to choose values for q0 and q2 is from
  17. the Mandelbrot set - use the Quaternion menu option to pick a point from
  18. near the boundary.
  19.  
  20. The menu options operate in the same way as for the Julia set.
  21.  
  22. Algorithm
  23. ---------
  24. A 32 bit and floating point version are provided, but both will be slower
  25. than Julia's due to the extra multiplications.
  26.  
  27. For each pixel we calculate the a (x) & c (y) value and then iterate. The
  28. colour is the iteration number unless Q²>4.0, when we set the colour to 0
  29. (or as set by the Interior menu option).
  30.  
  31.    iter=0;
  32.    repeat
  33.      iter + 1
  34.      if (a²+b²+c²+d²>4) then escape
  35.      new_a=a²-b²-c²-d²+q0
  36.      b=2*a*b+q1
  37.      c=2*a*c+q2
  38.      d=2*a*d+q3
  39.      a=new_a
  40.    until iter>=max_iter
  41.  
  42. Notes: It is possible to use other functions such as Q->Q³+q as done for
  43. Mandelbrot's. Also it is possible to produce a 3d mapping, though a lot of
  44. the swirling detail apparently is lost. Iterating the function Mandelbrot
  45. style gives a variation on the Mandelbrot shape.
  46.