本文介绍了如何使用方向角和速度来计算下一次的经纬度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我现在的位置({lat:x,lon:y})
,我知道我的速度和方向角;
如何在下一次预测下一个位置?

解决方案

首先,根据您当前的行程计算您将要旅行的距离速度和你已知的时间间隔(下一次):

 距离=速度*时间


$ b然后你可以用这个公式来计算你的新位置(lat2 / lon2):

  lat2 = asin(sin(lat1)* cos(d)+ cos(lat1)* sin(d)* cos(tc))
dlon = atan2(sin (tc)* sin(d)* cos(lat1),cos(d)-sin(lat1)* sin(lat2))
lon2 = mod(lon1-dlon + pi,2 * pi)-pi $对于Javascript中的实现,请参阅函数 LatLon.prototype.destinationPoint code>在



更新对于那些希望更加充实地实现上述内容的人来说,这里是以Javascript的形式:

  / ** 
*返回destin从给定点开始,已经在给定的初始方位上行进了给定距离
*。
*
* @param {number} lat - 以十进制度数表示的初始纬度(例如50.123)
* @param {number} lon - 十进制度数的初始经度(例如-4.321)
* @param {number}距离 - 行驶距离(米)。
* @param {number}方位 - 初始方位(以北为度)。
* @returns {array}目标点为[纬度,经度](例如[50.123,-4.321])$ ​​b $ b *
* @example
* var p = destinationPoint(51.4778 ,-0.0015,7794,300.7); // 51.5135°N,000.0983°W
* /
函数destinationPoint(lat,lon,distance,bearing){
var radius = 6371e3; //(平均)地球半径

var toRadians = function(v){return v * Math.PI / 180; };
var toDegrees = function(v){return v * 180 / Math.PI; };

//sinφ2=sinφ1·cosδ+cosφ1·sinδ·cosθ
//tanΔλ=sinθ·sinδ·cosφ1/cosδ-sinφ1·sinφ2
//参见mathforum.org /library/drmath/view/52049.html用于派生

varδ= Number(distance)/ radius; //以弧度表示的角距离
varθ= toRadians(Number(bearing));

varφ1= toRadians(Number(lat));
varλ1= toRadians(Number(lon));

varsinφ1= Math.sin(φ1),cosφ1= Math.cos(φ1);
varsinδ= Math.sin(δ),cosδ= Math.cos(δ);
varsinθ= Math.sin(θ),cosθ= Math.cos(θ);

varsinφ2=sinφ1*cosδ+cosφ1*sinδ*cosθ;
varφ2= Math.asin(sinφ2);
var y =sinθ*sinδ*cosφ1;
var x =cosδ - sinφ1*sinφ2;
varλ2=λ1+ Math.atan2(y,x);

return [toDegrees(φ2),(toDegrees(λ2)+540)%360-180]; // normalize to -180 .. + 180°
}


I have know my current position({lat:x,lon:y})and I know my speed and direction angle;How to predict next position at next time?

解决方案

First, calculate the distance you will travel based on your current speed and your known time interval ("next time"):

distance = speed * time

Then you can use this formula to calculate your new position (lat2/lon2):

lat2 =asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
dlon=atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(lat2))
lon2=mod( lon1-dlon +pi,2*pi )-pi

For an implementation in Javascript, see the function LatLon.prototype.destinationPoint on this page

Update for those wishing a more fleshed-out implementation of the above, here it is in Javascript:

  /**
  * Returns the destination point from a given point, having travelled the given distance
  * on the given initial bearing.
  *
  * @param   {number} lat - initial latitude in decimal degrees (eg. 50.123)
  * @param   {number} lon - initial longitude in decimal degrees (e.g. -4.321)
  * @param   {number} distance - Distance travelled (metres).
  * @param   {number} bearing - Initial bearing (in degrees from north).
  * @returns {array} destination point as [latitude,longitude] (e.g. [50.123, -4.321])
  *
  * @example
  *     var p = destinationPoint(51.4778, -0.0015, 7794, 300.7); // 51.5135°N, 000.0983°W
  */
  function destinationPoint(lat, lon, distance, bearing) {
     var radius = 6371e3; // (Mean) radius of earth

     var toRadians = function(v) { return v * Math.PI / 180; };
     var toDegrees = function(v) { return v * 180 / Math.PI; };

     // sinφ2 = sinφ1·cosδ + cosφ1·sinδ·cosθ
     // tanΔλ = sinθ·sinδ·cosφ1 / cosδ−sinφ1·sinφ2
     // see mathforum.org/library/drmath/view/52049.html for derivation

     var δ = Number(distance) / radius; // angular distance in radians
     var θ = toRadians(Number(bearing));

     var φ1 = toRadians(Number(lat));
     var λ1 = toRadians(Number(lon));

     var sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1);
     var sinδ = Math.sin(δ), cosδ = Math.cos(δ);
     var sinθ = Math.sin(θ), cosθ = Math.cos(θ);

     var sinφ2 = sinφ1*cosδ + cosφ1*sinδ*cosθ;
     var φ2 = Math.asin(sinφ2);
     var y = sinθ * sinδ * cosφ1;
     var x = cosδ - sinφ1 * sinφ2;
     var λ2 = λ1 + Math.atan2(y, x);

     return [toDegrees(φ2), (toDegrees(λ2)+540)%360-180]; // normalise to −180..+180°
  }

这篇关于如何使用方向角和速度来计算下一次的经纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 22:13