Let's say we have 2 locations (latitude,longitude) and each location has a radius (it may be different from each other), making a circle. How to check if these 2 circles are overlapping?
Check if the distance between the centers is smaller than the sum of the radii.
Say for circles A and B with radius Ar and Br respectively, and coordinates (Ax, Ay) and (Bx, By) respectively, the distance between the circles is
D = sqrt( (Ax - Bx)2 + (Ay - By)2 )
They overlap when
D < Ar + Br
There's a catch, however: the centers of the circles are placed on a sphere. The shortest distance between them is a straight line, beneath the sphere's surface. The distance between them following the surface will be larger. For instance, the distance between the North and South pole is 2 Earth radii, but the path on the surface will be 2π Earth radii. Also, these circles don't overlap. So, the above equations only hold when the distances are relatively small.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With