Find position knowing 2 points and distances to those points

52 Views Asked by At

I have a problem that I am trying to solve and I don't know how to approach it.

I am trying to position myself in 2d space using Bluetooth Beacons.

Basically i have my 2 beacons:

  • BEACON 1 at coordinates (50, 638)
  • BEACON 2 at coordinates (586, 10)

I can calculate the distance to these beacons and for example I get:

  • Distance to BEACON 1 = 188 cm
  • Distance to BEACON 2 = 646 cm

And I need to find the coordinates of where I am.

It would have been easier to do if I had 3 beacons, but I think it may be possible with 2 as well. As I thought about it there can be 2 positions where I could possibly be, so that the distances that I found to be correct.

We can see here in this drawing that I made:

enter image description here

I'm sure there should be some kind of formula in order to find these 2 possible coordinates. I have though about how should I calculate them but I didn't come up with anything. Can someone help me with finding this coordinates?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use this formula:

$$\begin{align} x&=\frac{l}{d}(x_2-x_1) \pm \frac{h}{d}(y_2-y_1) + x_1,\\ y&=\frac{l}{d}(y_2-y_1) \mp \frac{h}{d}(x_2-x_1) + y_1.\\ \end{align}$$

Where:

$$\begin{align} d&=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}\\ l&=\frac{r_1^2-r_2^2+d^2}{2d}\\ h&=\sqrt{r_1^2-l^2} \end{align}$$ $r_1=$ distance to BEACON 1,$r_2=$ distance to BEACON 2

This will give you the 2 possible coordinates $(x_1,y_1)$ $(x_2,y_2)$ where you may be standing.