问题描述
在导航应用中寻找资源或算法来计算以下内容:
Looking for resources or algorithm to calculate the following in a navigation app:
如果我当前的 GPS 位置是 (0,0),并且我以每小时 15 英里的速度前进 32 度,我如何计算我在 10 秒内的位置?
If my current GPS position is (0,0) and I'm heading 32 degrees at 15 miles per hour, how can I calculate what my position will be in 10 seconds?
即:GPSCoordinate predictCoord = GPSCoordinate.FromLatLong(0, 0).AddByMovement(32, 15, TimeSpan.FromSeconds(10));
当前代码基于以下答案:
Current code based on answer below:
public GPSCoordinate AddMovementMilesPerHour(double heading, double speedMph, TimeSpan duration)
{
double x = speedMph * System.Math.Sin(heading * pi / 180) * duration.TotalSeconds / 3600;
double y = speedMph * System.Math.Cos(heading * pi / 180) * duration.TotalSeconds / 3600;
double newLat = this.Latitude + 180 / pi * y / earthRadius;
double newLong = this.Longitude + 180 / pi / System.Math.Sin(this.Latitude * pi / 180) * x / earthRadius;
return GPSCoordinate.FromLatLong(newLat, newLong);
}
推荐答案
这是完整的参数答案:
变量:
heading
:航向(即从方位角 0° 向后的角度,以度为单位)speed
:速度(即速度向量的范数,以英里/小时为单位)lat0
,lon0
: 以度为单位的初始坐标dtime
: 从起始位置开始的时间间隔,以秒为单位lat
,lon
: 以度为单位的预测坐标pi
: pi 常数 (3.14159...)Rt
: 地球半径 miles(6378137.0 米,相当于 3964.037911746 英里)
heading
: heading (i.e. backwards angle from azimuth 0°, in degrees)speed
: velocity (i.e. norm of the speed vector, in miles/hour)lat0
,lon0
: initial coordinates in degreesdtime
: time interval from the start position, in secondslat
,lon
: predicted coordinates in degreespi
: the pi constant (3.14159...)Rt
: Earth radius in miles (6378137.0 meters which makes 3964.037911746 miles)
在一个(东、北)局部坐标系中,时间间隔后的位置是:
In an (East, North) local frame, the position after the time interval is :
x = speed * sin(heading*pi/180) * dtime / 3600;
y = speed * cos(heading*pi/180) * dtime / 3600;
(坐标以英里为单位)
您可以从那里计算 WGS84 帧中的新位置(即纬度和经度):
From there you can compute the new position in the WGS84 frame (i.e. latitude and longitude) :
lat = lat0 + 180 / pi * y / Rt;
lon = lon0 + 180 / pi / sin(lat0*pi/180) * x / Rt;
更正最后一行:*sin(phi) 为/sin(phi)
Edit : corrected the last line : *sin(phi) to /sin(phi)
这篇关于GPS/GIS 计算:基于运动/mph 预测未来位置的算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!