This collection contains four geometry programs: a polygon area calculator, an angle unit converter, a triangle solver, and a 3D vector analyzer. The polygon area calculator implements the shoelace formula, storing vertices in arrays of size N+1 so the closing segment wraps back to the first vertex without a conditional. The angle converter handles full degree/minute/second decomposition in both directions. The triangle solver uses a computed GOTO (GO TO 200*B) to dispatch five triangle-type cases (AAS, ASA, SAS, SSA, SSS), applying the law of sines and law of cosines as appropriate, and includes an SSA ambiguous-case check at line 870. The vector analyzer computes magnitudes, direction cosines, and the angle between two 3D vectors, with clamping guards (lines 265–266 and 505–510) to prevent domain errors in ACS due to floating-point rounding.
Program Analysis
Program Structure
The listing contains four independent programs, each terminated by a SAVE/RUN pair. They share no variables and are meant to be loaded individually:
- AREA – Polygon area via the shoelace formula (lines 10–240)
- DEGREES – Radians ↔ degrees/minutes/seconds converter (lines 5–430)
- PARTS – Triangle solver for five case types (lines 10–2030)
- VECTOR – 3D vector analysis (lines 10–550)
AREA – Polygon Area Calculator
The program collects N vertex pairs and computes area using the shoelace (Gauss) formula. The array is dimensioned to N+1 elements, and lines 160–170 copy the first vertex into position N+1, elegantly closing the polygon loop without a branch inside the summation.
The summation at line 200 accumulates (X(I)+X(I+1))*(Y(I)-Y(I+1)); dividing the absolute value by 2 at line 220 yields the correct area regardless of vertex winding order. FAST mode is entered at line 156 before the calculation, which on this platform suppresses the display to speed up the arithmetic loop. Input validation at lines 60–80 truncates N to an integer and rejects values below 1, but does not enforce an upper bound.
DEGREES – Angle Unit Converter
A three-option menu dispatches to radians-to-DMS conversion (lines 130–260) or DMS-to-radians conversion (lines 300–430). The radians-to-DMS path multiplies by 3600×180/PI to get total arc-seconds, then uses INT arithmetic to peel off degrees, minutes, and seconds. Line 190 handles full rotations by computing D MOD 360 via D - 360*INT(D/360).
The DMS-to-radians path (line 400) similarly normalizes the decimal degree value modulo 360 before converting, though the printed result at line 410 uses the un-normalized A value — a minor inconsistency that could cause unexpected output for very large degree inputs.
PARTS – Triangle Solver
This is the most complex of the four programs. The user selects a problem type (1–5), and the computed GO TO 200*B at line 160 dispatches to the appropriate case handler:
| Input (B) | Jump target | Case |
|---|---|---|
| 1 | 200 | AAS – two angles and a non-included side |
| 2 | 400 | ASA – two angles and the included side |
| 3 | 600 | SAA – side and two adjacent angles |
| 4 | 800 | SSA – two sides and a non-included angle (ambiguous) |
| 5 | 1000 | SSS – three sides given |
Shared subroutines at lines 1500 and 2000 handle side and angle input respectively, with the angle subroutine converting from degrees to radians on entry (A(B)=A(B)*PI/180). Output at line 1425 converts back to degrees for display.
The SSA ambiguous case is handled at lines 860–910: the altitude T is computed, and if S(1) < T no solution exists (line 520). The code at line 890 checks S(1) <= T (which in practice means equality, i.e., a right triangle) to go directly to the angle calculation, otherwise it adds both possible base segments before proceeding. Note that this resolves to only one of the two possible triangles in the genuinely ambiguous case — the second solution is not presented.
The GO TO 15 at line 1450 resets arrays and re-prompts after each solution, using CLEAR at line 15 to release dynamic memory before re-dimensioning.
VECTOR – 3D Vector Analyzer
The program computes and displays magnitude, the three direction-cosine angles (with each Cartesian axis), and the angle between two vectors. The constant S=57.29578 (degrees per radian, i.e., 180/PI) is used in preference to PI itself for the degree conversion, avoiding repeated division.
A subroutine at line 500 is used for each direction-cosine angle. It applies two layers of rounding and clamping:
- Line 500 rounds the cosine value to 8 decimal places to suppress floating-point noise.
- Lines 505–510 clamp to [−1, 1] to prevent a domain error in
ACS. - Line 530 rounds the resulting angle to 5 decimal places for clean output.
The same clamping pattern is applied inline at lines 265–266 for the inter-vector angle. Lines 270–290 special-case a dot product of zero (orthogonal vectors) by directly assigning 90° rather than computing ACS 0, which is defensively correct but not strictly necessary since ACS 0 would simply return PI/2.
Notable Techniques and Anomalies
- The computed
GO TO 200*Bidiom in PARTS is an efficient dispatch table, avoiding a chain ofIFtests. - Re-dimensioning arrays each iteration in AREA (lines 90–100) and PARTS (line 15–17) is the standard way to handle variable-size data on this platform, since arrays cannot be resized after
DIM. - AREA enters
FASTmode before computation but never explicitly restoresSLOWmode; returning to thePRINTstatement at line 220 implicitly restores normal display since output requires it. - DEGREES line 550 is unreachable dead code (
GOTO 20at line 430 precedes it); line 550 would be reached only by falling through from line 540, which itself is only reachable after aGOTO 20branch at line 430 — there is no actual fall-through path. - VECTOR re-runs the entire program with
RUN(line 350) on “Y” rather than branching back to line 30, which re-initializes all variables but also re-executes theDIMstatements, adding slight overhead.
Content
Image Gallery
Source Code
10 CLS
20 PRINT "AREA OF A POLYGON"
30 PRINT
40 PRINT "HOW MANY VERTICES (0 TO END)?"
50 INPUT N
60 LET N=INT N
70 IF N=0 THEN STOP
80 IF N<1 THEN GOTO 40
90 DIM X(N+1)
100 DIM Y(N+1)
110 FOR I=1 TO N
120 CLS
130 PRINT "X COORDINATE OF VERTEX ";I;" ";
135 INPUT X(I)
136 PRINT X(I)
140 PRINT "Y COORDINATE OF VERTEX ";I;" ";
145 INPUT Y(I)
150 NEXT I
155 CLS
156 FAST
160 LET X(N+1)=X(1)
170 LET Y(N+1)=Y(1)
180 LET AREA=0
190 FOR I=1 TO N
200 LET AREA=AREA+(X(I)+X(I+1))*(Y(I)-Y(I+1))
210 NEXT I
220 PRINT "AREA = ";ABS AREA/2
230 PRINT
240 GOTO 30
250 SAVE "ARE[A]"
260 RUN
5 SCROLL
10 CLS
20 PRINT "ANGLE CONVERSION"
30 PRINT
40 PRINT "1. RADIANS TO DEGREES"
50 PRINT "2. DEGREES TO RADIANS"
60 PRINT "3. STOP"
70 PRINT
80 PRINT "OPTION: ";
90 INPUT A
95 PRINT A
100 IF A=3 THEN STOP
110 IF A=2 THEN GOTO 300
120 IF A<>1 THEN GOTO 10
130 CLS
140 PRINT "ANGLE IN RADIANS: ";
150 INPUT R
160 PRINT R
170 LET A=3600*180*R/PI
180 LET D=INT (A/3600)
190 LET D1=INT (D/360)
200 PRINT " DEGREES = ";D-360*D1
210 LET A=INT (A-D*3600)
220 LET B=INT (A/60)
230 PRINT " MINUTES = ";B
240 PRINT " SECONDS = ";A-60*B
250 PRINT
260 GOTO 20
300 CLS
305 PRINT "DEGREES: ";
310 INPUT D
320 PRINT D
330 PRINT "MINUTES: ";
340 INPUT M
350 PRINT M
360 PRINT "SECONDS: ";
370 INPUT S
380 PRINT S
390 LET A=D+M/60+S/3600
400 LET R=A-360*INT (A/360)
410 PRINT " RADIANS = ";A*PI/180
420 PRINT
430 GOTO 20
440 SAVE "DEGREE[S]"
450 RUN
10 CLS
15 CLEAR
16 DIM S(3)
17 DIM A(3)
120 PRINT "PROBLEM TYPE"
130 INPUT B
140 IF B=0 THEN STOP
150 IF B<1 OR B>5 THEN GOTO 120
155 CLS
160 GOTO 200*B
200 LET B=1
210 GOSUB 2000
220 LET B=3
230 GOSUB 1500
240 LET B=2
250 GOSUB 2000
255 LET A(3)=PI-A(1)-A(2)
260 LET S(1)=S(3)*SIN (A(1))/SIN (A(3))
270 LET S(2)=S(3)*SIN (A(2))/SIN (A(3))
280 GOTO 1400
400 FOR B=1 TO 3
410 IF B=1 THEN GOSUB 2000
420 IF B<>1 THEN GOSUB 1500
430 NEXT B
460 LET S(1)=SQR (S(3)*S(3)+S(2)*S(2)-2*S(3)*S(2)*COS (A(1)))
470 LET A(2)=SIN (A(1))/S(1)*S(2)
480 LET A(2)=ASN A(2)
490 LET A(3)=PI-A(1)-A(2)
500 GOTO 1400
520 PRINT
530 PRINT "NO SOLUTION"
540 PRINT
550 GOTO 20
600 LET B=3
605 GOSUB 1500
610 GOSUB 2000
620 LET B=2
630 GOSUB 2000
660 LET A(1)=PI-A(2)-A(3)
670 GOTO 260
800 LET B=1
805 GOSUB 2000
810 GOSUB 1500
820 LET B=2
830 GOSUB 1500
860 LET T=S(2)*SIN (A(1))
870 IF S(1)<T THEN GOTO 520
880 LET S(3)=SQR (S(2)*S(2)-T*T)
890 IF S(1)<=T THEN GOTO 470
900 LET S(3)=S(3)+SQR (S(1)*S(1)-T*T)
910 GOTO 470
1000 FOR B=1 TO 3
1010 GOSUB 1500
1020 NEXT B
1030 LET A(1)=(S(2)*S(2)+S(3)*S(3)-S(1)*S(1))/(2*S(2)*S(3))
1040 LET A(1)=ACS A(1)
1050 GOTO 470
1400 CLS
1410 FOR B=1 TO 3
1420 PRINT "SIDE ";B;" = ";S(B);
1425 LET A(B)=A(B)*180/PI
1430 PRINT " ANGLE = ";A(B)
1440 NEXT B
1450 GOTO 15
1500 PRINT "SIDE ";B
1510 INPUT S(B)
1520 RETURN
2000 PRINT "ANGLE ";B
2010 INPUT A(B)
2020 LET A(B)=A(B)*PI/180
2030 RETURN
2040 SAVE "PART[S]"
2050 RUN
10 CLS
15 DIM A$(1)
20 PRINT "ANALYSIS OF 2 VECTORS"
30 PRINT
40 DIM X(2)
41 DIM Y(2)
42 DIM Z(2)
43 DIM M(2)
50 FOR I=1 TO 2
60 PRINT "VECTOR ";I
70 PRINT "X-COORDINATE: ";
75 INPUT X(I)
76 PRINT X(I)
80 PRINT "Y-COORDINATE: ";
81 INPUT Y(I)
82 PRINT Y(I)
90 PRINT "Z-COORDINATE: ";
91 INPUT Z(I)
92 PRINT Z(I)
93 NEXT I
94 CLS
100 FOR I=1 TO 2
105 LET M(I)=SQR (X(I)*X(I)+Y(I)*Y(I)+Z(I)*Z(I))
110 IF M(I)=0 THEN GOTO 220
120 PRINT "VECTOR ";I
130 PRINT "MAGNITUDE: ";M(I)
140 LET S=57.29578
150 LET J=X(I)/M(I)
160 PRINT "ANGLE WITH X-AXIS: ";
165 GOSUB 500
170 LET J=Y(I)/M(I)
180 PRINT "ANGLE WITH Y-AXIS: ";
181 GOSUB 500
185 LET J=Z(I)/M(I)
190 PRINT "ANGLE WITH Z-AXIS: ";
195 GOSUB 500
210 PRINT
220 NEXT I
240 IF M(2)=0 OR M(1)=0 THEN GOTO 310
260 LET J=(X(1)*X(2)+Y(1)*Y(2)+Z(1)*Z(2))/(M(1)*M(2))
265 IF J>1 THEN LET J=1
266 IF J<-1 THEN LET J=-1
270 IF J<>0 THEN GOTO 300
280 LET J=90
290 GOTO 310
300 LET J=S*ACS J
305 LET J=INT (J*1000000+.5)/1000000
310 PRINT "ANGLE BETWEEN VECTORS: ";J
320 PRINT
330 PRINT "MORE?"
340 INPUT A$
350 IF A$="Y" THEN RUN
360 IF A$="N" THEN STOP
370 PRINT "YES OR NO"
380 GOTO 330
390 SAVE "VECTO[R]"
400 RUN
500 LET J=INT (J*1E8+.5)/1E8
505 IF J>1 THEN LET J=1
510 IF J<-1 THEN LET J=-1
520 LET J=S*ACS J
530 LET J=INT (J*1E5+.5)/1E5
540 PRINT J
550 RETURN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.