For a computer game, I would like to study the motion of a rocket flying from a point A to point B on a two-dimensional plane. It is required that the speed of the rocket is zero both at the start and at the end of the journey. I can control the direction of the thrust vector but not the amount of the thrust. There is no gravity or drag and the rocket does not lose mass.
A trivial solution would be to accelerate from A to B for half of the distance, then flipping the rocket by 180° and braking for the second half of the distance. However, flipping the rocket takes some time and since I can't turn off the thrust, the rocket will deviate from the direct path between A and B, and this deviation must be compensated.
I would like to have an equation for the direction of the thrust vector as a function of time or distance.
After this problem is solved, lots of other interesting problems arise:
- what is the fastest path from A to B?
- if I could control (decrease) the thrust, would that lead to an even faster path?
- the rocket shall now visit more points A, B, C, D, ... and it is no longer required that the rocket stops at each point, how would the equations look like in this case?
Please advise how to approach this class of problems, or recommend literature for further study.
What you are looking for is called optimal control. And more specifically, you will need to use Pontryagin's maximum principle. Since your dynamical system has constraints.
Let's assume that we can control the angular velocity of the thrusters $u\in[-1,1]$ and the thrust $a=1$ is constant for simplicity. Then you can write the dynamical system: $$ \dot x = v_x,\qquad \dot v_x = a\cos\varphi,\\ \dot y = v_y,\qquad \dot v_y = a \sin\varphi,\\ \dot\varphi=u, $$ with conditions $x(0),y(0),y(T),v_x(0),v_y(0),v_x(T),v_y(T)=0$, $x(T)=X$.
It's useful to write it as $\dot {\mathbf q} = \mathbf f$, where $\mathbf q=(x,y,v_x,v_y,\varphi)$ and $\mathbf f=(v_x,v_y,\cos\varphi,\sin\varphi,u)$.
We want to minimize time, which we write as the integral $J=\int_0^T1\ dt$. To do this, we construct hamiltonian, by introducing Lagrange coefficient vector $\mathbf p$ ($\lambda$ in wiki): $$ H(\mathbf q, \mathbf p, u) = \mathbf p\cdot \mathbf f - 1. $$ ($-1$ because we have $1$ inside $J$ and we want to minimize it, no maximize).
Pontryagin's principle says, that for optimal scenario $\mathbf q^*$, $\mathbf p^*$, $u^*$, it's true that $$ H(\mathbf q^*, \mathbf p^*, u^*)\le H(\mathbf q^*, \mathbf p^*, u) $$ for all other $u$. Which in our case means that $p_5u^*\le p_5u$, thus $u=-\mathop{\mathrm{sign}} p_5$.
Costate equations: $$ \dot{\mathbf p} = -\frac{\partial H}{\partial \mathbf q},\\ \dot p_1 = 0,\quad \dot p_2 = 0,\quad \dot p_3=-p_1, \quad \dot p_4=-p_2, \quad \dot p_5 = p_3\sin\varphi - p_4\cos\varphi. $$ Since the end time $T$ is not fixed and $\varphi$ is also not fixed on both ends, we have: $$ H(T)=0,\qquad p_5(0) = 0,\qquad p_5(T)=0 $$
Solving this, we get $p_1=\mathrm{const}$, $p_2=\mathrm{const}$, $p_3=-p_1t+c_1$, $p_4=-p_2t+c_2$. For $p_5$ we have either $p_5=0$, or for each piecewise part where $\mathop{\mathrm{sign}} p_5=-u=\mathrm{const}$: $$ p_5 = (p_2-c_1u+p_1ut)\cos(ut+\varphi_0)-(p_1+c_2u-p_2ut)\sin(ut+\varphi_0) + c $$
Overall, we have 2 modes of flight. When $\varphi=\mathrm{const}$ and $p_5=0$ (acceleration along the straight line) and $p_5>0$ ($p_5<0$), when the thrusters rotate with max angular speed.
So you have to stitch those piecewise solutions (they are likely three: linear motion, rotation, linear motion again, as you predicted) and use start-end conditions to find constants (by utilizing the symmetry of the system, you can get rid of most of them). By the way, if $AB=2\pi$, I believe the resulting trajectory is cycloid. I would like to check it tomorrow.
For other questions: