PHP从一个静止对象到其周围多个对象的最小距离

PHP从一个静止对象到其周围多个对象的最小距离,php,Php,我正在解决一个问题,我有一个对象A(lat,lon)和不同的对象B(lat,lon)C(lat,lon)D(lat,lon)等等。我想计算哪个对象最接近对象A。对象的数量未知。有人能告诉我怎么做吗 function minDistance(obj A, obj B, obj C .....){ compute distance between obj A and all the arguments and return the obj with minimum distance to obj

我正在解决一个问题,我有一个对象A(lat,lon)和不同的对象B(lat,lon)C(lat,lon)D(lat,lon)等等。我想计算哪个对象最接近对象A。对象的数量未知。有人能告诉我怎么做吗

function minDistance(obj A, obj B, obj C .....){
compute distance between obj A and all the arguments and return the obj  with minimum distance to obj A here(I prefer Haversine)
}
“毕达哥拉斯定理”怎么样?:-)


从概念上讲,每对对象。。。(A,B),(A,C),(A,D)等是直角三角形的斜边点。因此,它们之间的距离由毕达哥拉斯定理给出。

如果你可以假设使用x,y网格,这只是两点之间形成的直角三角形的假设。如果你需要考虑地球的曲率,你需要哈弗斯线。