Joins vertices of regular polygon with n-sides.
Appears on
One of a series of library tapes. Programs on these tapes were renamed to a number series. This tape contained programs 20001 to 20050. These tapes were compiled by Tony Willing.
Gallery
Source Code
10 REM "N-POLYGONS" 20 REM joining vertices of regular polygon with n-sides 30 REM Adapted by F. BOULDIN 40 BORDER 5: PAPER 7: INK 0 100 REM joining vertices of regular N-gon 110 CLS : LET start=9700: LET setorigin=9600: LET moveto=9500: LET lineto=9400 120 LET horiz=3: LET VERT=2.1 130 GO SUB start 140 LET XMOVE=HORIZ*0.5: LET YMOVE=VERT*0.5 150 GO SUB setorigin 160 DIM X(30): DIM Y(30) 169 REM setup vertices of regular N-gon in arrays X and Y 170 INPUT "TYPE VALUE OF N (3-30) ";N 180 LET ALPHA=0: LET ADIF=2*PI/N 190 FOR I=1 TO N 200 LET X(I)=COS ALPHA: LET Y(I)=SIN ALPHA 210 LET ALPHA=ALPHA+ADIF 220 NEXT I 229 REM join point I to point J:1<=I<J<=N 230 FOR I=1 TO N 240 FOR J=I+1 TO N 250 LET XPT=X(I): LET YPT=Y(I): GO SUB moveto 260 LET XPT=X(J): LET YPT=Y(J): GO SUB lineto 270 NEXT J 280 NEXT I 290 PAUSE 360: PRINT AT 21,1;" Press Any Key for New Start" 300 PAUSE 0: CLS : GO TO 1 9400 REM lineto 9401 REM IN:XPT,YPT,XPEN, YPEN 9402 REM OUT:XPEN, YPEN 9410 LET NXPEN=FN X(XPT) 9420 LET NYPEN=FN Y(YPT) 9430 PLOT XPEN,YPEN 9440 DRAW NXPEN-XPEN,NYPEN-YPEN 9450 LET XPEN=NXPEN: LET YPEN=NYPEN 9460 RETURN 9500 REM moveto 9501 REM IN:XPT,YPT 9502 REM OUT:XPEN, YPEN 9510 LET XPEN=FN X(XPT) 9520 LET YPEN=FN Y(YPT) 9530 RETURN 9600 REM setorigin 9601 REM IN:XORIG, YORIG, XMOVE, YMOVE 9602 REM OUT :XORIG, YORIG, XPEN, YPEN 9610 LET XORIG=XORIG+XMOVE: LET YORIG=YORIG+YMOVE 9620 LET XPEN=FN X(0) 9630 LET YPEN=FN Y(0) 9640 RETURN 9650 DEF FN X(Z)=INT ((XORIG+Z)*XYSCALE+0.5) 9660 DEF FN Y(Z)=INT ((YORIG+Z)*XYSCALE+0.5) 9700 REM start 9701 REM IN : HORIZ, VERT 9702 REM OUT : NXPIX, NYPIX, XORIG, YORIG, XYSCALE, XPEN, YPEN, 9710 LET XORIG = 0: LET YORIG = 0 9720 LET XPEN = 0: LET YPEN = 0 9730 LET NXPIX = 256: LET NYPIX = 176 9740 LET XYSCALE = NXPIX/HORIZ: LET YSCALE = NYPIX/VERT 9750 IF XYSCALE > YSCALE THEN LET XYSCALE = YSCALE 9760 RETURN 9999 SAVE "N-POLYGONS" LINE 1