## Accelerating Particle Problem

### The Problem

*Given a particle in a 2-dimensional plane that has some initial position and velocity and can accelerate at a constant rate
in any direction, in which direction should it accelerate to reach a target destination?*

There is only a single acceleration vector for which the particle will actually hit the target. How can we find that
vector? This problem statement was actually arrived at via a slightly different question:
*on which path should the particle travel to reach a target destination in minimal time?*
I conjecture that following the time-optimal path
*is*
the single-acceleration-vector path. In this post, I cover a few ways of thinking about the problem, approximate
solutions, an exact solution, and followup questions for another post.

### Some Thoughts

A naive sub-optimal path involves two phases. First, accelerate in the opposite direction of travel in order to come to a complete stop. Once stopped, accelerate directly toward the target. This is obviously suboptimal in all but one case: when the initial velocity vector points directly away from the target.

A better solution is to imagine a line drawn between the particle and the target. If the velocity vector is on one side of this line, the acceleration vector should be on the other side. How far to the other side is a function of how far the particle is from the destination, and how far the velocity vector is from the line.

### Approximate Solution

To codify the approximate solution mentioned above, we'll need some mathematics. Let's label the vector from the particle to the target as \(\vec s\) and the velocity vector as \(\vec v\). These are the inputs to our acceleration function, \(A\). When developing these sorts of functions, I find it helpful to start teasing the equation out of some simplified cases. The simplest case is when the particle is moving directly towards or away from the target:

$$ A(\vec s, c\vec s) = \hat s $$

That is, if velocity is zero or the particle already moving directly towards or away from the target, whatever equation we come up with should return the unit vector pointed at the target, \(\hat s\).

This implies that our solution will need to know the angle between \(\vec v\) and \(\vec s\). The angle \(\theta\) between two vectors can be found with the formula:

$$ \theta = \arcsin \left( \frac{\vec v\cdot\vec s}{|\vec v|\cdot|\vec s|} \right) $$

Let's define \(\phi\) as the angle between the acceleration vector \(\vec a\) and \(\vec s\). We need a function that produces smaller \(\phi\) when \(\vec v\) is closer to \(\vec s\). \(\vec v\) being close to \(\vec s\) implies that \(\theta\) is far from \(\frac{\pi}{2}\) radians:

$$ f(\theta) = c \cdot \left|\frac{\pi}{2} - \theta \right| $$

In that function, \(c\) is a stand-in for some scalar in \([0, 2]\) that governs how \(\phi\) changes as \(\vec v\) gets closer to or farther from \(\vec s\). How should it be defined? If the target is very far away, we probably want \(\phi\) to be small regardless of \(\theta\). If the target is very close, or \(\vec v\) is very fast, we want to counteract \(\theta\) much more strongly. So we can define the scalar as a function of \(\vec s\) and \(\vec v\):