如何计算短&通过半正矢进行长途传输?
我正在寻找一种方法来计算地球上两点之间的距离。我们被告知使用半正矢,它可以很好地计算两点之间的最短距离。
现在,我想计算点之间的“长距离”。假设你有 2 个城市,A 在西部,B 在东部。如果我向东绕地球一周,然后从西到达 A,我想知道从 B 到 A 的距离。
我尝试更改半正弦函数中的一些内容,但似乎不起作用。
有人知道我如何通过对半正弦函数进行小调整来简单地做到这一点吗?
这就是我现在使用的:
lat1, lat2, lng1, lng2 以弧度为单位
part1 = sin(lat2) * sin(lat1); 第 2 部分 = cos(lat2) * cos(lat1) * cos(lng1 - lng2);
距离 = 6378.8 * acos(部分 1 + 部分 2);
我的看法是,你可以在两个城市之间画一个绕地球的圆圈。长距离等于该圆的周长减去短距离。但与回答相反,圆的长度不等于地球的周长。这仅是赤道上 2 个点的情况。
总氮 杰罗恩
I am looking for a way to calculate the distance between 2 points on the globe. We've been told to use Haversine, which works fine to calculate the shortest distance between the 2 points.
Now, I'd like to calculate the "long distance" between to points. So suppose you have 2 cities, A in the west and B in the east. I want to know the distance from B to A if I would travel eastwards around the globe and then reach A coming from the west.
I've tried changing a couple of things in the haversine function, but doesn't seem to work.
Anyone know how I can simply do this using small adjustments to the haversine function?
This is what I'm using now:
lat1, lat2, lng1, lng2 are in radians
part1 = sin(lat2) * sin(lat1);
part2 = cos(lat2) * cos(lat1) * cos(lng1 - lng2);
distance = 6378.8 * acos(part1 + part2);
The way I see it is that you can draw a circle around the globe between the 2 cities. The long distance the the circumference of that circle minus the short distance. But in contrary of what was replied, the circle's length is not equal to the earth's circumference. This is only the case for 2 points on the equator.
Tnx
Jeroen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
地球的周长约为 40,075 公里,计算出短距离并从中减去。
The circumference of the earth is approx 40,075KM, work out the short distance and subtract it from that.