Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find intersection of two Locations

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

like image 972
Nick Russler Avatar asked Jul 06 '15 16:07

Nick Russler


People also ask

What is the formula of intersection?

Point of intersection means the point at which two lines intersect. These two lines are represented by the equation a1x + b1y + c1= 0 and a2x + b2y + c2 = 0, respectively.

What is the formula for the intersection of two lines?

The point of intersection formula is used to find the point of intersection of two lines, meaning the meeting point of two lines. These two lines can be represented by the equation a1x+b1y+c1=0 a 1 x + b 1 y + c 1 = 0 and a2x+b2y+c2=0 a 2 x + b 2 y + c 2 = 0 , respectively.


1 Answers

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

like image 155
AlexWien Avatar answered Sep 28 '22 16:09

AlexWien