Reputation: 83
I would like to calculate a point (lat and lon) in three cases:
For 1. case I already have a solution Trilateration Method Android Java
But for 2. case I got nothing.
Has anyone an idea, how can I calculate this point knowing two other?
Are there a Java libraries (or at least a pseudocode) for similar "geo" tasks?
Here a picture for two-point problem. One of them is behind a wall, so I only make a decision, which of two is better (using Bluetooth Low Energy I can do it comparing RSSI)
Upvotes: 1
Views: 2665
Reputation: 15842
You need to know three points and the distance to your location to define a point. Have a look at the following picture:
The situation is general. For any two points, you can draw them as on the above picture. Then for known distance y
from the left one, you find points that are x
from the right one, and these are possible positions of the desired location.
Two distances to two points do not define one point. They give two points.
Question: how to calculate those points? Use Pythagoras theorem.
Assume two points O1(x1,y1) and O2(x2,y2) and desired points P3, P4.
(x4-x1)^2 + (y4-y1)^2 = dist1
(x3-x1)^2 + (y3-y1)^2 = dist1
(x4-x1)^2 + (y4-y1)^2 = dist2
(x3-x1)^2 + (y3-y1)^2 = dist2
You have 4 equations and 4 unknows. Calculate. Then hope for one point being in a different country than the phone the app is installed on. The hints can be found here.
After seeing the update of the question, I can tell you that one of the points will have coordinates outside of the room which can be easily checked by comparing points' coordinates to max/min x/y.
Upvotes: 1