16K Cassette or 24K Disk
by Edward Loniewski
Super Sine was originally written to demonstrate the very powerful mathematical concept that any complicated curve can be approximated by some combination of sine and cosine functions. In case you're not overly familiar with sines and cosines, they are a pair of curves that trace out a simple wave shape that repeats itself every 360 degrees. They can be thought of as plotting the horizontal and vertical distances of a point on the circumference of a circle as that point moves completely around the circle. These distances are measured from the x- and y-axes that pass through the center of the circle. These curves have two characteristics, called frequency and amplitude, that can be changed in various ways to distort the basic sine wave. By adding or multiplying several sines and cosines together, an almost endless variety of complicated curves can be drawn.
The program described here is a very simple sine wave generator, yet it can produce incredibly beautiful results. It only deals with two curves at a time and only allows for changing the frequency. However, with very little effort, the program can be expanded further.
The frequencies of the 2 curves plotted here are denoted by the variables K1 and K2, which can be assigned any positive value whatever. The fun comes in experimenting with various pairs of frequencies and watching what happens. In addition, eight different patterns or combinations of sines and cosines can be plotted, as shown in the table below.
PATTERN | COMBINATION |
---|---|
1 | SIN(K1)+SIN(K2) |
2 | COS(K1)+COS(K2) |
3 | SIN(K1)+COS(K2) |
4 | SIN(K1)*COS(K2) |
5 | SIN(K1)-SIN(K2) |
6 | COS(K1)-COS(K2) |
7 | SIN(K1)*SIN(K2) |
8 | COS(K1)*COS(K2) |
Each pattern can be drawn as a mirror image of itself by using negative pattern numbers. In other words, pattern -5 will plot the mirror image of pattern 5. Thus, there are really 16 patterns available.
The final fancy trick is to allow plotting of more than one pattern on the same graph. All sixteen patterns could be drawn if desired, but usually four or less would be sufficient. All patterns drawn on one graph, though, will have the same pair of frequencies.
Two versions of the program are shown here. The second includes a speedy graphic dump to an Epson printer with GRAFTRAX. If you have a dump routine for a different printer, insert it where appropriate.
After entering the program, SAVE it to a cassette or disk and then get ready for some intriguing experimentation.
To get a good feel for how the program works, RUN the following examples:
The following table yields some instructive and entertaining figures. When more than one pattern is given, study how the colors change with each succeeding plot. Sometimes the colors get filled in, sometimes they reverse, and sometimes they get cancelled to white or grey. Some of these combinations will actually wind up with eight colors on the screen at one time.
K1, K2 | PATTERNS |
---|---|
90, 92 | 5, -5 |
2, 179 | 1, -1 |
118, 120 | 3, -3 |
300, 303 | 7, -7 |
44, 45 | 4, -4 |
5, 90 | 2, 6 |
87, 93 | 1, -1, 4, -4 |
1.5, 2.85 | 3, -3, 4, -4 |
10, 120 | 4, -4 |
100, 101 | 4, -4 |
6, 7.161 | 7, -7, -8, 8 |
40, 42.32 | 5, -5, 6, -6 |
If you use the printer version of the program, the character in Line 102 is a [heart] (CTRL,). Change Line 145 to read 210. Add Line 210 and all of Lines 9000-9060.
The rest, now, is up to you. Experiment as much as you like. Try adapting the program to three or more frequencies, or add different patterns, or placing different frequencies on the same graph. If you're like me, you'll run out of time long before you run out of ideas.
By the way, this program can even be used to plot sines and cosines.
100 REM SUPER SINE
101 DIM PCS(450),PAT(16),YN$(1)
105 DEG :GRAPHICS 2:POKE 710,0:POSITIO
N 5,3:PRINT #6;"S U P E R":POSITION 6,
6:PRINT #6;"s i n e"
106 POKE 752,1:PRINT :PRINT "
PLEASE STAND BY"
107 FOR I=0 TO 90:X=SIN(I):PCS(I)=X:PC
S(I+180)=-X:PCS(180-I)=X:PCS(360-I)=-X
:PCS(I+360)=X:NEXT I
110 GRAPHICS 8:POKE 709,14:POKE 710,0:
POKE 712,68
120 COLOR 1:X0=10:YFAC=39:NPAT=0:TRAP
110
130 PLOT 0,80:DRAWTO 319,80:PLOT X0,0:
DRAWTO X0,159:PLOT 0,159:DRAWTO 319,15
9
140 PRINT "K1,K2=";:INPUT K1,K2
145 PRINT "PATTTERN";:INPUT ZT:IF ZT=0
THEN 215
147 ARG1=-K1:ARG2=-K2:NPAT=NPAT+1:PAT(
NPAT)=ZT
148 PT=ABS(ZT):ZFAC=-YFAC*SGN(ZT)
150 FOR X=X0 TO 319
152 ARG1=ARG1+K1:ARG2=ARG2+K2
153 IF ARG1>360 THEN ARG1=ARG1-360:GOT
O 153
154 IF ARG2>360 THEN ARG2=ARG2-360:GOT
O 154
160 IF PT=1 THEN Y=80+ZFAC*(PCS(ARG1)+
PCS(ARG2))
162 IF PT=2 THEN Y=80+ZFAC*(PCS(ARG1+9
0)+PCS(ARG2+90))
164 IF PT=3 THEN Y=80+ZFAC*(PCS(ARG1)+
PCS(ARG2+90))
166 IF PT=4 THEN Y=80+ZFAC*(PCS(ARG1)*
PCS(ARG2+90))
168 IF PT=5 THEN Y=80+ZFAC*(PCS(ARG1)-
PCS(ARG2))
170 IF PT=6 THEN Y=80+ZFAC*(PCS(ARG1+9
0)-PCS(ARG2+90))
172 IF PT=7 THEN Y=80+ZFAC*(PCS(ARG1)*
PCS(ARG2))
174 IF PT=8 THEN Y=80+ZFAC*(PCS(ARG1+9
0)*PCS(ARG2+90))
178 IF X=X0 THEN PLOT X,Y
179 IF X<>X0 THEN DRAWTO X,Y
180 NEXT X
200 SOUND 0,40,10,6:FOR W=1 TO 50:NEXT
W:SOUND 0,0,0,0
205 GOTO 145
215 PRINT "NEW GRAPH (Y/N)";:INPUT YN$
:IF YN$<>"Y" THEN 145
220 GOTO 110
100 DATA 583,934,335,770,181,188,192,8
04,70,261,369,618,680,700,634,7319
154 DATA 643,180,772,472,474,206,791,2
00,792,686,256,782,789,707,574,8324
220 DATA 694,694
100 DATA 75,934,818,335,770,181,188,19
2,804,70,246,369,618,680,700,6980
153 DATA 634,643,180,772,472,474,206,7
91,200,792,686,256,782,789,707,8384
210 DATA 182,574,694,654,606,535,962,7
23,575,936,552,810,155,588,219,8765
9023 DATA 362,587,517,162,595,184,194,
2601