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 / rpolys.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  41 lines

  1. ############################################################################
  2. #
  3. #    File:     rpolys.icn
  4. #
  5. #    Subject:  Procedure to produce traces of regular polygons
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     March 24, 1999
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. # Generate points for a regular polygon with the specified number of
  18. # vertices and radius, centered at cx and cy.  The offset angle is theta;
  19. # default 0.
  20. #
  21. ############################################################################
  22. #
  23. #  Links:  gobject
  24. #
  25. ############################################################################
  26.  
  27. link gobject
  28.  
  29. procedure rpoly(cx, cy, radius, vertices, theta)    #: generate polygon points
  30.    local incr, i
  31.  
  32.    incr := 2 * &pi / vertices
  33.    /theta := 0            # starting angle
  34.  
  35.    every i := 1 to vertices do {
  36.       suspend Point(cx + radius * cos(theta), cy + radius * sin(theta))
  37.       theta +:= incr
  38.       }
  39.  
  40. end
  41.