[Math] How to find the closest point to three vector lines

3dgeometric-interpretationvector-spacesvectors

Regarding the image below, I know the angles $A$ and $B$ for each individual, and their positions in longitude and latitude (assuming height of person $z =0$).

Am I correct in thinking that for any position in the z plane it would be $z = x\tan(B)$ and in the $y$ plane $y = x\tan(A)$?

If so this would mean I could form a $3$ dimensional vector straight line from each person.

The problem is I am highly doubting all three straight lines will intersect, so my question is how do I calculate the closest point to all three vector lines mathematically?

Cheers

enter image description here

Best Answer

If you can convert the line information that you currently have into $(x,y,z)$-coordinates then you can calculate the closest point between two straight, skew lines using the following:

Line 1: \begin{equation} \vec{r}_{1} = \vec{a}+\lambda\vec{b} \end{equation}

Line 2: \begin{equation} \vec{r}_{2} = \vec{c}+\mu\vec{d} \end{equation}

where $\vec{a}$, $\vec{c}$ are the position vectors of the line equations, and $\vec{b}$, $\vec{d}$ are the direction vectors of the line equations.

The linking line passing through the shortest distance between $\vec{r}_{1}$ and $\vec{r}_{2}$ is perpendicular to both $\vec{r}_{1}$ and $\vec{r}_{2}$:

\begin{equation} \vec{n} = \vec{b}\times\vec{d}. \end{equation}

The component of $\vec{a}-\vec{c}$ (or $\vec{c}-\vec{a}$) in the direction of $\vec{n}$ is then needed:

\begin{equation} \rm{Distance} = |(\vec{a}-\vec{c})\cdot\hat{n}| \end{equation} or \begin{equation} \rm{Distance} = |(\vec{c}-\vec{a})\cdot\hat{n}|. \end{equation}

Where $\hat{n} = \vec{n}/|\vec{n}|$.

If you repeat this process to calculate the distance from line 1 to line 2, line 1 to line 3, line 2 to line 3, then you can take the average to find the shortest distance between all three lines.