简体   繁体   English

地理位置-如何检查2个圆圈是否重叠

[英]Geolocations - How to check if 2 circles are overlapping

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. 假设我们有2个位置(纬度,经度),每个位置都有一个半径(可能彼此不同),形成一个圆。 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 A r and B r respectively, and coordinates ( A x , A y ) and ( B x , B y ) respectively, the distance between the circles is 假设圆A和圆B的半径分别为A rB r ,坐标分别为( A xA y )和( B xB y ),则圆之间的距离为

D = sqrt( (A x - B x ) 2 + (A y - B y ) 2 ) D = sqrt((A x -B x2 +(A y -B y2

They overlap when 它们重叠时

D < A r + B r D <A r + B r

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 Earth radii. 例如,北极和南极之间的距离为2个地球半径,但表面上的路径将为2π个地球半径。 Also, these circles don't overlap. 而且,这些圆圈不会重叠。 So, the above equations only hold when the distances are relatively small. 因此,以上等式仅在距离相对较小时成立。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM