1 COMMON A, AL, B, BASEONLY, C, C$, C1, CAT$, CC, CKT$, D, D$, DD, DIA, DIMN$, DMS, E, EO, EX$, F, F$, FD, FF, FQ, FRQ, G$, GO$, I, I$, L, LATLONG, LD, LL, LN, LS, LW, LX, MAX, MENU, MIN, MX, N, NN, NT, OV, P, PI, PROG$, Q, QQ, QU, R, RA, RC, T, T$, U, U$, UH, UL$, V$, VC, W, WHIP, WIRD, WW, X, X$, X1, XS, Z$, ZP, ZS
5 'OMMON EX$,PROG$
10 'TRIG - Trigonometric Functions - 25 APR 01 rev.07 JUN 2002
20 CLS:KEY OFF
30 IF EX$=""THEN EX$="EXIT"
40 IF PROG$=""THEN GO$=EX$ ELSE GO$=PROG$
50 
60 COLOR 7,0,1
70 DEFDBL A-Z
80 PI=4*ATN(1)  '3.141593
90 UL$=STRING$(80,205)
100 '
110 '.....title page
120 CLS
130 COLOR 15,2
140 PRINT " TRIGONOMETRIC FUNCTIONS";TAB(57);"by George Murphy VE3ERP ";
150 COLOR 1,0:PRINT STRING$(80,223);
160 COLOR 7,0,1
170 '
180 '.....start
190 L=0:DGR=0:Y=0:Z=0
200 PRINT " Press letter in < > to enter any known value:"
210 PRINT UL$;
220 PRINT "   <a> Angle, in degrees/minutes/seconds"
230 PRINT "   <b> Angle, in decimal degrees"
240 PRINT "   <c> Angle, in radians"
250 PRINT "   <d> Sine"
260 PRINT "   <e> Cosine"
270 PRINT "   <f> Tangent"
280 PRINT "   <g> Cotangent"
290 PRINT "   <h> Secant"
300 PRINT "   <i> Cosecant"
310 PRINT
320 PRINT "   -or-"
330 PRINT
340 PRINT "   <y> to run Solution of Triangles program"
350 PRINT
360 PRINT "   <z> to EXIT program"
370 Z$=INKEY$:IF Z$=""THEN 370
380 L=ATN(Z/SQR(-Z^2+1))
390 IF Z$="y"THEN CLS:CHAIN "\hamcalc\prog\solutri"
400 IF Z$="z"THEN CLS:CHAIN GO$
410 IF Z$="a"THEN 580
420 IF Z$="b"THEN 740
430 IF Z$="c"THEN 870
440 IF Z$="d"THEN 1000
450 IF Z$="e"THEN 1090
460 IF Z$="f"THEN 1180
470 IF Z$="g"THEN 1260
480 IF Z$="h"THEN 1340
490 IF Z$="i"THEN 1430
500 GOTO 370
510 '
520 '.....clear screen
530 COLOR 7,0,0:CLS
540 PRINT TAB(28);"TRIGONOMETRIC FUNCTIONS"
550 PRINT UL$;
560 RETURN
570 '
580 '.....DMS
590 GOSUB 520
600 INPUT " ENTER: Angle, number of whole degrees";Z:Z=INT(Z)
610 IF Z>=360 THEN Z=Z-360:GOTO 610
620 INPUT " ENTER: ...... number of whole minutes";MIN:MIN=INT(MIN)
630 INPUT " ENTER: ...... number of seconds";SEC
640 Y=(Z+MIN/60+SEC/3600)
650 IF Y>0 AND Y<90 THEN DGR=Y
660 IF Y>90 AND Y<180 THEN DGR=180-Y
670 IF Y>180 AND Y<270 THEN DGR=Y-180
680 IF Y>270 AND Y<360 THEN DGR=360-Y
690 L=DGR*PI/180
700 IF Y=0 OR Y=180 THEN L=0
710 IF Y=90 OR Y=270 THEN L=PI/2
720 GOTO 1520
730 '
740 '.....decimal degrees
750 GOSUB 520
760 INPUT " ENTER: Angle, in degrees";Y
770 IF Y>=360 THEN Y=Y-360:GOTO 770
780 IF Y>0 AND Y<90 THEN DGR=Y
790 IF Y>90 AND Y<180 THEN DGR=180-Y
800 IF Y>180 AND Y<270 THEN DGR=Y-180
810 IF Y>270 AND Y<360 THEN DGR=360-Y
820 L=DGR*PI/180
830 IF Y=0 OR Y=180 THEN L=0
840 IF Y=90 OR Y=270 THEN L=PI/2
850 GOTO 1520
860 '
870 '.....radians
880 GOSUB 520
890 INPUT " ENTER: Angle, radians";Y
900 IF Y>PI*2 THEN Y=Y-PI*2:GOTO 900
910 IF Y>0 AND Y<PI/2 THEN Z=Y
920 IF Y>PI/2 AND Y<PI THEN Z=PI-Y
930 IF Y>PI AND Y<1.500000*PI THEN Z=Y-PI
940 IF Y>1.500000*PI AND Y<2*PI THEN Z=2*PI-Y
950 L=Z
960 IF Y=0 OR Y=PI THEN L=0
970 IF Y=PI/2 OR Y=1.500000*PI THEN L=PI/2
980 GOTO 1520
990 '
1000 '.....sine
1010 GOSUB 520
1020 INPUT " ENTER: Value of Sine (range 0-1)";Z
1030 IF Z<0 OR Z>1 THEN BEEP:GOTO 1020
1040 L=ATN(Z/SQR(-Z^2+1))
1050 IF Z=0 THEN L=0
1060 IF Z=1 THEN L=PI/2
1070 GOTO 1520
1080 '
1090 '.....cosine
1100 GOSUB 520
1110 INPUT " ENTER: Value of Cosine (range 0-1)";Z
1120 IF Z<0 OR Z>1 THEN BEEP:GOTO 1110
1130 L=PI/2-ATN(Z/SQR(-Z^2+1))
1140 IF Z=0 THEN L=PI/2
1150 IF Z=1 THEN L=0
1160 GOTO 1520
1170 '
1180 '.....tangent
1190 GOSUB 520
1200 INPUT " ENTER: Value of Tangent (range 0-ì)";Z
1210 IF Z<0 THEN BEEP:GOTO 1200
1220 L=ATN(Z)
1230 IF Z=0 THEN L=0
1240 GOTO 1520
1250 '
1260 '.....cotangent
1270 GOSUB 520
1280 INPUT " ENTER: Value of Cotangent (range 0-ì)";Z
1290 IF Z<0 THEN BEEP:GOTO 1280
1300 L=ATN(1/Z)
1310 IF Z=0 THEN L=PI/2
1320 GOTO 1520
1330 '
1340 '.....secant
1350 GOSUB 520
1360 INPUT " ENTER: Value of Secant (range 1-ì)";Z
1370 IF Z<1 THEN BEEP:GOTO 1360
1380 Z=1/Z
1390 L=PI/2-ATN(Z/SQR(-Z^2+1))
1400 IF Z=1 THEN L=0
1410 GOTO 1520
1420 '
1430 '.....cosecant
1440 GOSUB 520
1450 INPUT " ENTER: Value of Cosecant (range 1-ì)";Z
1460 IF Z<1 THEN BEEP:GOTO 1450
1470 Z=1/Z
1480 L=ATN(Z/SQR(-Z^2+1))
1490 IF Z=1 THEN L=PI/2
1500 GOTO 1520
1510 '
1520 '.....display
1530 GOSUB 520
1540 DEGREE=ABS(L*180/PI)
1550 RADIAN=ABS(L)
1560 SINE=ABS(SIN(L))
1570 COSINE=ABS(COS(L))
1580 TANGENT=ABS(TAN(L))
1590  IF L=0 THEN 1610
1600 COTANGENT=ABS(1/TAN(L))
1610 SECANT=ABS(1/COS(L))
1620  IF L=0 THEN 1650
1630 COSECANT=ABS(1/SIN(L))
1640 '
1650 PRINT " ANGLES:"
1660 PRINT "        Deg/Min/Sec.......= ";
1670  IF L=0 OR L=PI THEN K=0:GOSUB 1750:K=180:GOSUB 1750:GOTO 1730
1680  IF L=PI/2 OR Y=1.500000*PI THEN K=90:GOSUB 1750:K=270:GOSUB 1750:GOTO 1730
1690 K=DEGREE:GOSUB 1750
1700 K=180-DEGREE:GOSUB 1750
1710 K=180+DEGREE:GOSUB 1750
1720 K=360-DEGREE:GOSUB 1750
1730 PRINT "";:GOTO 1870
1740 '
1750 D=K:D1=INT(D):D2=(D-D1)*60
1760 D3=(D2-INT(D2))*60
1770 D2=INT(D2):D3=INT(D3+5.000000E-01)
1780 IF D3=60 THEN D2=D2+1:D3=O
1790 IF D2=60 THEN D1=D1+1:D2=O
1800 D2$=STR$(D2):D2$=RIGHT$(D2$,LEN(D2$)-1)+"'"
1810 IF LEN(D2$)<3 THEN D2$="0"+D2$:GOTO 1810
1820 D3$=STR$(D3):D3$=RIGHT$(D3$,LEN(D3$)-1)+CHR$(34)
1830 IF LEN(D3$)<3 THEN D3$="0"+D3$:GOTO 1830
1840 PRINT USING " ####ø";D1;:PRINT D2$;D3$;
1850 RETURN
1860 '
1870 PRINT "        Decimal degrees...= ";
1880  IF L=0 OR L=P1 THEN K=0:GOSUB 1950:K=180:GOSUB 1950:GOTO 1940
1890  IF L=PI/2 OR Y=1.500000*PI THEN K=90:GOSUB 1950:K=270:GOSUB 1950:GOTO 1940
1900 K=DEGREE:GOSUB 1950
1910 K=180-DEGREE:GOSUB 1950
1920 K=180+DEGREE:GOSUB 1950
1930 K=360-DEGREE:GOSUB 1950
1940 PRINT "";:GOTO 1980
1950 PRINT USING " ####.######";K;
1960 RETURN
1970 '
1980 PRINT "        Radians...........= ";
1990  IF L=0 OR L=PI THEN K=0:GOSUB 1950:K=PI:GOSUB 1950:GOTO 2060
2000  IF L=PI/2 OR Y=1.500000*PI THEN K=PI/2:GOSUB 1950:K=1.500000*PI:GOSUB 1950:GOTO 2060
2010 IF RADIAN>PI/2 THEN RADIAN=RADIAN-PI/2:GOTO 2010
2020 K=RADIAN:GOSUB 1950
2030 K=PI-RADIAN:GOSUB 1950
2040 K=PI+RADIAN:GOSUB 1950
2050 K=2*PI-RADIAN:GOSUB 1950
2060 PRINT "";:GOTO 2100
2070 '
2080 FOR K=PI/2 TO 3*PI/2 STEP PI/2
2090 PRINT USING " ####.######";RADIAN+K;:NEXT K:PRINT ""
2100 PRINT UL$;
2110 '
2120 PRINT " FUNCTIONS of all the above angles:"
2130 PRINT USING "        Sine..........Sin = #####.######";SINE
2140 PRINT USING "        Cosine........Cos = #####.######";COSINE
2150 IF SINE=1 THEN PRINT "        Tangent........Tan=     ì";:GOTO 2170
2160 PRINT USING "        Tangent.......Tan = #####.######";TANGENT
2170 IF SINE=0 THEN PRINT "        Cotangent......Cot=     ì";:GOTO 2190
2180 PRINT USING "        Cotangent.....Cot = #####.######";COTANGENT
2190 IF SINE=1 THEN PRINT "        Secant.........Sec=     ì";:GOTO 2210
2200 PRINT USING "        Secant........Sec = #####.######";SECANT
2210 IF SINE=0 THEN PRINT "        Cosecant.......Csc=     ì";:GOTO 2230
2220 PRINT USING "        Cosecant......Csc = #####.######";COSECANT
2230 PRINT UL$;
2240 GOTO 2260
2250 '
2260 '.....end
2270 GOSUB 2290:GOTO 110
2280 '
2290 '.....PRT
2300 KEY OFF:GOSUB 2370:LOCATE 25,5:COLOR 0,2
2310 PRINT " Send this page to:(1)Printer Queue? (2)Printout? ";
2320 PRINT "(3)Next page? (1/2/3)";:COLOR 7,0
2330 Z$=INKEY$:IF Z$<"1"OR Z$>"3"THEN 2330 ELSE GOSUB 2370
2340 IF Z$="3"THEN RETURN
2350 FOR I%=1 TO 24:FOR J%=1 TO 80:LPRINT CHR$(SCREEN(I%,J%));:NEXT J%:NEXT I%
2360 IF Z$="2"THEN LPRINT CHR$(12) ELSE 2300
2370 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
