10 " "CLEAR :ON ERROR GOTO 950:WAIT 90:PRINT "    VECTOR ARITHMETIC":PRINT "  Copr. 1982 Tandy Corp."
11 USING :LOCK :GOTO 900
20 X=J*(SIN L*COS K):Y=J*(SIN L*SIN K):Z=J*COS L:RETURN 
30 J=SQR (A*A+B*B+C*C)
31 IF J=0LET K=0:L=0:RETURN 
32 L=ACS (C/J)
33 IF A=0AND B=0LET K=0:RETURN 
34 IF A=0LET K=90*(2-SGN B):RETURN 
35 IF B=0LET K=90*(1-SGN A):RETURN 
36 K=ATN (B/A)+ACS (-1)*(A<0):IF K<0LET K=K+2*ACS (-1)
37 RETURN 
40 IF MTHEN 50
41 WAIT 0:Z$="First vector ":CLS :PRINT Z$;:INPUT "X? ";A:GOTO 43
42 GOTO 46
43 CLS :PRINT Z$;:INPUT "Y? ";B
44 CLS :PRINT Z$;:INPUT "Z? ";C
45 IF QLET Q=0:RETURN 
46 Z$="Second vector ":CLS :PRINT Z$;:INPUT "X? ";X
47 CLS :PRINT Z$;:INPUT "Y? ";Y
48 CLS :PRINT Z$;:INPUT "Z? ";Z
49 RETURN 
50 Z$="First vector ":CLS :PRINT Z$;:INPUT "mag? ";J:GOTO 52
51 GOTO 56
52 CLS :PRINT Z$;:INPUT "phi? ";K
53 CLS :PRINT Z$;:INPUT "theta? ";L
54 GOSUB 20:A=X:B=Y:C=Z
55 IF QLET Q=0:RETURN 
56 CLS :Z$="Second vector ":PRINT Z$;:INPUT "mag? ";J
57 CLS :PRINT Z$;:INPUT "phi? ";K
58 CLS :PRINT Z$;:INPUT "theta? ";L
59 GOSUB 20:RETURN 
60 CLS :WAIT :IF MTHEN 65
61 PRINT "X =";A:PRINT "Y =";B:PRINT "Z =";C:RETURN 
65 GOSUB 30:PRINT "Magnitude =";J:PRINT "Phi =";K:PRINT "Theta =";L:RETURN 
100 "+"GOSUB 40:A=A+X:B=B+Y:C=C+Z:GOSUB 60:GOTO 900
200 "-"GOSUB 40:A=A-X:B=B-Y:C=C-Z:GOSUB 60:GOTO 900
300 "."GOSUB 40:WAIT :CLS :PRINT "Dot prod =";A*X+B*Y+C*Z:GOTO 900
400 "X"GOSUB 40:G=B*Z-C*Y:H=C*X-A*Z:C=A*Y-B*X:A=G:B=H:GOSUB 60:GOTO 900
500 "V"GOSUB 40:G=ACS ((A*X+B*Y+C*Z)/((SQR (A*A+B*B+C*C))*(SQR (X*X+Y*Y+Z*Z))))
510 CLS :WAIT :PRINT "Angle =";G:GOTO 900
600 "R"R=M:M=1:GOTO 620
610 "S"R=M:M=0
620 Q=1:G=A:H=B:I=C:N=X:O=Y:P=Z:GOSUB 40:IF MLET A=X:B=Y:C=Z
627 M=1-M:GOSUB 60:M=R
630 A=G:B=H:C=I:X=N:Y=O:Z=P:GOTO 900
700 "C"CLEAR :WAIT 60:PRINT "Data cleared":GOTO 900
800 "M"WAIT 60:M=1-M:IF MPRINT "Spherical mode":GOTO 900
810 PRINT "Rectangular mode":GOTO 900
900 WAIT 0:CLS :PRINT "> Ready"
905 IF INKEY$ <>""THEN 905
910 A$=INKEY$ :IF A$=""THEN 910
920 CLS :GOTO A$
950 BEEP 3:WAIT :PRINT "UNDEFINED OPERATION":GOTO 900
999 "Q"UNLOCK :END
