You are trying to model a simple 2-body simulation (a special case of $n$-body simulations). Your basic set up should revolve around two equations:
\begin{align}
\frac{dx}{dt}&=v\\
\frac{dv}{dt}&=\frac{F}{m}
\end{align}
which is really breaking up Newton's 2nd law into two steps. Here
$$
F=G\frac{mM}{r^2}
$$
is the gravitational force and $a=F/m$ your acceleration.
In discrete steps, you should be evolving the position and velocity of the particles as
\begin{align}
x_{new} &= x_{old}+v_{old}\cdot dt\tag{1}\\
v_{new} &= v_{old}+\frac{F}{m}\cdot dt\tag{2}
\end{align}
where $x$ and $v$ are 2D vectors.
Your most simple algorithm is the Euler method, described in Equations (1) & (2). A more stable integration scheme, called Verlet integration, goes
- Compute the new position step: $$x_{n+1}=x_n+v_{n}dt+\frac12a(x_n)dt^2$$
- Compute new velocity: $$v_{n+1}=v_{n}+\frac12\left(a(x_{n+1})+a(x_n)\right)dt$$
- Set $x_n=x_{n+1}$ and $v_n=v_{n+1}$, increment time: $t=t+dt$ and repeat until $t=t_{end}$
And there are other integration methods available to you, but either of these two are simple enough to implement and should work for your purposes (provided $dt$ is small enough).
This is similar to the path a car will take which can use the tire traction either for accelerating/decelerating or for turning, but not both at the same time. Well, both are possible but with limits.
In this case, the general path looks as follows:
If the magnitude of the acceleration is limited to $a$ then the minimum turn radius when the ship has speed $v$ is $$r = \frac{v^2}{a}$$
Here I have marked the location of the target with $(X,Y)$ based on a coordinate system on the starting location and the x-axis along the direction of travel.
The total transit time is the sum of the three legs
$$ t = \frac {|v_B-v_A|}{a} + \frac{|\varphi| v_B}{a} + \frac{|v_E-v_B|}{a} $$
where $v_A$ is the starting speed, $v_B$ is the turn-in speed and $v_E$ is the exit speed (speed at target).
One of the strategies is to come to a complete stop at a distance $\ell_{\rm AB} = \frac{v_A^2}{2 a}$ and then start accelerating towards the target. In this scenario, the time to turn is zero.
The turn angle for this scenario is
$$ \varphi_{\rm min} = \mathrm{atan}\left( \frac{Y}{X + \frac{v_A^2}{2 a}} \right) $$
The transit time is now
$$ t_{\rm min} = \frac{v_A}{a} + 0 + \sqrt{
\frac{ 2 \sqrt{
Y^2 + \left(X + \frac{v_A^2}{2 a} \right)^2 }
}{a}} $$
In general, for a larger turn angle $\varphi > \varphi_{\rm min}$ the key speeds and transit time is
$$\boxed{\begin{aligned}
v_{B} & =\sqrt{\frac{a\left(X'\sin\varphi-Y\cos\varphi\right)}{1+\tfrac{1}{2}\sin\varphi-\cos\varphi}}\\
v_{E} & =\sqrt{\frac{a\left(\left(2X'-Y\right)\cos\varphi+\left(X'+2Y\right)\sin\varphi-2X'+Y\right)}{1+\tfrac{1}{2}\sin\varphi-\cos\varphi}}\\
t & =\frac{|v_{A}-v_{B}|}{a}+\frac{|\varphi|v_{B}}{a}+\frac{|v_{E}-v_{B}|}{a}
\end{aligned}}$$
where $X' = X + \frac{v_A^2}{2 a}$
There is an upper limit on the turn angle $\varphi$ which makes $\ell_{\rm DE}=0$ and this also results in a short transit time, but it is unknown if it is shorter than the case where the ship stops to turn.
This limit is
$$ \varphi_{\rm max} = 2 \mathrm{atan}\left( \frac{X' +2 Y}{2 X'-Y} \right) - \frac{\pi \left( \mathrm{sign}\left(2 X'-Y \right) \mathrm{sign}\left( X' + 2 Y \right) + \mathrm{sign}\left( 2 X'-Y \right) - 2 \right) }{2}$$ and use the expressions above to get $v_B$, $v_E$ and $t$.
In general, with varying conditions, the optimal strategy is between these two extremes but not on the extremes.
here is what the curves look like for some arbitrary conditions, with arrows indicating the optimal turn angle.
Best Answer
Sure, there are rules, and it is pretty simple. You'll see after you solve this confusion.
Suppose you come up with a kinematics exercise. After you read and understand it (yes, it's obvious that's the first thing, but not everybody does haha), then we must set a reference frame.
Setting the reference frame means not only deciding "the reference point" from which we will measure distances. It also includes deciding the axes.
So, for example, imagine that you read the problem and it is a free fall, because you read that it is a free fall. An intelligent choice would be setting the reference frame (RF) at the bottom, and the usual cartesian axes. Doing it like this, distances will be possitive, and that's good.
So we've chosen two perpendicular axes. The usual cartesian axes. You've chosen where to put the origin of those axes (preferably at the bottom). So now we've got the axes. From now on:
If you've chosen the usual cartesian axes, then it is possitive above the origin and negative below it. (Also possitive at the right of the origin and negative at the left). This has been like this from the beginning of times.
Now, velocities.
You have to keep in mind the definition:
$$v=\frac{\Delta s}{\Delta t}$$
Where $\Delta$ means "increase". So
$v$= how much distances increases $\div$ how much time increases.
But time flows always forward, never backwards. So the increasing of time is always possitive, whatever its value. $\Delta t>0$. This means that the sign of velocity is given by the change in distance:
This is usually possitive if it goes upwards/rightwards, and negative if it is downwards/leftwards.
But this is just because of the definition. If the distance is decreasing (that means everytime less possitive, or more negative), then $\Delta s<0$ and thus $v<0$.
For the same reason, accelerations are
$$a=\frac{\Delta v}{\Delta t}$$
So the sign of acceleration is given by the sign of $\Delta v$, that is, the sign of the "change of $v$".
If $v$ is decreasing, acceleration is negative. If $v$ is increasing, acceleration is possitive.
Check that we are usually dealing with negative numebrs too. So "Increasing" can be regarded as "more possitive" or "less negative", equivalently.
Back to the exercise.
So, the particular case of a free fall. We are working on the vertical axis, labeled $y$.
The intelligent choice is setting the origin at the bottom. Like this, your initial position would be $0$ if it starts from the ground, or a possitive numebr if it starts from certain height, but possiive anyways, and that's good.
$y_0>0$.
Now, velocity. It depends on the problem. If the object is initially moving upwards, $v_0>0$. If it is moving downwards, $v<0$.
Acceleration is certainly negative, because it tends to decrease velocity. If $v$ was possitive, it is trying to stop the particle. IF $v$ was already negative, acceleration will make it go downwards faster, so velocity is smaller, in the sense of "more absolute value but negative". It's "more negative", so it's still decreasing. Acceleration is negative anyways.
But this is because of your choice of axis. IF you had chosen a "reversed axis", so that possitive coordinates were below the origin, acceleration would be possitive. It's all about thinking with the definitions: is velocity making position grow or decrease?
And we deal with real numbers. Going from minus 10 to minus 20 is decreasing 10 units. It's bigger in absolute value, but the sign is there.