Finding an angle in a triangle, when the length of one side is unknown and the distances from each vertex to an arbitrary point is known Given the triangle $\triangle ABN$ I would like to find the angle $\angle ANB$. The lengths of $AN$ and $BN$ are known, but the length $AB$ is unknown.
There exists another point $S$ that forms two more triangles $\triangle ANS$ and $\triangle BNS$. The lengths of $NS, AS$ and $BS$ are known. The location of $S$ is arbitrary, it may be inside or outside $\triangle ABN$.
Using these triangles $\angle ANS$ and $\angle BNS$ can be calculated. These can then be used to find $\angle ANB$. However, There are multiple ways to calculate ANB depending on the position of $S$, as shown by these two figures:


I've also come up with other equations that are required when $S$ is in different positions.
Is there a better way to find $\angle ANB$?
If there is not, is there a way to determine which of the equations to use to calculate $\angle ANB$ from $\angle ANS$ and $\angle BNS$?
The coordinates of the four points $A$, $B$, $N$ and $S$ are all unknown.
 A: You can use Cayley–Menger determinants. Writing $ab$ for the distance between $a$ and $b$, you get
$$\begin{vmatrix}
0 & SA^2 & SB^2 & SN^2 & 1 \\
SA^2 & 0 & AB^2 & AN^2 & 1 \\
SB^2 & AB^2 & 0 & BN^2 & 1 \\
SN^2 & AN^2 & BN^2 & 0 & 1 \\
1 & 1 & 1 & 1 & 0
\end{vmatrix}=0$$
This will lead to a quadratic equation in $AB^2$, which will give you two possible solutions. For each possible value of $AB^2$ you of course take the positive square root as $AB$. But that still leaves you with two solutions, and unless you have additional information, both of them are valid.
Here is one way to think about the two solutions. Since you know $AN, SA, SN$ you can construct $\triangle ANS$ uniquely up to a congruence transformation. The same holds for $\triangle BNS$ taken by itself. But if you combine them along the edge $NS$, you have to make a choice: are $A$ and $B$ on the same side of $NS$, or on different sides? Or in other words, do the triangles have the same or opposite orientation. Either solution would be valid, either would satisfy all your length requirements, but they would lead to different distances $AB$ and different angles $\gamma$. The following picture illustrates this:

Once you have $AB$, you can compute $\gamma$ from that using the cosine law:
$$\gamma=\arccos\frac{AN^2+BN^2-AB^2}{2\cdot AN\cdot BN}$$
The result will be in the range $[0°,180°]$, i.e. unsigned and no reflex angles. Which is what's to be expected if all you have are lengths.
A: 
As stated, the problem does not necessarily have a single solution. Example: 
AN = 1.0, BN = 0.65, NS = 0.92, AS = 0.81, BS = 0.35 
B's coordinates can be either {0.45509,0.354363} or 
{0.733145,0.592696}, and the values of angle ANB is different for 
these two sets of coordinates. 
Note that I am using approximate numbers here, but the roundoff errors 
are small enough to be ignored. 
I hope to expand on my answer by providing a closed formula for the 
two possible values of ANB (when they exist).
EDIT: General answer:
Create a Cartesian grid such that $N$ is at the origin, $A$ lies on 
the positive x axis and $S$ lies in the upper half plane. You can 
always do this using translation, rotation, and reflecting without 
affecting any lengths: 

(note that $A$ and $N$ above are flipped from my counterexample 
earlier, as it turns out the calculations are easier with $N$ at the 
origin; I've also replaced the side lengths with lowercase letters 
since I'm using Mathematica to help solve this problem) 
Although I've draw B and S in quadrant I, B can be in any quadrant, 
and S can be in quadrants I or II (since we explicitly chose our axis 
system so that sy > 0). 
We can now find sx and sy by solving the simultaneous equations: 
$\text{sx}^2+\text{sy}^2=d^2$ 
$(\text{sx}-c)^2+\text{sy}^2=e^2$ 
The are two solutions, but only one with sy > 0: 
$  
   \left\{\text{sx}\to \frac{c^2+d^2-e^2}{2 c},\text{sy}\to 
    \sqrt{d^2-\frac{\left(c^2+d^2-e^2\right)^2}{4 c^2}}\right\} 
$ 
We can now solve for bx and by using: 
$(\text{bx}-\text{sx})^2+(\text{by}-\text{sy})^2=f^2$ 
$\text{bx}^2+\text{by}^2=g^2$
and plugging in the values of sx and sy we found earlier, yielding two 
solutions, both valid: 
$ 
   \left\{\text{bx}\to \frac{\left(c^2+d^2-e^2\right) 
    \left(d^2-f^2+g^2\right)+\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) (d-f-g) 
    (d+f-g) (d-f+g) (d+f+g)}}{4 c d^2},\text{by}\to -\frac{c^4 
    \left(d^2-f^2+g^2\right)+c^2 \left(\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) 
    (d-f-g) (d+f-g) (d-f+g) (d+f+g)}-2 \left(d^2+e^2\right) 
    \left(d^2-f^2+g^2\right)\right)+(d-e) (d+e) \left(\sqrt{(c-d-e) (c+d-e) 
    (c-d+e) (c+d+e) (d-f-g) (d+f-g) (d-f+g) (d+f+g)}+(d-e) (d+e) 
    \left(d^2-f^2+g^2\right)\right)}{4 c d^2 \sqrt{-(c-d-e) (c+d-e) (c-d+e) 
    (c+d+e)}}\right\} 
$ 
$ 
   \left\{\text{bx}\to \frac{\left(c^2+d^2-e^2\right) 
    \left(d^2-f^2+g^2\right)-\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) (d-f-g) 
    (d+f-g) (d-f+g) (d+f+g)}}{4 c d^2},\text{by}\to \frac{c^4 
    \left(-\left(d^2-f^2+g^2\right)\right)+c^2 \left(\sqrt{(c-d-e) (c+d-e) 
    (c-d+e) (c+d+e) (d-f-g) (d+f-g) (d-f+g) (d+f+g)}+2 \left(d^2+e^2\right) 
    \left(d^2-f^2+g^2\right)\right)+(d-e) (d+e) \left(\sqrt{(c-d-e) (c+d-e) 
    (c-d+e) (c+d+e) (d-f-g) (d+f-g) (d-f+g) (d+f+g)}-(d-e) (d+e) 
    \left(d^2-f^2+g^2\right)\right)}{4 c d^2 \sqrt{-(c-d-e) (c+d-e) (c-d+e) 
    (c+d+e)}}\right\} 
$ 
To find ABN, we simply take the arctangent of 
$\frac{\text{by}}{\text{bx}}$. Since the angle will always be between 
0 and 180 degrees (if it's larger than 180 degrees, we measure the 
angle clockwise), we can use the single argument form of arctangent 
(I'd stated incorrectly earlier than we needed the two argument 
form. This yields: 
$ 
   -\tan ^{-1}\left(\frac{c^4 \left(d^2-f^2+g^2\right)+c^2 \left(\sqrt{(c-d-e) 
    (c+d-e) (c-d+e) (c+d+e) (d-f-g) (d+f-g) (d-f+g) (d+f+g)}-2 
    \left(d^2+e^2\right) \left(d^2-f^2+g^2\right)\right)+(d-e) (d+e) 
    \left(\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) (d-f-g) (d+f-g) (d-f+g) 
   (d+f+g)}+(d-e) (d+e) \left(d^2-f^2+g^2\right)\right)}{\sqrt{-(c-d-e) (c+d-e) 
    (c-d+e) (c+d+e)} \left(\left(c^2+d^2-e^2\right) 
    \left(d^2-f^2+g^2\right)+\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) (d-f-g) 
    (d+f-g) (d-f+g) (d+f+g)}\right)}\right) 
$ 
$ 
   \tan ^{-1}\left(\frac{c^4 \left(-\left(d^2-f^2+g^2\right)\right)+c^2 
    \left(\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) (d-f-g) (d+f-g) (d-f+g) 
    (d+f+g)}+2 \left(d^2+e^2\right) \left(d^2-f^2+g^2\right)\right)+(d-e) (d+e) 
    \left(\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) (d-f-g) (d+f-g) (d-f+g) 
   (d+f+g)}-(d-e) (d+e) \left(d^2-f^2+g^2\right)\right)}{\sqrt{-(c-d-e) (c+d-e) 
    (c-d+e) (c+d+e)} \left(\left(c^2+d^2-e^2\right) 
    \left(d^2-f^2+g^2\right)-\sqrt{(c-d-e) (c+d-e) (c-d+e) (c+d+e) (d-f-g) 
    (d+f-g) (d-f+g) (d+f+g)}\right)}\right) 
$ 
Mathematica can't find a simpler form for the answer, and I'm not sure 
how useful the above is, but there you have it. 
Note that I assume the triangle inequality throughout. When the 
triangle inequality doesn't hold, some of the square roots above are 
of negative values, and thus have no real number solutions. 
