Here we have:
Code:
L1 holds sides. L2 holds angles. Of the six elements, there should be three zeroes representing three unknowns—no more, no less. The program below will compute the missing sides and angles in addition to the triangle's area. It will display both sets of solutions if two exist (per the SSA theorem), and it will give no output if there are no valid solutions.
Code:
Two problems with this:
(Good grief, there's only one store arrow in the entire program, and it only serves as an optimization!)
Code:
L2(3)
L1(2) / \ L1(1)
/ \
L2(1)---------L2(2)
L1(3)
L1 holds sides. L2 holds angles. Of the six elements, there should be three zeroes representing three unknowns—no more, no less. The program below will compute the missing sides and angles in addition to the triangle's area. It will display both sets of solutions if two exist (per the SSA theorem), and it will give no output if there are no valid solutions.
Code:
PROGRAM:TRISOLVE
:Degree
:not(L1)(L2+not(L2)(180-sum(L2 //AAS→ASA
:max(L1)sin(Ans)/sin(sum(Ans+min(L1 //Compute sides via ASA
:If 2=sum(not(Ans //Did it work?
:√(sum(L1²)-prod(L1+2not(L1)cos(max(L2 //If not, use SAS instead
:If min(L1) or max(L1 and L2)≠sum(not(L1 //It wasn't SSA, right?
:Then
:Goto 0 //If not, go ahead to display
:End
:For(X,-1,1,2 //SSA members only
:max(L1not(L2
:Anscos(L2)+X√(L1²-Ans²sin(L2)²
:max(Ansnot(not(L2
:Lbl 0 //Ready to update "sides" list and display
:L1+Ansnot(L1→X
:If min(real(Ansnot(imag(Ans //Is this solution valid for a triangle?
:Then
:Pause Ans //Sides, angles
:Pause cos‾¹(Ans/prod(Ans)(.5sum(Ans²)-Ans²
:sum(.5{L}X
:Pause √(Ansprod(Ans-{L}X //Area (Heron's formula)
:End
:End
Two problems with this:
- It's over 200 bytes – not worth removing the elegant "area" code over.
- The SSS case lists the solution twice. A condition needs tightening. (Edit: Fixed)
(Good grief, there's only one store arrow in the entire program, and it only serves as an optimization!)