计算地球平面地图上2点之间的最短路径 [英] Calculating shortest path between 2 points on a flat map of the Earth

查看:265
本文介绍了计算地球平面地图上2点之间的最短路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

当然,这条线不会是一条直线因为地球是弯曲的。 (例如,两个机场之间的最短距离是弯曲的。)编辑:谢谢所有答案的人 - 对不起,我选择解决方案很慢:/

解决方案

我从



h3>点之间的距离

坐标为
{lat1,lon1}和{lat2,lon2}的
两点之间的大圆距d为给出


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



一个数学上等价的公式,
不容易舍入
对于短距离的错误是:

code> 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),并且我们希望
点是沿着伟大的
圆形路线的一个小数f。 f = 0是点1. f = 1是
点2.这两点不能是
反对数(即lat1 + lat2 = 0和$ b $ abs(lon1-lon2)= pi),因为那么
路由是未定义的。中间
的经度和纬度然后被赋予


  A = sin((1-f )* 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)



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 :/

解决方案

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)

这篇关于计算地球平面地图上2点之间的最短路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆