Roger Blake <rogerblake@sprintmail.com> wrote:

> Let me see if I can make my case to you so you can point out the error
> in my thinking.  Instead of the 5, 6, 7 triangle which is not a triangle
> that as stated will produce an ambiguous solution [it can produce three
  ambiguous solutions, as we'll show below, but let's pass on that for now]

> let's use Angle A = 20 degrees, side a=1, and c=2

  Well, so far we think alike, inasmuch as I've used this same example
  quite a lot while testing the program :)


                                         B
                  Known            x    / \       Known
              c   side:      x         /   \   <- side
                       x              /     \
                 x                   /       \      a
           x                        /         \
  A  x-----------------------------o-----------o C
    ^ Known angle   b

> I run it on your program set to solve for the larger angle

  Well, you chose ">", which chooses the longer *side* for the unknown
  side b, but at the same time the angle C is the *smaller* possibility
  [between  the two first choices having equal SIN(C)], as seen below.

  Of course angle B is then larger, if that's what you mean.

> and I get the following:
    a=1
    b=2.609   [ actually -2.609 ==> calculated, not user-supplied ]
    c=2
    A=20
    B=-116.840
    C=43.160  [ actually -43.160, also calculated]  <== less than 90
> and the message that the solution is ambiguous.
> [and returns] {1.000 2.609 2.000 20.00 116.840 43.160}

> Lets assume that a flag [7] is set that indicates [it was ambiguous].
> Further, [flag 6] knows that it's set to find the larger solution.

  Yep, "larger" meaning in terms of unknown *side* (and by consequence,
  also the larger possibility for the angle opposite the unknown side).

> Since  the larger angle was found and it must be
> greater than 90 degrees that angle had to be an unknown.

  Tilt!!!

  Although you have correctly constructed *one* particular situation
  where you can, by good luck, identify the second solution without
  ambiguity, you can not always do so.

  With the ">" option chosen, no angle in *all* solutions need have been
  greater than 90 degrees (remember, it was angle B that came out to
  be larger, angle C that is definitely smaller, and it's merely chance
  that angle B happens to be greater than 90 degrees, for there is a
  universe of solutions where it isn't, e.g. a=4, c=7, A=33,
  which leads to B=-74.61, C=-72.38, all with this same ">" option).

  It is in fact the "<" menu choice which *forces* angle C to be obtuse,
  but ">" does not force angle B to be obtuse.

Now, before you start all over again, trying a specific "<" solution
first, let me cover every single possibility with this exhaustive logic:

No matter what solution you find on the stack after TRI1 executes,
as long as no two of the three sides are exactly equal (eliminate
exact right triangles also, for sake of argument), you can pick
three combinations of SSA out of that list which make an ambiguous
input set, since you can pick any pair of unequal sides in three
different ways, and once you have picked a pair of sides, you
can pick the angle opposite the smaller side to go along with those
(pictorially, for any of the three pairs of sides, you can see that
the shorter of the two can be the "swinger" which can have two possible
positions, and this is true both for acute and obtuse triangles).

If it so happens that the triangle found on the stack is acute,
then what's found on the stack could only have resulted from the
">" option of TRI1 [it's impossible that the "<" option could
have been in effect, because that option always computes the
first solved angle as 180 - ASIN(something) > 90 degrees],
and there's no way to distinguish which of the three alternate
"<" outputs "goes with" the solution you found on the stack.

If it so happens that the triangle found on the stack is obtuse,
then of the three possible ambiguous SSA sets we could pick from
what's on the stack, one of them could possibly produce what's
found on the stack only from the ">" option of TRI1, and the
other two could produce what's found on the stack only from
the "<" option.  Now, if the "flag" left by TRI1 happens to
indicate that the ">" option *was* in effect, then you "win,"
and you will be able to identify a unique "alternate" solution,
but if you find that the "<" option was in effect, then you
are still facing two indistinguishable possibilities.

If you say 'let's always perform a ">" option first,' then whenever
that option results in an obtuse triangle answer, as in your
particular example above, you "win," but whenever that option
results in an acute triangle answer, you "lose."

If you say 'let's always perform a "<" option first,'
then the situation is much worse, for there will *always*
be two indistinguishable possibilities in such a case
(either of the two shorter sides could be the "swinger,"
with the point about which it swings being where it meets
the longest side, rather than where the obtuse angle now is).

Since no strategy whatsoever is a sure "winner," we might as well
let the user have the freedom to specify whichever option he may want,
or do both in whatever order he may want, since he may well know
in advance which one applies to his particular case, so
why make him wait for two solutions to be calculated,
when he only needs one?

> Your program is great, but I suspect it could be done with all positive
> numbers, but then again I may be overlooking something, so tell it to me.

  "Round up the usual suspects" :)

I'll soon add the "angle" symbols to the screen display
as a consolation -- how's that?  :)

-----------------------------------------------------------
With best wishes from:   John H Meyers   <jhmeyers@mum.edu>