Matching a target velocity and position

364 Views Asked by At

For a science-fiction computer game I'm writing, I wish to calculate the travel time and accelerations of a ship leaving one (3D) position with an initial velocity, and travelling to a moving target, aiming to match both position and velocity when it arrives.

Since I don't believe I can solve the whole problem analytically, I've broken it up into two parts. The exercise of intercepting a moving target is being done with successive approximation - I calculate the position and velocity of the target at the departure time (i.e. assuming a zero travel time), then calculate the time it would take to travel to match that position and velocity. I then repeat the calculation for that updated arrival time, and iterate to converge on a position and velocity which is correct at the time the ship actually arrives.

The other part of the problem is actually calculating the time and accelerations needed to arrive at the target position with a target velocity. I have not been able to solve this analytically either, but I feel there should be an analytic solution, which is what my question actually relates to.

My assumptions are

  • The ship has magic science-fiction drives, so it can accelerate continuously without needing reaction mass.
  • The ship's acceleration is $>>$ the influence of gravity, so I'm ignoring gravity in the ship's equation of motion.
  • I've divided the motion up into two phases of constant acceleration. Phase 1 is of duration $t_1$ where the ship applies acceleration $\vec{a_1}$, and phase 2 is of duration $t_2$ where the ship applies acceleration $\vec{a_2}$.
  • The ship can instantaneously change acceleration at the transition from phase 1 to phase 2.
  • I believe that the solution with the shortest possible travel time will involve using the ship's maximum thrust, giving an acceleration of $a$, and therefore $\lvert\vec{a_1}\rvert = \lvert\vec{a_2}\rvert = a$.

The known values are

  • The initial position $\vec{p_i}$
  • The initial velocity $\vec{v_i}$
  • The target position $\vec{p_t}$
  • The target velocity $\vec{v_t}$
  • The ship's maximum acceleration $a$.

The variables I wish to get analytical solutions for are

  • The duration $t_1$ of phase 1.
  • The acceleration $\vec{a_1}$ during phase 1.
  • The duration $t_2$ of phase 2.
  • The acceleration $\vec{a_2}$ during phase 2.

I wish to minimise the travel time $t_1 + t_2$.

Given all that, I have some vector equations based on the classic equations of motion.

\begin{align} \lvert\vec{a_1}\rvert & = \lvert\vec{a_2}\rvert = a \tag{1}\label{eq1} \\ \vec{v_t} & = \vec{v_i} + \vec{a_1} t_1 + \vec{a_2} t_2 \tag{2}\label{eq2} \\ \vec{p_t} & = \vec{p_i} + \vec{v_i} t_1 + \frac{\vec{a_1} t_1^2}2 + (\vec{v_i} + \vec{a_1} t_1) t_2 + \frac{\vec{a_2} t_2^2}2 \\ \iff \vec{p_t} & = \vec{p_i} + \vec{v_i} (t_1 + t_2) + \frac{\vec{a_1} t_1^2}2 + \vec{a_1} t_1 t_2 + \frac{\vec{a_2} t_2^2}2 \tag{3}\label{eq3} \\ \end{align}

I can rearrange equation $\ref{eq2}$ to get $a_2$, \begin{align} \vec{v_t} & = \vec{v_i} + \vec{a_1} t_1 + \vec{a_2} t_2 \tag{2} \\ \iff \vec{a_2} t_2 & = \vec{v_t} - \vec{v_i} - \vec{a_1} t_1 \\ \iff \vec{a_2} & = (\vec{v_t} - \vec{v_i} - \vec{a_1} t_1) / t_2 \\ \end{align}

and then substitute it into $\ref{eq3}$: \begin{align} \vec{p_t} & = \vec{p_i} + \vec{v_i} (t_1 + t_2) + \frac{\vec{a_1} t_1^2}2 + \vec{a_1} t_1 t_2 + \frac{\vec{a_2} t_2^2}2 \tag{3} \\ \iff \vec{p_t} & = \vec{p_i} + \vec{v_i} (t_1 + t_2) + \frac{\vec{a_1} t_1^2}2 + \vec{a_1} t_1 t_2 + \frac{(\vec{v_t} - \vec{v_i} - \vec{a_1} t_1) t_2}2 \\ \iff \vec{p_t} & = \vec{p_i} + \vec{v_i} (t_1 + t_2) + \frac{\vec{a_1} t_1^2}2 + \vec{a_1} t_1 t_2 + \frac{\vec{v_t}t_2 - \vec{v_i}t_2 - \vec{a_1} t_1 t_2}2 \\ \iff \vec{p_t} & = \vec{p_i} + \vec{v_i} (t_1 + \frac{t_2}2) + \frac{\vec{a_1} t_1^2}2 + \frac{\vec{a_1} t_1 t_2}2 + \frac{\vec{v_t}t_2}2 \\ \end{align}

... and that's as far as I've got with this version of the problem. I've tried taking the dot product of both sides with $\vec{a_1}$ to make it into a scalar quadratic which I could solve, and also $\vec{a_1} . \vec{a_1} = a^2$, a known quantity, but that doesn't actually eliminate the unknown direction of $\vec{a_1}$ because it's still needed to calculate the dot product with $\vec{p_t}$, $\vec{p_i}$, $\vec{v_i}$ and $\vec{v_t}$.

I have four unknowns and only really two equations (I don't know that the two equations in \ref{eq1} really count in terms of eliminating unknowns), plus a desire to minimise $t1 + t2$, so obviously I need to pin down some more things before I can progress. It feels like there should be enough information to come up with a unique solution (or perhaps a set of solutions), but maybe I'm wrong.

Edit: Actually, I've realised that I can use \ref{eq1} to eliminate an unknown.

\begin{align} \vec{v_t} & = \vec{v_i} + \vec{a_1} t_1 + \vec{a_2} t_2 \tag{2} \\ \iff \vec{a_2} t_2 & = \vec{v_t} - \vec{v_i} - \vec{a_1} t_1 \\ \implies \lvert \vec{a_2} t_2 \rvert & = \lvert \vec{v_t} - \vec{v_i} - \vec{a_1} t_1 \rvert \\ \iff \lvert \vec{a_2} \rvert t_2 & = \lvert \vec{v_t} - \vec{v_i} - \vec{a_1} t_1 \rvert \\ \iff a t_2 & = \lvert \vec{v_t} - \vec{v_i} - \vec{a_1} t_1 \rvert \tag{using \ref{eq1}} \\ \iff t_2 & = \frac{\lvert \vec{v_t} - \vec{v_i} - \vec{a_1} t_1 \rvert}a \\ \end{align}

... and then substitute for $t_2$ in our working equation to eliminate the unknown $t_2$. However, since I'm unaware of any way to manipulate or extract values inside the magnitude expression (beside the manipulation I just used above, pulling out $t_2$ from the magnitude expression as a single scalar common factor), that leaves us with both $\vec{a_1}$ and $t_1$ trapped inside terms we can't extract them from, so we can't continue to rearrange our equation to get either variable by itself on one side of the equals symbol. It thus doesn't seem to help us get to an analytic expression for either $\vec{a_1}$ or $t_1$.