Given two points with coordinates (latitude and longitude) And two vectors from those two points with their headings focusing on some distant object, determine the coordinates (latitude and longitude) of that distant object.

I need to write the solution into javascript to operate an aspect of an app I’m building. Take two photos of an object at nearly 90 degrees apart, using the pinpoint lat & long from the phone and heading of the lens when the camera snapped each image, locate the exact position of the object.

My math is sadly inadequate, although I can understand things bit by bit when explained clearly, many thanks for your help

  • $\begingroup$ The camera positions are nearly 90° of latitude/longitude apart, so about 10000 km apart? Or rather the two heading values are ~90° apart (say, both are somewhere in Paris and one sees the Eiffel tower in NNE direction and the other ESE direction)? $\endgroup$ – Hagen von Eitzen May 18 '18 at 17:19
  • $\begingroup$ Exactly that, heading values are ~90° apart. $\endgroup$ – Ultradiv May 18 '18 at 22:50

I assume the two camera positions (probably known anyway only up to 1m precision or worse) are close enough to allow approximating the relevant part of the earth surface as flat. If the longitudes/latitudes/headings are $(\alpha_1,\beta_1,\gamma_1)$ and $(\alpha_2,\beta_2,\gamma_2)$, we can convert longitude/latitude $(\alpha,\beta)$ to cartesian coordinates $(x,y)$ as $$ \begin{align}x&=(\alpha-\alpha_1)\cdot\cos\beta_1\\ y&=(\beta-\beta_1) \end{align}$$ The heading rays are then given by $$ (x,y)=(t\sin\gamma_1, t\cos\gamma_1), \qquad t\ge 0$$ $$ (x,y)=((\alpha_2-\alpha_1)\cos\beta_1+u\sin\gamma_2,\beta_2-\beta_1+ u\cos\gamma_2), \qquad u\ge 0$$ Equating these, we find a system of two linear equations in two unknowns $t,u$. This can be solved and then we find the $(x,y)$ coordinates of the target and ultimately also the latitude/longitude of the target.

To wit, $$\begin{align} t\sin\gamma_1-u\sin\gamma_2&=(\alpha_2-\alpha_1)\cos\beta_1\\ t\cos\gamma_1-u\cos\gamma_2&=\beta_2-\beta_1\end{align}$$ gives $$ t=\frac{(\alpha_2-\alpha_1)\cos\beta_1\cos\gamma_2-(\beta_2-\beta_1)\sin\gamma_2}{\sin\gamma_1\cos\gamma_2-\cos\gamma_1\sin\gamma_2}.$$ Fortunately (regarding the numerical precision), $\gamma_1$ and$\gamma_2$ differ by $\approx90^\circ$, which automatically makes the denominator $\approx \pm1$. There is no need to also find $u$. The found $t$ is enough to compute $$\begin{align}x&=t\sin\gamma_1\\ y&=t\cos\gamma_1\end{align}$$ for the coordinates of the target and then $$ \begin{align}\alpha&=\frac x{\cos\beta_1}+\alpha_1\\ \beta&=y+\beta_1.\end{align}$$ By the way, $t$ is essentially the distance form the first camera position to the target, measured in degrees. So multiply by $60$ do get approximately nautical miles. Multiply by $60\cdot 1852$ to obtain approximate distance in meters. (Same goes for $u$ - not computed aboove - and the distance from the second camera position).

Numerical example

One observer at 48° 51.175'N, 2° 18.162'E sees a tall metal structure in NW direction (more precisely at a heading of $\approx 314^\circ$). A second observer sees the same from 48° 50.828'N, 2° 16.478'E in NE directoin (more precisely at a heading of $\approx 50^\circ$). So (with 5 digit precision) $$ \alpha_1=2.30270^\circ,\quad \beta_1=48.85292^\circ,\quad\gamma_1=314^\circ$$ $$ \alpha_2=2.27463^\circ,\quad \beta_2=48.84713^\circ,\quad\gamma_2=50^\circ$$ This makes $$\begin{align} t&=\frac{(2.27463-2.30270)\cos 48.85292^\circ \cos 50^\circ-(48.84713-48.85292)\sin 50^\circ}{\sin314^\circ\cos50^\circ-\cos314^\circ\sin50^\circ}\\ &=\frac{(-0.02807)\cdot 0.65799\cdot 0.64279-(-0.00579)\cdot0.76604}{(-0.71934)\cdot0.64279-0.69466\cdot0.76604 }\\ &=\frac{-0.00744}{-0.99452}\qquad\text{(as promised, denominator}\approx \pm1)\\&=0.00748\end{align}$$ With this, $$\begin{align}x&=0.00748\cdot(-0.71934)= -0.00538,\\ y&=0.00748\cdot0.69466=0.00520,\\ \alpha&=\frac{-0.00538}{0.65799}+2.30270=2.29452,\\ \beta&=0.00520+48.85292=48.85812 \end{align}$$ Thus the observed tall steel structure is located at 48°51.487'N, 2°17.671'E and commonly known under the name Eiffel Tower.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.