Get a third point (lat, lng) from two given

312 Views Asked by At

I have two points as follow (the distance between them is variable):

two given points with variable distance

I need to get a third as shown:

Third point?

The two first points change all the time, including the distance between them. My problem: I have many points in a road got from a GPS, and a photo taken from every point. I need to write a script to put a new point to the right ahead from the point of view of the camera positioned at the point two. Many years have passed since my high school, and I can't remember trigonometry anymore. Does anybody know a formule to get this point? Thank you!

1

There are 1 best solutions below

2
On

To get the distance and angle from the first point to the third point:

Pictorially, draw a line from the third point to the line passing through the first two points so that it hits perpendicularly. This distance is 2.5m by the 30-60-90 triangle identity. Then the distance from that point where the two lines intersect to the second point is $2.5 \sqrt3$. Add this to the variable distance between the first two points, call this summed distance X. Use Pythagorean theorem so the total distance is $T=\sqrt{2.5^2+{X}^2}$.

To get the angle use law of cosines. Take the square of the distance X and add it to the square of distance T and subtract $2.5^2$. Then divide all of this by 2XT. Finally take the arccosine of all of it. That should be the angle from the line passing through the first two points to the line passing through the first and the third. The formula is: \begin{equation*} A = \arccos\left(\frac{X^2+T^2-2.5^2}{2XT}\right) \end{equation*}