计算起点和终点之间的坐标

发布于 2024-09-05 05:16:43 字数 162 浏览 12 评论 0原文

给定..

1 - 起点 GPS 坐标,
2 - 终点 GPS 坐标,
3 - 物体行进的速度,
4 - 知道行程轨迹将是一条直线...

我如何计算出 n 分钟后我的 GPS 坐标将是什么?也就是说,如何计算我在行程开始后到行程结束前的某个时间点的位置?

Given..

1 - The start-point GPS coordinates,
2 - The end-point GPS coordinates,
3 - The speed at which the object is travelling,
4 - Knowing that the trip trajectory will be a straight line...

How can I calculate what my GPS coordinated will be in n minutes' time? That is to say, how can I calculate my position at a given time after the trip has started before the trip has ended?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌生 2024-09-12 05:16:44

您需要使用 Thaddeus Vincenty 公式

这将为您提供两个 GPS 坐标之间的距离(经度/纬度)。

然后简单地

  Time = [Distance] in m / [Speed] in m/s

假设匀速,这是一个粗略的估计。

You need to use the Thaddeus Vincenty Formulae

This will give you the distance between two GPS co-ordinates (lon/lat).

Then simply do

  Time = [Distance] in m / [Speed] in m/s

Assuming uniform speed, its a gross estimation.

终难愈 2024-09-12 05:16:43

这种方法仅对于小距离来说足够准确,因为没有考虑地球的曲率。您可以将伪球坐标转换为平面坐标,但对于距离较大且需要精度的情况,不同的方法可能会更好。

关键是计算起点和终点之间的总距离。您可以使用欧几里得距离,但是,如上所述,这仅对于较小的距离来说相当准确:

distance = sqrt((end.x - start.x) ** 2 + (end.y - start.y) ** 2)

然后您就知道走完整个距离需要多长时间:

timeToTravelDistance = distance / speed

由此,您可以计算该距离的百分比在给定时间的情况下,您从startend行驶的距离:

percentageTraveled = time / timeToTravelDistance

最后,插值:

result.x = start.x * (1 - percentageTraveled) + end.x * percentageTraveled
result.y = start.y * (1 - percentageTraveled) + end.y * percentageTraveled

This method is accurate enough only for small distances, because the curvature of the Earth is not accounted for. You can convert pseudo-spherical coordinates to planar coordinates, but a different method would probably be better for cases where the distance is large and accuracy is needed.

The key is to calculate the total distance between the start and end points. You can use Euclidean distance but, as stated, this is reasonably accurate only for smaller distances:

distance = sqrt((end.x - start.x) ** 2 + (end.y - start.y) ** 2)

You then know how long it will take to travel the entire distance:

timeToTravelDistance = distance / speed

From this, you can calculate the percentage of the distance you have traveled from start to end given time:

percentageTraveled = time / timeToTravelDistance

Finally, interpolate:

result.x = start.x * (1 - percentageTraveled) + end.x * percentageTraveled
result.y = start.y * (1 - percentageTraveled) + end.y * percentageTraveled
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文