两个城市之间的经纬度距离方程是什么?

what is the equation of longitude and latitude distance between 2 cities

本文关键字:距离 经纬度 方程 是什么 城市之间 两个      更新时间:2023-10-16

我需要c++中计算一个城市的经纬度和另一个城市的经纬度之间距离的方程,oop

假设你正在寻找一个大的弧距(鸟类飞行时最直接的路线),你需要的是哈弗斯公式:https://en.wikipedia.org/wiki/Haversine_formula

一个示例应用程序(用您选择的任何编程语言重写都应该是微不足道的):

    dlon = lon2 - lon1
    dlat = lat2 - lat1
    a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
    c = 2 * a * tan2(sqrt(a), sqrt(1-a))
    d = R * c //where R is the radius of the Earth