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 / gprocs / orbits.icn < prev    next >
Text File  |  2001-05-02  |  2KB  |  83 lines

  1. ############################################################################
  2. #
  3. #    File:     orbits.icn
  4. #
  5. #    Subject:  Procedures to produce traces of orbits
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     May 2, 2001
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  These procedures produce traces of orbits.  See
  18. #
  19. #    Geometric and Artistic Graphics; Design Generation with
  20. #    Microcomputers, Jean-Paul Delahaye, Macmillan, 1987, pp. 65-73.
  21. #
  22. #  The arguments specify the starting positions, the extent of the
  23. #  drawing, the number of segments, and various parameters that
  24. #  control the orbit.
  25. #
  26. ############################################################################
  27. #
  28. #  Links:  gobject
  29. #
  30. ############################################################################
  31.  
  32. link gobject
  33.  
  34. procedure orbit1(x, y, extent, n, t1, t2, k1, k2, radius1, sscale,
  35.    xfact, yfact)
  36.    local incr1, incr2, real_n, angle1, angle2, i, radius2, loff
  37.  
  38.    radius1 *:= extent            #scaling
  39.    loff := 0.5 * extent
  40.    sscale *:= extent
  41.  
  42.    real_n := real(n)
  43.    incr1 := 2 * &pi * t1 / n
  44.    incr2 := 2 * &pi * t2 / n
  45.    angle1 := angle2 := 0
  46.  
  47.    every i := 1 to n do {
  48.       radius2 := sscale * (1 - i / real_n)
  49.       angle1 +:= incr1
  50.       angle2 +:= incr2
  51.       suspend Point(x + xfact * (loff + radius1 * cos(k1 * angle1) +
  52.          radius2 * cos(angle2)),
  53.          y + yfact * (loff + radius1 * sin(k2 * angle1) +
  54.          radius2 * sin(angle2)))
  55.       }
  56.  
  57. end
  58.  
  59. procedure orbit2(x, y, extent, n, t1, t2, k1, k2, radius1, sscale,
  60.    xfact, yfact, roff, rfact, rratio, div)
  61.    local incr1, incr2, rangle, angle1, angle2, i, radius2, loff
  62.  
  63.    rangle := 2 * &pi / div * rratio
  64.    radius1 *:= extent            #scaling
  65.    loff  := 0.5 * extent
  66.    sscale *:= extent
  67.  
  68.    incr1 := 2 * &pi * t1 / n
  69.    incr2 := 2 * &pi * t2 / n
  70.    angle1 := angle2 := 0
  71.  
  72.    every i := 1 to n do {
  73.       radius2 := sscale * (roff + rfact * cos(i * rangle))
  74.       angle1 +:= incr1
  75.       angle2 +:= incr2
  76.       suspend Point(x + xfact * (loff + radius1 * cos(k1 * angle1) +
  77.          radius2 * cos(angle2)),
  78.          y + yfact * (loff + radius1 * sin(k2 * angle1) +
  79.          radius2 * sin(angle2)))
  80.       }
  81.  
  82. end
  83.