我如何找出用户是否在一起

问题描述 投票:-1回答:1

可以在这样的用户gps之间进行比较33.2160872、90.2160872、55.2160872并找出它们是否靠近

javascript php html gps
1个回答
1
投票

要查找两个用户之间的二维距离(不考虑高度差),您可以应用距离公式:

Distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)

用户位置为(x2, y2)(x1, y1)的地方。

伪代码示例:

float getDistance(float x1, float y1, float x2, float y2) {
    return sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
}

要查找用户是否彼此靠近,您需要具有某种基线距离,这些基线距离应被认为足够“靠近”,并检查返回的数字是否小于该距离。

© www.soinside.com 2019 - 2024. All rights reserved.