SB-02 – Triangle Solution

Copyright © 1979-1981 by Steffen Beyer.

This program is free software, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Description:

Given any three values describing an arbitrary triangle (at least one side, though), such as length of side a, length of side b, length of side c, angle α, angle β or angle γ, the program will automatically calculate the missing other three values.

Usage:

In case there is more than one solution (indicated by a blinking 2 after pressing E), press E again after viewing the first solution in order to display the values of the second solution.

Example:

Enter the three sides: D 3 A 4 B 5 C

Then press E

To display the other values:

Good to know:

The program does not interfere with ongoing calculations. None of the functions A, B, C, 2nd A', 2nd B', 2nd C', D and E uses CLR or = internally.

For example it is possible to enter 2nd A' + 2nd B' + 2nd C' = in order to make a sanity check that the sum of the angles is indeed 180 degrees (if 2nd Deg is selected).

The program of course also works with 2nd Rad and 2nd Grad.

The program checks the number of arguments and displays a blinking 9.9999999 99 if there are more or less than three arguments, but it does no sanity checks on the arguments themselves in order to see whether the values cannot possibly match a real triangle, such as for example a = 3, b = 11 and α = 19.

In fact the maximum angle α which is possible in this example is easily calculated as D 3 A 1 1 B 9 0 2nd B' E 2nd A' which yields 15.82662013.

This example D 3 A 1 1 B 1 9 2nd A' E allegedly gives two solutions, the second of which yields negative values - an indication that something is wrong.

When the angle α is smaller than 15.82662013, then there are indeed always two solutions. For example D 3 A 1 1 B 1 5 2nd A' E will yield the following two solutions:

  a = 3
  b = 11
  c = 11.57098371
  α = 15
  β = 71.6230946
  γ = 93.3769054

  a = 3
  b = 11
  c = 9.679384465
  α = 15
  β = 108.3769054
  γ = 56.6230946

Resources used:

This program uses registers 00 to 13, t and flags 0 and 1.

Formulas used:

α + β + γ = 180 or 2π or 200

c2 = a2 + b2 - 2ab cos γ

a ÷ sin α = b ÷ sin β = c ÷ sin γ

Further development:

Maybe a sanity check could be added that the sum of the angles which have been entered is less than 180.

Maybe a function could be added to calculate the area of the triangle, according to the following formula:

A = sqrt (s (s-a) (s-b) (s-c)) with s = ( a + b + c ) ÷ 2