已知起点经纬度及两点间距离、方位角如何求出终点经纬度?(附C#与python代码)

Get lat/long given current point, distance and bearing.

1、计算公式:
lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ))
lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2))
其中,

  • asin = arc sin()

  • d = distance (in any unit)

  • R = Radius of the earth (in the same unit as above)

and hence d/r = is the angular distance (in radians)

  • atan2(a,b) = arc tan(b/a)
  • θ is the bearing (in radians, clockwise from north);

2、C#代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{

    class Program
    {
        static void Main(string[] args)
        {    
            const dou
  • 1
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要实现已知一点的经纬度方位角距离来求另一点,可以使用C/C++编程语言。 首先,需要了解一些基本的地理坐标计算公式。在地球上,我们可以将经度和纬度表示为弧度(radians)。经度的范围是从-π到+π,而纬度的范围是从-π/2到+π/2。 对于已知的点A,经度为lonA,纬度为latA,方位角为bearing,距离为distance。首先,我们将经度和纬度转换为弧度形式: double lonA_rad = lonA * M_PI / 180; // 将经度转换为弧度 double latA_rad = latA * M_PI / 180; // 将纬度转换为弧度 接下来,我们可以使用以下公式来计算另一点的经纬度: double angular_distance = distance / earth_radius; // 将距离转换为角距离 double latB_rad = asin(sin(latA_rad) * cos(angular_distance) + cos(latA_rad) * sin(angular_distance) * cos(bearing)); double lonB_rad = lonA_rad + atan2(sin(bearing) * sin(angular_distance) * cos(latA_rad), cos(angular_distance) - sin(latA_rad) * sin(latB_rad)); 最后,我们将得到的经度和纬度转换为度数形式: double lonB = lonB_rad * 180 / M_PI; // 将经度转换为度数 double latB = latB_rad * 180 / M_PI; // 将纬度转换为度数 这样,我们就可以得到点B的经度和纬度。 注意:在上述代码中,earth_radius是地球的半径,通常约为6371千米。M_PI是C/C++提供的π值,可以在cmath头文件中找到。 以上就是用C/C++实现已知一点经纬度方位角距离求另一点的方法。希望对您有帮助。 ### 回答2: C/C++语言可以使用数学公式来实现已知一点的经纬度方位角距离来求另一点的计算。 首先,我们可以使用球面坐标系中的公式来计算目标点的经纬度。假设已知的点的经度为lon1,纬度为lat1,方位角为angle,距离为distance。经度的取值范围为[-180, 180],纬度的取值范围为[-90, 90]。 1. 首先,将角度转换为弧度:angle = angle * PI / 180 2. 根据方位角距离计算目标点的纬度:lat2 = asin(sin(lat1) * cos(distance / R) + cos(lat1) * sin(distance / R) * cos(angle)) 其中,R为地球的半径,通常取6371km。 3. 根据方位角距离计算目标点的经度:lon2 = lon1 + atan2(sin(angle) * sin(distance / R) * cos(lat1), cos(distance / R) - sin(lat1) * sin(lat2)) 最后,将弧度转换为角度:lon2 = lon2 * 180 / PI,lat2 = lat2 * 180 / PI 这样就可以使用C/C++代码实现已知一点的经纬度方位角距离来求另一点的计算。具体实现时,可以编写一个函数,接收已知点的经度、纬度、方位角距离作为参数,返回计算得到的目标点的经度和纬度。 ### 回答3: C/C++中可以使用数学函数库来实现已知一点的经纬度方位角距离,求另一点的坐标。 首先,我们需要包含数学函数库,例如"math.h"。 ```c #include <math.h> ``` 然后,我们可以定义一个函数,用于计算另一点的经纬度。 ```c void calculatePoint(double lat1, double lon1, double brng, double distance, double *lat2, double *lon2) { double radius = 6371; // 地球的半径,单位:公里 double angDistance = distance / radius; // 距离转化为弧度 // 将经度和纬度转化为弧度 double lat1Rad = lat1 * M_PI / 180; double lon1Rad = lon1 * M_PI / 180; double brngRad = brng * M_PI / 180; // 计算纬度和经度的新值 double lat2Rad = asin(sin(lat1Rad) * cos(angDistance) + cos(lat1Rad) * sin(angDistance) * cos(brngRad)); double lon2Rad = lon1Rad + atan2(sin(brngRad) * sin(angDistance) * cos(lat1Rad), cos(angDistance) - sin(lat1Rad) * sin(lat2Rad)); // 转化为度数 *lat2 = lat2Rad * 180 / M_PI; *lon2 = lon2Rad * 180 / M_PI; } ``` 在主函数中,我们可以调用calculatePoint函数,并传入已知经纬度方位角距离,获取计算后的另一点的坐标。 ```c #include <stdio.h> int main() { double lat1 = 40.7128; // 已知点的纬度 double lon1 = -74.0060; // 已知点的经度 double brng = 45; // 方位角 double distance = 100; // 距离 double lat2, lon2; // 存储计算后的另一点的经纬度 calculatePoint(lat1, lon1, brng, distance, &lat2, &lon2); printf("另一点的经纬度:%.4f, %.4f\n", lat2, lon2); return 0; } ``` 这样,我们就可以通过已知经纬度方位角距离,使用C/C++来计算另一点的经纬度坐标。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值