计算地球平面地图上两点之间的最短路径

发布于 2024-08-13 21:14:26 字数 118 浏览 7 评论 0原文

如何绘制代表地球平面地图上两点之间最短距离的曲线?

当然,这条线不会是直线,因为地球是弯曲的。 (例如,两个机场之间的最短距离是弯曲的。)

编辑:感谢所有答案 - 抱歉我选择解决方案很慢:/

How do you draw the curve representing the shortest distance between 2 points on a flat map of the Earth?

Of course, the line would not be a straight line because the Earth is curved. (For example, the shortest distance between 2 airports is curved.)

EDIT: THanks for all the answers guys - sorry I was slow to choose solution :/

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

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

发布评论

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

评论(2

暮年 2024-08-20 21:14:26

我从航空处方集获得此类信息。

在这种情况下:

点之间的距离

之间的大圆距离 d
有坐标的两点
给出 {lat1,lon1} 和 {lat2,lon2}
作者:

d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))

数学上等价的公式,
较少受到舍入的影响
短距离误差为:

d=2*asin(sqrt((sin((lat1-lat2)/2))^2 +
cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))

并且

大圆上的中间点

在前面的部分中我们发现
大圆上的中间点
给定交叉纬度或
经度。在这里我们找到点
(lat,lon) 的给定分数
它们之间的距离(d)。假设
起点是 (lat1,lon1) 并且
最后一点 (lat2,lon2) 我们想要
沿着伟大的点a分数f
循环路线。 f=0 是点 1。f=1 是
第 2 点. 这两点不能
对映体(即 lat1+lat2=0 且
abs(lon1-lon2)=pi) 因为这样
路线未定义。中间体
然后给出纬度和经度
作者:

<前><代码> A=sin((1-f)*d)/sin(d)
B=sin(f*d)/sin(d)
x = A*cos(lat1)*cos(lon1) + B*cos(lat2)*cos(lon2)
y = A*cos(lat1)*sin(lon1) + B*cos(lat2)*sin(lon2)
z = A*sin(lat1) + B*sin(lat2)
纬度 = atan2(z,sqrt(x^2+y^2))
lon=atan2(y,x)

I get this sort of information from the Aviation Formulary.

In this case:

Distance between points

The great circle distance d between
two points with coordinates
{lat1,lon1} and {lat2,lon2} is given
by:

d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))

A mathematically equivalent formula,
which is less subject to rounding
error for short distances is:

d=2*asin(sqrt((sin((lat1-lat2)/2))^2 +
cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))

And

Intermediate points on a great circle

In previous sections we have found
intermediate points on a great circle
given either the crossing latitude or
longitude. Here we find points
(lat,lon) a given fraction of the
distance (d) between them. Suppose the
starting point is (lat1,lon1) and the
final point (lat2,lon2) and we want
the point a fraction f along the great
circle route. f=0 is point 1. f=1 is
point 2. The two points cannot be
antipodal ( i.e. lat1+lat2=0 and
abs(lon1-lon2)=pi) because then the
route is undefined. The intermediate
latitude and longitude is then given
by:

    A=sin((1-f)*d)/sin(d)
    B=sin(f*d)/sin(d)
    x = A*cos(lat1)*cos(lon1) +  B*cos(lat2)*cos(lon2)
    y = A*cos(lat1)*sin(lon1) +  B*cos(lat2)*sin(lon2)
    z = A*sin(lat1)           +  B*sin(lat2)
    lat=atan2(z,sqrt(x^2+y^2))
    lon=atan2(y,x)
几味少女 2024-08-20 21:14:26

要将地球表面两点之间的 3D 最短路径绘制到地球表面的 2D 地图上,您必须知道地球的 3D 表面如何投影到相关的 2D 地图上。如果您知道所使用的投影,则只需将其应用于 3D 最短路径即可将其投影到 2D 地图上。如果您不知道所使用的确切投影,但可以通过某种接口访问它(即输入 3D 表面坐标 -> 输出 2D 地图坐标),您可以沿 3D 表面路径采样点,生成它们对应的点通过所述界面映射点,然后用线段/贝塞尔曲线/等近似投影路径。通过投影的样本点。

To draw the 3D shortest path between two points on Earth's surface onto a 2D map of Earth's surface, you have to know how the 3D surface of Earth was projected onto the 2D map in question. If you know the projection used, you just need to apply it to the 3D shortest path to project it onto the 2D map. If you don't know the exact projection used, but have access to it through some sort of interface (ie. input 3D surface coords -> output 2D map coords), you could sample points along the 3D surface path, generate their corresponding map points through said interface, and then approximate the projected path with line segments/bezier curves/etc. through the projected sample points.

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