home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / gprogs / julia1.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  80 lines

  1. ############################################################################
  2. #
  3. #    File:     julia1.icn
  4. #
  5. #    Subject:  Program to display the Julia set
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 17, 1994
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This is a barebones version of a display of the Julia set.  It
  18. #  has deliberately been left simple and free of options so that the
  19. #  basic idea is clear and so that it can be used as the basis of
  20. #  more capable versions.
  21. #
  22. #  This program is based on material given in "Chaos, Fractals,
  23. #  and Dynamics", Robert L. Devaney, Addison-Wesley, 1990.
  24. #
  25. #  The point in the complex plane for which the Julia set is computed
  26. #  is given on the command line, as in
  27. #
  28. #    julia1 .360284 .100376
  29. #
  30. #  which displays the Julia set for the complex number .360284 + .100376i.
  31. #
  32. ############################################################################
  33. #
  34. #  Requires:  Version 9 graphics
  35. #
  36. ############################################################################
  37. #
  38. #  Links:  wopen
  39. #
  40. ############################################################################
  41.  
  42. link wopen
  43.  
  44. procedure main(argl)
  45.    local c1, c2, extent, half, quarter, m, n, x0, y0, x, y
  46.    local x1, y1, i, z
  47.  
  48.    c1 := real(argl[1]) | -1.0        # default is -1.0 + 0.0i
  49.    c2 := real(argl[2]) | 0.0
  50.  
  51.    extent := 200
  52.    half := 200 / 2
  53.    quarter := real(extent) / 4
  54.  
  55.    WOpen("label=julia", "height=" || extent, "width=" || extent) |
  56.       stop("*** cannot open window")
  57.  
  58.    every m := 0 to extent do {
  59.       x0 := -2 + m / quarter
  60.       every n := 0 to half do {
  61.          y0 := 2 - n / quarter
  62.          x := x0
  63.          y := y0
  64.          every i := 1 to 20 do {    # compute orbit
  65.             x1 := x ^ 2 - y ^ 2 + c1
  66.             y1 := 2 * x * y + c2
  67.             x := x1
  68.             y := y1
  69.             z := x ^ 2 + y ^ 2
  70.             if z > 4 then break next    # if escaping, forget it
  71.             }
  72.          DrawPoint(m, n)
  73.          DrawPoint(extent - m, extent - n)
  74.          }
  75.       }
  76.  
  77.    Event()
  78.  
  79. end
  80.