两个移动物体与纬度/经度坐标的交点 [英] Intersection of two Moving Objects with Latitude/Longitude Coordinates

查看:143
本文介绍了两个移动物体与纬度/经度坐标的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题到现在为止我还不能解决,尽管我已经阅读了几篇文章 - 希望有人能在这里帮助。



事实(知道变量) p>


  • 地球表面上的两个移动物体,两者都具有当前已知的经度/纬度坐标。

  • 速度这两个对象都是已知的(以m / s为单位)。

  • 一个对象的方向(角度)是已知的。



现在我要计算与另一个移动物体相交所需的第二个移动物体的方向(角度)。

由于物体之间的距离很小(在5-20公里范围内),并且不需要非常高的精度,因此可以将地球表面视为飞机。



因此,我已经尝试使用这个伟大的库:



如果拦截发生在时间 t,那么追迹者和目标所经过的距离就是tv 。我们还知道在时间0处追踪器和目标之间的距离d,并且角度α连接追踪器和目标的线段与目标的轨迹之间。如果我们将这些输入



正如您在上面的图片中看到的,如果追踪者比目标慢,如果目标移向追踪者(蓝色射线与绿色曲线相交),则有潜在的两个拦截点,但是如果目标从追踪者移开则没有拦截点。在二次公式中使用加法给出第一个拦截点(使用减法将给出第二个拦截点)。

然后,我们可以计算目标在时间点t之后的位置,它是拦截点,以及从追踪器到这个点的方向。




下面的JavaScript代码片段演示了这种方法以及来自两个图像的值。它以标准JavaScript方向(0 =右,π/ 2 =向上,π=左, - π/ 2 =向下)在弧度中使用角度。追踪器和目标速度相等(曲线是直线)的情况可以使用等腰三角定理,因为否则它将导致二次方程中除零。

function intercept(chaser,target){var dist = distance(chaser,目标); var dir = direction(chaser,target); var angle = Math.PI + dir - target.dir;如果(chaser.vel == target.vel){if(Math.cos(angle)<0)返回undefined; //等于速度的情况: // INTERCEPTION IMPOSSIBLE return(dir + angle)%(Math.PI * 2); } //一般情况:按照余弦规则和二次方程求解var a = Math.pow(chaser.vel,2) - Math.pow(target.vel,2); var b = 2 * dist * target.vel * Math.cos(angle); var c = -Math.pow(dist,2); var disc = Math.pow(b,2) - 4 * a * c;如果(光盘< 0)返回undefined; //截取不可能var time =(Math.sqrt(disc)-b)/(2 * a); var x = target.x + target.vel * time * Math.cos(target.dir); var y = target.y + target.vel * time * Math.sin(target.dir);返回方向(chaser,{x:x,y:y});函数距离(p,q){return Math.sqrt(Math.pow(p.x-q.x,2)+ Math.pow(p.y - q.y,2)); }函数方向(p,q){返回Math.atan2(q.y - p.y,q.x - p.x); }} var chaser = {x:196,y:-45,vel:100}; var target = {x:139,y:-312,vel:75,dir:0.1815142422}; document.write(intercept(chaser,目标)+< br>); // -1.015 radians = -58.17 degreesvar chaser = {x:369,y:-235,vel:37.5}; var target = {x:139,y:-376, (例如:vel:75,dir:0.1815142422}; document.write(intercept(chaser,target)+< br>); // -1.787弧度= -102.4度

其他截取点 绿色曲线将2D平面有效地划分为目标首先到达的区域和追赶者首先到达的区域。如果你希望追逐者和目标以恒定速度移动并相撞(想象一下,例如在一艘正在移动的船上发射一枚鱼雷),那么你会瞄准曲线上的一个点,这两个点将在同一时间到达,就像上面解释过。然而,如果追逐者可以到达一个点并在那里等待目标到达(想象一下,例如一个人试图搭乘巴士),那么每个点目标在追踪区内的轨迹可能是拦截点。

在第一张图片(较慢的目标)中,曲线是围绕目标的一个圆圈,一旦目标移出该圆圈(指向截取点的右侧在粉红色),追逐者总是可以先到达并等待目标。如果在追踪者或目标速度不恒定的情况下需要安全余量,这可能很有用。在第二幅图像(更快的目标)中,曲线是追踪者周围的一个圆,并且该圆内目标轨迹上的每个点都可能是截取点。追赶者可以例如垂直于目标的轨迹移动,以便将行进的距离最小化,或瞄准第一个和最后一个拦截点之间的中点以最大化等待时间。

This issue I can't really solve till now although I read through several articles already - hope somebody can help here.

Facts (know variables):

  • Two moving objects on earth surface, both with current know latitude/longitude coordinates.
  • The speed of both objects is know as well (in m/s).
  • The direction (angle) of one object is know.

Now I want to calculate the direction (angle) of the second moving object needed to intersect with (hit) the other moving object.

As the distance between the objects is small (in the range of only 5-20 km) and no very high accuracy is needed, it is OK to consider the earth surface as plane.

Therefore I already tried working with this great library: http://www.codeproject.com/Articles/990452/Interception-of-Two-Moving-Objects-in-D-Space

But I don't really get that to work as I don't know how to convert speed in m/s back and forth to latitude/longitude velocity vectors.

To better understand the problem here an example with values:

  • Moving object 1 (runner):
    • Current location: latitude: 38.565, longitude: -98.513
    • Speed: 100 m/s
    • Direction: 270°
  • Moving object 2 (chaser):
    • Current location: latitude: 38.724, longitude: -98.449
    • Speed: 150 m/s
    • Direction: To be calculated

Any help on that would be highly appreciated, thanks in advance!

解决方案

If the distances are small and you convert the latitude/longitude coordinates to x,y coordinates on a flat plane as you suggest, using e.g. the answers to this question, then the math needed to solve this problem is quite straightforward.

The image below shows the location of chaser and target at time 0 (red and blue dot), their velocity (the circles show their range after time 1, 2, 3...) and the trajectory of the target (blue ray).

The green curve contains all locations where target and chaser could be at the same moment if they keep moving at their current velocity. The intersection of this curve with the target's trajectory is the interception point (pink dot).

If the interception happens after time t, then the distance travelled by chaser and target is t.vc and t.vt. We also know the distance d between the chaser and target at time 0, and the angle α between the line segment connecting chaser and target and the target's trajectory. If we enter these into the cosine rule we get:

(t . vc)2 = (t . vt)2 + d2 - 2 . d . t . vt . cos(α)

Which transforms to this quadratic equation when we solve for time t:

(vc2 - vt2) . t2 + (2 . d . vt . cos(α)) . t - d2 = 0

If we solve this using the quadratic formula:

t = (- b ± √(b2 - 4 . a . c)) / (2 . a)
where:
a = vc2 - vt2
b = 2 . d . vt . cos(α)
c = - d2

a non-negative discriminant means interception is possible, and the root obtained by using addition in the quadratic formula is the first or only time of interception.

As you can see in the image above, if the chaser is slower than the target, there are potentially two interception points if the target moves towards the chaser (blue ray intersects with green curve), but none if the target moves away from the chaser. Using addition in the quadratic formula gives the first interception point (using subtraction would give the second).

We can then calculate the position of the target after time t, which is the interception point, and the direction from the chaser to this point.


The JavaScript code snippet below demonstrates this method, with the values from both images. It uses angles in radians in the standard JavaScript orientation (0 = right, π/2 = up, π = left, -π/2 = down). The case where the chaser and target have equal velocity (and the curve is a straight line) is solved using the isosceles triangle theorem, because otherwise it would lead to a division by zero in the quadratic equation.

function intercept(chaser, target) {
    var dist = distance(chaser, target);
    var dir = direction(chaser, target);
    var angle = Math.PI + dir - target.dir;
    // EQUAL VELOCITY CASE: SOLVE BY ISOSCELES TRIANGLE THEOREM
    if (chaser.vel == target.vel) {
        if (Math.cos(angle) < 0) return undefined; // INTERCEPTION IMPOSSIBLE
        return (dir + angle) % (Math.PI * 2);
    }
    // GENERAL CASE: SOLVE BY COSINE RULE AND QUADRATIC EQUATION
    var a = Math.pow(chaser.vel, 2) - Math.pow(target.vel, 2);
    var b = 2 * dist * target.vel * Math.cos(angle);
    var c = -Math.pow(dist, 2);
    var disc = Math.pow(b, 2) - 4 * a * c;
    if (disc < 0) return undefined;                // INTERCEPTION IMPOSSIBLE
    var time = (Math.sqrt(disc) - b) / (2 * a);
    var x = target.x + target.vel * time * Math.cos(target.dir);
    var y = target.y + target.vel * time * Math.sin(target.dir);
    return direction(chaser, {x: x, y: y});

    function distance(p, q) {
        return Math.sqrt(Math.pow(p.x - q.x, 2) + Math.pow(p.y - q.y, 2));
    }
    function direction(p, q) {
        return Math.atan2(q.y - p.y, q.x - p.x);
    }
}
var chaser = {x: 196, y: -45, vel: 100};
var target = {x: 139, y: -312, vel: 75, dir: 0.1815142422};
document.write(intercept(chaser, target) + "<br>");// -1.015 radians = -58.17 degrees
var chaser = {x: 369, y: -235, vel: 37.5};
var target = {x: 139, y: -376, vel: 75, dir: 0.1815142422};
document.write(intercept(chaser, target) + "<br>");// -1.787 radians = -102.4 degrees

other interception points

The green curve effectively divides the 2D plane into a zone where the target will arrive first, and a zone where the chaser will arrive first. If you want the chaser and the target to move at constant speed and collide (imagine e.g. a torpedo being fired at a moving ship) then you'd aim for a point on the curve, where the two will arrive at the same time, as explained above.

However, if the chaser can go to a point and wait there for the target to arrive (imagine e.g. a person trying to catch a bus), then every point on the target's trajectory that is within the "chaser's zone" could be the interception point.

In the first image (slower target) the curve is a circle around the target, and once the target moves out of this circle (to the right of the interception point indicated in pink), the chaser could always get there first and wait for the target. This could be useful if you want a safety margin in case the chaser's or target's speed isn't constant.

In the second image (faster target) the curve is a circle around the chaser, and every point on the target's trajectory inside this circle could be the interception point. The chaser could e.g. move perpendicular to the target's trajectory, in order to minimise the distance travelled, or aim at a point halfway between the first and last interception point to maximise the waiting time.

这篇关于两个移动物体与纬度/经度坐标的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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