1

I have the following task:

I have $2$ points on the map (for each point the latitude and longitude is set) and the object on the map with the given direction (the direction is set as the angle with respect to the north). I need to determine to which of the $2$ points the object is going.

My solution:

Take a point $10 $meters back and compare the length. Call this point old.

I argue:

If the old point is closer to point $2$ than the new one, then we go to point $1$. Conversely as well. Tell me how to find the old point, knowing only the angle and coordinates? or I'll be glad to hear the algorithm better. Thank you

Nikitc
  • 125

1 Answers1

0

You have a position $u(t_0)$ of your moving object at current time $t_0$ and part of the change of the position (which is the velocity $\dot{u}(t_0)$) at current time. The part you have is the direction of the velocity vector, you lack it‘s magnitude. E.g. $$ \dot{u}(t_0) = \lVert \dot{u}(t_0) \rVert \, (\sin \alpha(t_0), \cos \alpha(t_0))^\top $$ where $\alpha$ is the angle to the $y$-axis.

To calculate the path of the moving object from an initial position and velocities over time $$ u(t) = \int\limits_{t_0}^t \dot{u}(\tau) \, d\tau $$ this is not enough information. So you must add assumptions.

E.g. the direction will not change over time $\alpha(t) = \alpha$ and there will be non-zero magnitudes (it moves forward somehow).

This would imply that the path will be a straight line (neglecting Earth‘s surface curvature, otherwise one would need to deal with parts of circle arcs, neglecting the deviations of Earth‘s surface from an ideal sphere, yadda, yadda).

In this simplified scenario calculating the distances of the target points to the line and picking the one with smaller distance would be the solution.

This would also need a check that points lie in forward direction relative to initial position and velocity direction.

The line can be modeled as \begin{align} n \cdot u &= d \iff \\ (n_x, n_y) \ (x, y)^\top &= n_x x + n_y y = d \end{align} with a unit normal vector $n$ of the line, a position vector $u$ and the distance $d$ of the line to the origin. $\top$ is short for transposition, it turns a column vector into a row vector and vice versa (ignore it, if you do not know it).

A target $u_i = (x_i, y_i)^\top$ will lie on a parallel line $$ n \cdot u_i = d_i $$ where the resulting number $d_i$ is the distance of the parallel line to the origin.

The distance of $u_i$ to the path line then is the absolute difference $$ \lvert d-d_i\rvert $$.

We start with the path line represented as \begin{align} u(t) &= u_0 + v t \\ u(t) &= (x(t), y(t))^\top \\ u_0 &= u(t_0) \\ v &= (\sin \alpha, \cos \alpha)^\top \end{align} then a unit normal vector to that line is $$ n = (–\cos \alpha, \sin \alpha)^\top $$ A target $u_i$ lies in forward direction if \begin{align} a_i = v \cdot (u_i - u_0) &= \lVert v \rVert \, \lVert u_i - u_0 \rVert \cos \angle(v, u_i-u_0) \\ &= (\sin \alpha, \cos \alpha) \, (x_i-x_0, y_i-y_0)^\top \\ &= (x_i-x_0) \sin \alpha + (y_i-y_0) \cos \alpha > 0 \end{align}

Example:

example (Large version)

You can fiddle with this example here: link

Play with the sliders to vary the various parameters of the scene.

mvw
  • 34,562
  • To calculate where the object goes, the magnitude of the velocity is not relevant, just that is > 0. I'd also like point out that the OP's proposed solution is not correct. If your object is currently in Miami and your 2 points on the map are New York City and Ottawa, then the object will be moving (mainly) north, no matter which point is its destination. That means that 'compare distances of old point vs. current point' method will tell that the object comes nearer to both points, and this creates no way to tell to which one. – Ingix May 16 '18 at 19:05
  • Such a case in my task will not be, because the object goes from one point to another. In this case, my decision suits me, I need to finalize it – Nikitc May 16 '18 at 19:10
  • @mvw Thank you, can you show a concrete example of your decision? – Nikitc May 16 '18 at 19:48
  • @Nikitc Yes, and you can play with it, if you use the link to the interactive GeoGebra work sheet. – mvw May 16 '18 at 22:20