1

I would like to calculate a point (lat and lon) in three cases:

  1. Three points are available with their distances to my location
  2. Two points are available with their distances to my location

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) two points problem

Community
  • 1
  • 1
  • this is as only case of calculating circle intersection, explained here: http://mathworld.wolfram.com/Circle-CircleIntersection.html Your case can be made exactly as shown in this link since you can assume P1 and P2 are on the same axis – Akka Jaworek Sep 28 '16 at 08:17

1 Answers1

1

You need to know three points and the distance to your location to define a point. Have a look at the following picture:

enter image description here

enter image description here

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.

Community
  • 1
  • 1
xenteros
  • 15,586
  • 12
  • 56
  • 91
  • You are correct, however it is possible to verify which one of the two points is desired one if you specify enviroment (walls etc.). You can calculate these two points by calculating crossing points of two circles with radius of your measured distance – Akka Jaworek Sep 28 '16 at 07:57
  • @AkkaJaworek you are right...If I got these two points, then I can make a decision to choose one of them. – Morgan Chane Sep 28 '16 at 07:58
  • If you find my idea helpful (it's sufficient) feel free to upvote the answer and mark as a solution by clicking on the gray tick below the score. @MorganChane – xenteros Sep 28 '16 at 08:09
  • @xenteros I'm about to code it, and I'm doing a "field experiment". and then solving an equation system... – Morgan Chane Sep 28 '16 at 09:22
  • @MorganChane http://stackoverflow.com/questions/3349125/circle-circle-intersection-points might be helpful – xenteros Sep 28 '16 at 09:23