[英]Geolocations - How to check if 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 r和B r ,坐标分别为( A x , A y )和( B x , B y ),则圆之间的距离为
D = sqrt( (A x - B x ) 2 + (A y - B y ) 2 ) D = sqrt((A x -B x ) 2 +(A y -B y ) 2 )
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 2π 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.