Simple but confusing trigonometry to find angle (PID control for autonomous car)

143 Views Asked by At

I have been given some math (picture below) with no explanation that will allow me to find the distance from a wall to an autonomous car is that I'm programming. But I am unsure of how the angle $\alpha$ is retrieved using trigonometry. Can someone explain that first portion if they understand how it is obtained?

enter image description here

2

There are 2 best solutions below

0
On

I think that you will find the following image helpful:

Modified diagram

Now simply note that in the pink triangle, tangent is opposite over adjacent.

0
On

Use the cosine formula for the two right triangles in your diagram,

$$AB = b\cos\alpha= a \cos (\alpha+\theta)$$

Then, use the identity

$$\cos (\alpha+\theta)=\cos\alpha \cos\theta -\sin\alpha \sin\theta$$

to get

$$b\cos\alpha= a \cos\alpha \cos\theta -a\sin\alpha \sin\theta$$

Divide by $\cos\alpha$ to obtain

$$\tan\alpha = \frac{ a\cos\theta-b}{a\sin\theta}$$

As a result, the distance is

$$AB = \frac{ab\sin\theta}{\sqrt{a^2-2ab\cos\theta+b^2}}$$