From the March, 1988 issue
This program prints fancy patterns to the screen or to the EPSON HI-80 plotter. The patterns are based on CYCLOIDS, or the movements of a point on a spoke of a wheel turning within another wheel. An unlimited number of different patterns can be drawn by changing one or more parameters of the procedure PATTERN. A few examples are:
16 525 420 410 -20 7 13 600 400 370 -30 0 1 750 510 255 -30 25 1 540 280 240 0 0 1 505 95 90 10 -10
Values 2, 3 and 4 should be selected in such a way that the pattern fits into the window. If values 2 and 3 have mostly common factors, one cycle of the procedure CYCLOID ends quickly (600 and 400 in example 2), if less common factors are used, it takes a lot longer (505 and 95 in the last example).
Lines 760 to 1010 are not required if this program will only be used for screen plotting.
Two more procedures are included in the program, although they have no relation with pattern drawing. These procedures are LONG–PLOT and PLOT–FILE.
LONG–PLOT shows how to plot strips longer than the maximum paper size for the EPSON plotter. The trick is to plot the maximum page size first, then initialise the plotter with the IN command, set the defaults, move to where the first plot stopped and continue from there. I use fan-fold paper to plot long graphs in this manner. The procedure gives an example, showing an extended grid.
PLOT–FILE shows how plotter output can be redirected to a file on disk, and plotted by copying the file to SER. In this procedure LONG–PLOT is used as a program that sends its output to the file SCREEN–PLT. The file can be plotted as many times as required, without running the program.
100 CHOISE:DRAW
110 REMark ************
120 DEFine PROCedure CHOISE
130 CLS:AT 10,20:PRINT '0) OUTPUT TO PLOTTER'
140 PRINT TO 20,'1)OUTPUT TO SCREEN'
150 PRINT:INPUT TO 20,'PRESS 0 OR 1';V
160 IF V
170 WINDOW 512,202,0,0:CLS
180 SCALE 1000,-800,-500
190 ELSE
200 C=3:OPEN#C,SER
210 CLS:AT 10,20:PRINT 'PLOTTING..'
220 MA 1255,960:OR1
230 END IF
240 END DEFine CHOISE
250 REMark ***********
260 DEFine PROCedure DRAW
270 REPeat LOOP
280 CLS:AT 10,20
290 PRINT 'INPUT OF PARAMETERS "0" TO END':PRINT
300 INPUT TO 20,'NUMBER OF CALLS TO ‹CYCLOID› : ';LEVEL
310 IF LEVEL=0:EXIT LOOP:CLOSE#C:END IF
320 INPUT TO 20,'RADIUS OF FIXED CIRCLE : ';R1
330 INPUT TO 20,'RADIUS OF MOVING CIRCLE : ';R2
340 INPUT TO 20,'PEN RELATIVE TO MOVING CIRCLE : ';R3
350 INPUT TO 20,'RATE OF CHANGE IN R3 : ';R3–I
360 INPUT TO 20,'STEP IN ANGLE OF FIXED CIRCLE : ';A–I
370 PATTERN LEVEL,R1,R2,R3,R3–I,A–I,A1–I
380 END REPeat LOOP
390 IF NOT FLAG:CH:END IF
400 END DEFine DRAW
410 REMark ************
420 DEFine PROCedure PATTERN(LEVEL,R1,R2,R3,R3–I,A–I)
430 CLS:A=0:A1–I=PI/36:A2–I=R1*A1–I/R2
440 CR=R1-R2:A–I=RAD(A–I)
450 FOR I=1 TO LEVEL
460 CYCLOID A:A=A+A–I:R3=R3+R3–I
470 END FOR I
480 END DEFine PATTERN
490 REMark ***********
500 DEFine PROCedure CYCLOID(A)
510 A1=A:A2=0
520 IF V
530 LINE (CR+R3)*COS(A1),(CR+R3)*SIN(A1)
540 ELSE
550 MA INT(1.92*(CR+R3)*COS(A1)+.5),INT(1.-92*(CR+R3)*SIN(A1)+ .5)
560 END IF
570 REPeat LOOP
580 A1=(A1+A1–I)
590 A1=A1*(A1‹2*PI)+(A1-2*PI)*(A1›=2*PI)
600 CX=CR*COS(A1):CY=CR*SIN(A1)
610 A2=A2+A2–I
620 IF A2›A1:A2=A2-2*PI:END IF
630 A3=(A1-A2)
640 A3=A3*(A3‹2*PI)+(A3-2*PI)*(A3›=2*PI)
650 X–I=R3*COS(A3):Y–I=R3*SIN(A3)
660 IF V
670 LINE TO CX+X–I,CY+Y–I
680 ELSE
690 DA INT(1.92*(CX+X–I)+.5),INT(1.92*(CY+-Y–I)+.5)
700 END IF
710 AA=INT(1000*A)
720 IF INT(1000*A1)=AA AND INT(1000*A3)=AA:EXIT LOOP:END IF
730 END REPeat LOOP
740 END DEFine CYCLOID
750 REMark **********
760 DEFine PROCedure LONG–PLOT
770 REMark C=3:OPEN#C,SER2
780 GR 251,10,600,3
790 MA 2510,0:INI:DF:MA 54,0:OR1
800 GR 251,9,600,3
810 REMark CLOSE#C
820 END DEFine LONG–PLOT
830 REMark ***********************
840 DEFine PROCedure PLOT–FILE
850 C=3
860 OPEN–NEW#C,FLP1–SCREEN–PLT
870 REMark *** PROGRAM WITH PLOTTER COMMANDS ***
880 LONG–PLOT
890 CLOSE#C
900 REMark TO PLOT THE FILE USE :COPY FLP1–SCREEN–PLT TO SER2
910 END DEFine PLOT–FILE
920 REMark ********************
930 DEFine PROCedure MA(X,Y): PRINT#C,'MA ';X;',';Y:END DEFine
940 DEFine PROCedure GR(XU,XN, YU,YN)
950 PRINT #C,'GR ';XU;',';XN;',';YU;',';YN
960 END DEFine GR
970 DEFine PROCedure INI: PRINT#C,'IN':END DEFine
980 DEFine PROCedure DF:PRINT#C, 'DF':END DEFine
990 DEFine PROCedure OR1:PRINT#C,'OR':END DEFine
1000 DEFine PROCedure DA(X,Y): PRINT#C,'DA ';X;',';Y:END DEFine
1010 DEFine PROCedure CH:PRINT #C,'CH':END DEFine
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.