# Assuming I have the angle with respect to two beacons, and know the distance between them, can I localize myself?

Let's assume I have the following situation, and need to find (x,y).

Is it possible? There does not appear to be more than one solution to the system, but my trigonometry is a bit rusty.

I feel like I need one more distance.

• Do you really know theta1 and theta2 individually? Your inital question didn't say that. What are you using as a reference to know those headings absolutely? May 15 '15 at 22:06

If we assume that the origin of the reference frame is the left beacon, then it holds:

$$\begin{cases} \tan\theta_1=\frac{x}{y} \\ \tan\theta_2=\frac{d-x}{y} \end{cases}.$$

We finally derive the following relations:

$$\begin{cases} x=\frac{d\cdot\tan\theta_1}{\tan\theta_1+\tan\theta_2} \\ y=\frac{d}{\tan\theta_1+\tan\theta_2} \end{cases}.$$

• Are you assuming that the beacon-to-beacon line is the x-axis? [Ie, that the beacons are at (0,0) and (D,0)] May 15 '15 at 21:12
• Yep. The axes are oriented as depicted in the figure May 15 '15 at 21:15
• The title of the question is contradictory with respect to the problem's description: in the title the author mentions the knowledge of one angle, whereas in the description he clearly states he knows both of them, separately. Physically, I agree he would need a third beacon along the line connecting the original two in order to get $\theta_1$ and $\theta_2$. I've just provided an answer to the trigonometric problem then. May 15 '15 at 22:08

Octopus's answer assumes you only know D and θ₁ + θ₂. If that's all you know, then many points are possible solutions.

However, your diagram shows θ₁, θ₂ separately, as if they are true headings to the beacons. If that is so, and if you know the (x,y) locations of the beacons, then it is possible to solve for your unknown location.

Suppose B₁=(x₁,y₁) and B₂=(x₂,y₂) are the locations of the two beacons, and B₀=(x₀,y₀) is the unknown location. Equations of the lines B₀B₁ and B₀B₂ are x-x₁=(y-y₁)tanθ₁ and x-x₂=(y-y₂)tanθ₂, respectively, supposing your headings are relative to the y-axis. At point B₀ we have x₀-xᵢ=(y₀-yᵢ)tanθᵢ so x₀ = (y₀-y₁)tanθ₁-x₁ = (y₀-y₂)tanθ₂-x₂ giving y₀(tanθ₁-tanθ₂) = y₁tanθ₁-y₂tanθ₂+x₁-x₂ whence y₀ = (y₁tanθ₁-y₂tanθ₂+x₁-x₂)/(tanθ₁-tanθ₂). Then back-substitute to get x₀.

Note: this answer is based on the criteria from the original question, before edits were made to it.

If the orange spots are robots and the green spots are beacons, you can see that all three locations satisfy your criteria:

• angle between two beacons from robot's point of view and
• distance between the two beacons.

I think you can see that there are many such solutions when you only know those two variables.

But add a third beacon, and you might be on to something.

If you know true headings of beacon 1 and beacon 2 and not just the angle between them, then you have a different equation and one that has a single solution.

+1 Ugo's answer. To show the process a bit more:

We have two ways to calculate $y$:

$$y = \frac{x}{\tan{\theta_1}} = \frac{d-x}{\tan{\theta_2}}$$

So we can use this equality (ignoring $y$ completely for the moment) to solve for $x$. We start by cross multiplying:

\begin{align} x \tan{\theta_2} & = (d - x) \tan{\theta_1} \\ x \tan{\theta_2} & = d \tan{\theta_1} - x \tan{\theta_1} \\ x \tan{\theta_1} + x \tan{\theta_2} & = d \tan{\theta_1} \\ x (\tan{\theta_1} + \tan{\theta_2}) & = d \tan{\theta_1} \\ x & = \frac{d \tan{\theta_1}}{\tan{\theta_1} + \tan{\theta_2}} \end{align}

And since we know that $y = \frac{x}{\tan{\theta_1}}$ we plug in the equation we have for $x$ (which conveniently cancels the $\tan{\theta_1}$ term) to get:

$$y = \frac{d}{\tan{\theta_1} + \tan{\theta_2}}$$