summaryrefslogtreecommitdiff
path: root/ipl/gprocs/rpolys.icn
blob: 4af3195fefda33c844d348d9363247fa05052558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
############################################################################
#
#	File:     rpolys.icn
#
#	Subject:  Procedure to produce traces of regular polygons
#
#	Author:   Ralph E. Griswold
#
#	Date:     March 24, 1999
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
# Generate points for a regular polygon with the specified number of
# vertices and radius, centered at cx and cy.  The offset angle is theta;
# default 0.
#
############################################################################
#
#  Links:  gobject
#
############################################################################

link gobject

procedure rpoly(cx, cy, radius, vertices, theta)	#: generate polygon points
   local incr, i

   incr := 2 * &pi / vertices
   /theta := 0			# starting angle

   every i := 1 to vertices do {
      suspend Point(cx + radius * cos(theta), cy + radius * sin(theta))
      theta +:= incr
      }

end