Draws regular polygons, and star polygons, in high resolution on the TS2068. It asks for the centre’s coordinates (x and y), the radius, the number of sides, the orientation in degrees and the number of “hops”: 1 hop draws an ordinary polygon, 2 or more join every second (third…) corner, so 5 sides with 2 hops draws a five-pointed star. A centre and radius that would run off the screen are refused and the program asks again.
This is the article’s “Final Polygon Algorithm”. The article builds it up step by step, from a first version that works out six sines and cosines for every side to this one, which draws each side as a fixed-length vector turned by a fixed angle and has only one PLOT, before the loop. Try the article’s examples: centre 80 and 80, radius 60, 8 sides, orientation 22.5, 1 hop; and centre 80 and 80, radius 60, 5 sides, orientation 18, 2 hops.
Published in the BCS Sinclair-Timex User Group Newsletter March 1984 (Polygons).
Source Code
10 INPUT "CENTER'S COORDINATES"'X,Y
20 INPUT "RADIUS"'R
25 IF X-R<0 OR X+R>255 OR Y-R<0 OR Y+R>175 THEN GOTO 10
30 INPUT "NUMBER OF SIDES"'N
40 INPUT "ORIENTATION"'P
45 LET P=P*PI/180
49 INPUT "HOPS"'H
50 LET V=2*PI*H/N
60 LET S=2*R*SIN(V/2)
70 LET T=P+PI/2+V/2
80 PLOT X+R*COS P, Y+R*SIN P
100 FOR I=1 TO N
130 DRAW S*COS T, S*SIN T
135 LET T=T+V
150 NEXT INote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


