7

I want to find the intersection points of two Locations in Android.

I don't want to consider cases where the circles as shown in the Figure don't intersect or are included or are completely overlapping.

My problem is that the Location is given in degree and the radius (accuracy) is given in meter. I do not know how to mix those Units.

In my case the environment is Android, but the Problem is not Android specific.

Locations with Radiuses in m

AlexWien
  • 28,470
  • 6
  • 53
  • 83
Nick Russler
  • 4,608
  • 6
  • 51
  • 88
  • I think you are searching for [trilateration](http://stackoverflow.com/questions/27657437/finding-point-between-two-geo-locations-of-beacons),here you have a [function](https://github.com/hrskrs/UtilsCollection/blob/master/app/src/main/java/com/hrskrs/utilscollection/Utils/BeaconUtils.java) for that in `java` – hrskrs Jul 06 '15 at 16:36

1 Answers1

4

You have to convert latitdue, longitude to a cartesian coordinate system, with unit meters.
This is done using a Cyclindrical equidistant projection with center latitude = (latitudeCircle1 + latCircle2) / 2.0. (same for center longitude)

(http://mathworld.wolfram.com/CylindricalEquidistantProjection.html)

In the link above to get a meter based system you have yet to multiply with the constant "meterPerDegreeAtEquator" which is 40000000 / 360.0

Now you have coordinates x,y as you had in school.

Then you calculate the circle intersection points as learned in school, or as found somewhere on the web. E.g here: https://math.stackexchange.com/questions/256100/how-can-i-find-the-points-at-which-two-circles-intersect

Then you convert the cartesian intersection points back to lat, lon using the inverse projection.

This works for a distance between the two circles not more than 10-100km.

Note: Below common error, which I saw in the discussion with your sample code: Please note that x is related to longitude, and y to latitude. Although we say lat/long. In such transformation formulas you should use long,lat order in paramter names etc. See also Lat Long or Long Lat

Community
  • 1
  • 1
AlexWien
  • 28,470
  • 6
  • 53
  • 83
  • reference links, http://math.stackexchange.com/questions/256100/how-can-i-find-the-points-at-which-two-circles-intersect and http://www.analyzemath.com/CircleEq/circle_intersection.html – tyczj Jul 06 '15 at 16:21
  • Thanks for the circle math ref link. – AlexWien Jul 06 '15 at 16:23
  • That sounds very good, which phi (from the formula on wolframalpha) would you recommend? – Nick Russler Jul 06 '15 at 16:37
  • as told phi = (lat1 + lat2) / 2.0; phi is the reference latitude, or projection center. This set the projetion center in the middle, so the projection center ideal for the both circles. – AlexWien Jul 06 '15 at 16:38
  • I thought lambda_0 = (lat1 + lat2) / 2 ? – Nick Russler Jul 06 '15 at 16:40
  • lambda_0 = (longitude1 + longitide2) / 2.0; which is the center (longitude) – AlexWien Jul 06 '15 at 16:43
  • Just make sure: the formula (cos() uses radians,) while lat, lon from GPS are in degrees, You have to convert in the real code. – AlexWien Jul 06 '15 at 16:45
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/82522/discussion-between-nick-russler-and-alexwien). – Nick Russler Jul 06 '15 at 17:44