How to detect intersecting segments based on length of the segments As part of a larger problem, I am trying to detect based on the distance matrix which segments intersect in the original 2D space that originated the matrix. I don´t have coordinates (lat/long, x/y or any other for the points).

As an example, on the image below, the answer to the question for the top graph would be: AD, BC. While for the bottom graph would be AC, BD.

The information that we have is just the distance matrix:

DISTANCE MATRIX TOP

$
\begin{align}
 &amp;&amp; A &amp;&amp; B &amp;&amp; C &amp;&amp; D \\
A&amp;&amp; 0 &amp;&amp; 1 &amp;&amp; 1 &amp;&amp; \sqrt{2} \\
B&amp;&amp; 1 &amp;&amp; 0 &amp;&amp; \sqrt{2} &amp;&amp; 1 \\
C&amp;&amp; 1 &amp;&amp; \sqrt{2} &amp;&amp; 0 &amp;&amp; 1 \\
D&amp;&amp; \sqrt{2} &amp;&amp; 1 &amp;&amp; 1 &amp;&amp; 0
\end{align}
$

DISTANCE MATRIX BOTTOM

$
\begin{align}
 &amp;&amp; A &amp;&amp; B &amp;&amp; C &amp;&amp; D \\
A&amp;&amp; 0 &amp;&amp; 1 &amp;&amp; 1 &amp;&amp; \sqrt{2} \\
B&amp;&amp; 1 &amp;&amp; 0 &amp;&amp; \sqrt{2} &amp;&amp; \sqrt{5} \\
C&amp;&amp; 1 &amp;&amp; \sqrt{2} &amp;&amp; 0 &amp;&amp; 1 \\
D&amp;&amp; \sqrt{2} &amp;&amp; \sqrt{5} &amp;&amp; 1 &amp;&amp; 0
\end{align}
$



I have tried so far to use the triangular inequality and some other (probably) naive geometric knowledge but I can´t figure out what conditions must be met.
First assume that you know where $A,B,C,D$ are.  In this case, you can write $D$ uniquely in the form $\alpha_A A + \alpha_B B + \alpha_C C$, with $\alpha_A + \alpha_B + \alpha_C = 1$. The tuple $(\alpha_A,\alpha_B,\alpha_C)$ are called the barycentric coordinates of $D$.  You can read off which of the segments $Dx$ ($x\in \{A,B,C\}$) cross a side of the triangle $ABC$ from the sign pattern of the barycentric coordinates.

It's not particularly difficult to find suitable coordinates either.  You can just assume that $A=(0,0)$, $B=(d(A,B),0)$, and $C$ is either intersection point of the appropriate circles around $A$ and $B$.  This will then uniquely determine $D$ by intersecting three circles.