I'm trying to create a logic for GeoLocation mapping.
I am trying to "triangulate" a location on a unscaled illustrative map using list of GPS locations I acutally have mapped (so a list of GPS coordinates vs their relative (x,y) coordinates on the map) and the GPS coordinate of the device. I have tried to achieve this by finding the three closest point that is known, and the actual distance to these locations (by using the GPS coordinates). Given the actual distances can only be used as indicative "ratios" of the distance, I have tackled this problem as a problem of intersecting circles, as below.
Problem:
$(x_a-x)^2+(y_a-y)^2=(r*a)^2$
$(x_b-x)^2+(y_b-y)^2=(r*b)^2$
$(x_c-x)^2+(y_c-y)^2=(r*c)^2$
known variables: $x_a, x_b, x_c, y_a, y_b, y_c, a, b, c$
unknown variables: $x, y, r$
final solution: solve for the $x$ and $y$ for $r$ that gives a unique solution.
Thanks to some help here I found out this fails for some cases (namely when one of the places are too close (which is very possible) and it gives very little freedom for the other two circles to grow.
What are possible other ways the problem can be tackled?
expand the squares:$$x^2 - 2x_ax +x_a^2 +y^2 - 2y_ay +y_a^2 = r^2a^2$$. Take the difference between any two lines: $$x_a^2 + y_a^2 - x_b^2 - y_b^2 = r^2(a^2-b^2) + 2(x_a - x_b)x + 2(y_a - y_b)y$$ Do this with all three pairs of equations and you have three linear equations in $x, y, r^2$. Solve them as you would any system of three linear equations. Take the square root of $r^2$ and you are done (without need to stop at the intermediary solution).