1
\$\begingroup\$

Consider a static obstacle placed in 3 Dimensional coordinate plane. A moving bot is programmed to pass through it. We know the position of obstacle. We also know the current position and current velocity of moving bot. Say, position and velocity are given as 3D vector.

How to decide whether the bot is approaching the obstacle or leaving the obstacle?

I think, the relative velocity should be able to differentiate it? Any approach please.

\$\endgroup\$
1
  • \$\begingroup\$ Depending on the exact topography, the ideal path from point A to point B might involve sections where the direct distance increases. Is that relevant for your use-case? \$\endgroup\$
    – Philipp
    Commented Sep 30, 2016 at 12:56

1 Answer 1

2
\$\begingroup\$

Given the obstacle at position A, and the bot at position B with velocity V;
We calculate the dot product p = AB · V = xAB·xV + yAB·yV + zAB·zV.

Then p is:

  • >0 if the bot is moving towards the obstacle;
  • <0 if the bot is moving away from the obstacle;
  • 0 if the bot is staying at the same distance (standing still or moving around the obstacle in a circle).
\$\endgroup\$
2
  • \$\begingroup\$ Just asking for confirming, if p=0, it means that V is perpendicular to the trajectory? \$\endgroup\$
    – ravi
    Commented Sep 30, 2016 at 13:18
  • 1
    \$\begingroup\$ @RaviJoshi absolutely. The dot product is zero if either vector is zero, or they are perpendicular. \$\endgroup\$
    – Quentin
    Commented Sep 30, 2016 at 13:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .