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$,GO$
10 'SOLUTRI - Solution of Triangles - 24 DEC 93 rev.07 JUN 200
20 IF EX$=""THEN EX$="EXIT"
30 IF PROG$=""THEN GO$=EX$ ELSE GO$=PROG$
40 
50 CLS:KEY OFF:SCREEN 0
60 COLOR 7,0,5
70 ON ERROR GOTO 190
80 UL$=STRING$(80,205)
90 '
100 '.....start
110 CLS
120 A=0:B=0:C=0:D=0:E=0:F=0:G=0:H=0:I=0:J=0:K=0:T1=0:T2=0
130 COLOR 15,1
140 PRINT " SOLUTION OF TRIANGLES";TAB(57);"by George Murphy VE3ERP ";
150 COLOR 5,0:PRINT STRING$(80,223);
160 COLOR 7,0
170 GOTO 310
180 '
190 IF ERR=5 OR ERR=11 THEN 210
200 BEEP:LOCATE 20:PRINT "Error";ERR;;"in line";ERL:END
210 COLOR 14,0
220 BEEP:LOCATE 20:PRINT " THE COMBINATION OF FACTORS ENTERED IS EITHER ";
230 PRINT "IMPOSSIBLE OR UNSOLVABLE.";:GOTO 260
240 COLOR 14,0:BEEP:LOCATE 20:PRINT " ANGLE MUST BE LESS THAN 90ø ";:GOTO 260
250 COLOR 14,0:BEEP:LOCATE 20:PRINT " ANGLE MUST BE LESS THAN 180 ø";:GOTO 260
260 PRINT:COLOR 7,0
270 PRINT " Press any key to start over...."
280 IF INKEY$=""THEN 280
290 GOTO 10
300 '
310 '.....start
320 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
330 PI=3.141592
340 U$="####.###"
350 V$="####.##"
360 GOTO 430
370 '
380 '.....inverse sin and cos
390 ASN=ATN(X/SQR(-X*X+1))         'arc sin
400 ACS=-ASN+PI/2                  'arc cos
410 RETURN
420 '
430 '.....draw diagram
440 T=9
450 COLOR 7,0
460 PRINT TAB(T);;"     |\                                     /^\"
470 PRINT TAB(T);;"     |  \                                 / (f) \"
480 PRINT TAB(T);;"     |(a) \                             /         \"
490 PRINT TAB(T);;"     |      \                      <i>/             \<j>"
500 PRINT TAB(T);;"     |        \<e>                  /                 \"
510 PRINT TAB(T);;"     |          \                 /                     \"
520 PRINT TAB(T);;"  <d>|        (b) \             / (h)                 (g) \"
530 PRINT TAB(T);;"     |_ _ _ _ _ _ _ \         /_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\"
540 PRINT TAB(T);;"           <c>                              <k>"
550 COLOR 7,0
560 PRINT
570 PRINT TAB(T);;"  RIGHT-ANGLED TRIANGLE           OBLIQUE-ANGLED TRIANGLE"
580 PRINT TAB(T);;"  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ           ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
590 PRINT TAB(T);;"(a),(b) are the angles          (f),(g),(h) are the angles"
600 PRINT TAB(T);;"<c>,<d>,<e> are the sides       <i>,<j>,<k> are the sides"
610 PRINT UL$;
620 '
630 '.....input data
640 X=97:Y=107
650 '
660 LOCATE 18,20:COLOR 0,7
670 PRINT " Press 1 to RUN program or 0 to EXIT.....";:COLOR 7,0
680 Z$=INKEY$:IF Z$=""THEN 660
690 IF Z$="0"THEN CHAIN GO$
700 IF Z$="1"THEN 730
710 GOTO 660
720 '
730 LOCATE 18,2:COLOR 0,7
740 PRINT " Press one of the above letters to select a known angle or side..."
750 COLOR 7,0
760 Z$=INKEY$:IF Z$=""THEN 760
770 IF ASC(Z$)<X OR ASC(Z$)>Y THEN 760
780 IF ASC(Z$)<=101 THEN Y=101
790 IF Y=101 THEN FOR Z=3 TO 16:LOCATE Z,39:PRINT STRING$(40,32):NEXT Z
800 IF ASC(Z$)>=102 THEN X=102
810 IF X=102 THEN FOR Z=3 TO 16:LOCATE Z,1:PRINT STRING$(33,32):NEXT Z
820 '
830 LOCATE 18:PRINT STRING$(80,32);:LOCATE 18     'clear dialog line
840 Q=ASC(Z$)
850 IF(Q>=97 AND Q<=98)OR(Q>=102 AND Q<=104)THEN I$="Degrees, angle ("+Z$+")"
860 IF(Q>=99 AND Q<=101)OR(Q>=105 AND Q<=107)THEN I$="Length of side <"+Z$+">"
870 PRINT " ENTER: ";I$;
880 '
890 '.....right-angled triangles
900 IF Z$="a"THEN INPUT A:T2=A*PI/180:T1=PI/2-T2:IF A>=90 THEN 240
910 IF Z$="b"THEN INPUT B:T1=B*PI/180:T2=PI/2-T1:IF B>=90 THEN 240
920 IF Z$="c"THEN INPUT C
930 IF Z$="d"THEN INPUT D
940 IF Z$="e"THEN INPUT E
950 '
960 '.....oblique-angled triangles
970 IF Z$="f"THEN INPUT F:F=F*PI/180:IF F>=PI THEN 250
980 IF Z$="g"THEN INPUT G:G=G*PI/180:IF G>=PI THEN 250
990 IF Z$="h"THEN INPUT H:H=H*PI/180:IF H>=PI THEN 250
1000 IF Z$="i"THEN INPUT I
1010 IF Z$="j"THEN INPUT J
1020 IF Z$="k"THEN INPUT K
1030 '
1040 GOSUB 1060:GOTO 730
1050 '
1060 '.....solve right-angled triangle
1070 IF D*C THEN E=SQR(D^2+C^2):T1=ATN(D/C):T2=PI/2-T1:GOTO 1460
1080 IF D*E THEN C=SQR(E^2-D^2):X=D/E:GOSUB 380:T1=ASN:T2=PI/2-T1:GOTO 1460
1090 IF C*E THEN D=SQR(E^2-C^2):X=C/E:GOSUB 380:T1=ACS:T2=PI/2-T1:GOTO 1460
1100 IF C*T1 THEN D=C/TAN(T2):E=C/COS(T1):GOTO 1460
1110 IF D*T1 THEN C=D/TAN(T1):E=D/SIN(T1):GOTO 1460
1120 IF E*T1 THEN D=E*SIN(T1):C=E*COS(T1):GOTO 1460
1130 '
1140 '.....solve oblique angled triangle
1150 IF I*J*K THEN 1400                       '3 sides known
1160 '
1170 IF F=0 THEN IF G*H THEN F=PI-G-H         '3rd angle if two angles known
1180 IF G=0 THEN IF F*H THEN G=PI-F-H
1190 IF H=0 THEN IF F*G THEN H=PI-F-G
1200 '
1210 IF I*F*G*H THEN J=I*SIN(H)/SIN(G):K=I*SIN(F)/SIN(G):GOTO 1460
1220 IF J*F*G*H THEN K=J*SIN(F)/SIN(H):I=J*SIN(G)/SIN(H):GOTO 1460
1230 IF K*F*G*H THEN I=K*SIN(G)/SIN(F):J=K*SIN(H)/SIN(F):GOTO 1460
1240 IF F*G THEN IF F+G>=PI THEN 210
1250 IF G*H THEN IF G+H>=PI THEN 210
1260 IF H*F THEN IF H+F>=PI THEN 210
1270 '
1280 IF F=0 THEN IF J*K*H THEN X=K/J*SIN(H):GOSUB 380:F=ASN:GOTO 1170
1290 IF H=0 THEN IF J*K*F THEN X=J/K*SIN(F):GOSUB 380:H=ASN:GOTO 1170
1300 IF F=0 THEN IF I*K*G THEN X=K/I*SIN(G):GOSUB 380:F=ASN:GOTO 1170
1310 IF G=0 THEN IF I*K*F THEN X=I/K*SIN(F):GOSUB 380:G=ASN:GOTO 1170
1320 IF G=0 THEN IF I*J*H THEN X=I/J*SIN(H):GOSUB 380:G=ASN:GOTO 1170
1330 IF H=0 THEN IF I*J*G THEN X=J/I*SIN(G):GOSUB 380:H=ASN:GOTO 1170
1340 '
1350 IF I=0 THEN IF J*K*G THEN I=SQR(J^2+K^2-(2*J*K*COS(G))):GOTO 1400
1360 IF J=0 THEN IF I*K*H THEN J=SQR(I^2+K^2-(2*I*K*COS(H))):GOTO 1400
1370 IF K=0 THEN IF I*J*F THEN K=SQR(I^2+J^2-(2*I*J*COS(F))):GOTO 1400
1380 GOTO 1460
1390 '
1400 '.....3 sides known
1410 S=(I+J+K)/2
1420 IF F=0 THEN F=2*ATN(SQR((S-J)*(S-I)/(S*(S-K))))
1430 IF G=0 THEN G=2*ATN(SQR((S-J)*(S-K)/(S*(S-I))))
1440 IF H=0 THEN H=2*ATN(SQR((S-K)*(S-I)/(S*(S-J))))
1450 '
1460 COLOR 0,7
1470 '.....screen print
1480 IF T2 THEN COLOR 7,0:LOCATE 5,T+6:PRINT "  ®ÄÄÄ";
1490 IF T2 THEN COLOR 0,7:PRINT USING V$;T2*180/PI;:PRINT "ø"
1500 IF T1 THEN COLOR 7,0:LOCATE 9,T+14:PRINT "  ®ÄÄÄ";
1510 IF T1 THEN COLOR 0,7:PRINT USING V$;T1*180/PI;:PRINT "ø"
1520 IF C THEN LOCATE 11,T+9:PRINT USING U$;C;:PRINT " "
1530 IF D THEN LOCATE 9,T+1:PRINT USING U$;D;:PRINT " "
1540 IF E THEN LOCATE 7,T+10:PRINT USING U$;E;:PRINT " "
1550 IF F THEN COLOR 7,0:LOCATE 4,T+44:PRINT " ®ÄÄÄÄ";
1560 IF F THEN COLOR 0,7:PRINT USING V$;F*180/PI;:PRINT "ø"
1570 IF G THEN LOCATE 9,T+49:PRINT USING V$;G*180/PI;:PRINT "ø"
1580 IF H THEN LOCATE 9,T+34:PRINT USING V$;H*180/PI;:PRINT "ø"
1590 IF I THEN LOCATE 6,T+34:PRINT USING U$;I;:PRINT " "
1600 IF J THEN LOCATE 6,T+48:PRINT USING U$;J;:PRINT " "
1610 IF K THEN LOCATE 11,T+41:PRINT USING U$;K;:PRINT " "
1620 '
1630 COLOR 7,0
1640 IF T1*T2*C*D*E THEN 1680
1650 IF F*G*H*I*J*K THEN 1680
1660 RETURN
1670 '
1680 VIEW PRINT 15 TO 24:CLS:VIEW PRINT:LOCATE 15
1690 PRINT UL$;
1700 PRINT TAB(16);;"NOTE: All calculated values have been rounded-off."
1710 PRINT UL$;
1720 LN=18:GOSUB 1750
1730 GOTO 100   'start
1740 '
1750 'PRT
1760 KEY OFF:GOSUB 1830:LOCATE 25,5:COLOR 0,2
1770 PRINT " Send this page to:(1)Printer Queue? (2)Printout? ";
1780 PRINT "(3)Next page? (1/2/3)";:COLOR 7,0
1790 Z$=INKEY$:IF Z$<"1"OR Z$>"3"THEN 1790 ELSE GOSUB 1830
1800 IF Z$="3"THEN RETURN
1810 FOR I%=1 TO 24:FOR J%=1 TO 80:LPRINT CHR$(SCREEN(I%,J%));:NEXT J%:NEXT I%
1820 IF Z$="2"THEN LPRINT CHR$(12) ELSE 1760
1830 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
