1 DEF ARCCOS(X)=-ATN(X/SQR(-X*X+1))+1.5708 ' ACOS(X)
5 CLEAR 12000
10 PRINT "ANALYSIS OF TWO VECTORS"
20 PRINT
30 DIM X(2), Y(2), Z(2), M(2)
35 PRINT
39 REM - STATEMENTS 40 TO 70 REQUEST VECTOR COORDINATES
40 PRINT "VECTOR 1: X,Y,Z";
50 INPUT X(1),Y(1),Z(1)
60 PRINT "VECTOR 2: X,Y,Z";
70 INPUT X(2),Y(2),Z(2)
80 PRINT
89 REM - LOOP TO ANALYZE BOTH VECTORS
90 FOR I=1 TO 2
99 REM - CALCULATE MAGNITUDE, PRINT
100 M(I)=SQR(X(I)[2+Y(I)[2+Z(I)[2)
109 REM - IS VECTOR A POINT? IF YES, CANNOT COMPUTE AN ANGLE
110 IF M(I)=0 THEN 220
120 PRINT "VECTOR";I;":"
130 PRINT "MAGNITUDE:";M(I)
139 REM - CONVERSION FACTOR FOR RADIANS TO DEGREES
140 S=57.29578
149 REM - CALCULATE ANGLE BETWEEN VECTOR AND X-AXIS, PRINT
150 J=X(I)/M(I)
160 PRINT "ANGLE WITH X-AXIS:";ARCCOS(J)*S
169 REM - CALCULATE ANGLE BETWEEN VECTOR AND Y-AXIS, PRINT
170 J=Y(I)/M(I)
180 PRINT "ANGLE WITH Y-AXIS:";ARCCOS(J)*S
189 REM - CALCULATE ANGLE BETWEEN VECTOR AND Z-AXIS, PRINT
190 J=Z(I)/M(I)
200 PRINT "ANGLE WITH Z-AXIS:";ARCCOS(J)*S
210 PRINT 
220 NEXT I
230 J=0
239 REM - IF EITHER VECTOR A POINT, CANNOT COMPUTE ANGLE
240 IF M(1)=0 THEN 310
250 IF M(2)=0 THEN 310
259 REM - CALCULATE ANGLE BETWEEN VECTORS
260 J=(X(1)*X(2)+Y(1)*Y(2)+Z(1)*Z(2))/M(1)/M(2)
269 REM - ARE THE VECTORS PERPENDICULAR?
270 IF J<>0 THEN 300
280 J=90
290 GOTO 310
299 REM - CALCULATE ANGLE IN DEGREES, PRINT
300 J=ATN(SQR(1-J[2)/J)*S
310 PRINT "ANGLE BETWEEN VECTORS:";J
320 PRINT
329 REM - RESTART OR END PROGRAM?
330 PRINT "MORE DATA (1=YES, 0=NO)";
340 INPUT Z
350 IF Z=1 THEN 35
360 END
