Acceleration, deceleration, distance - calculating point of deceleration I'm working on game in space and I encounter problem that took me few hours to solve and I reached point when I think it would be easier to ask someone more clever, that trying to learn from beginning physics formulas from internet :)

*

*I need to find formula for calculating point at given distance the body will need to start decelerating. I know acceleration(a=1m/s2), deceleration(d=2m/s2) and distance(s=100m) the body needs to travel. Initial velocity is 0, and final velocity is also 0. Body start to accelerate and at some point it needs to start decelerating. Acceleration & deceleration are const.

After what distance the body needs to start decelerating. What is formula for this i can use to calculate it.


*Like above but additionally it needs some time (for example 2s) before it starts decelerating (time needed to rotate the ship before it starts decelerating with main thruster). In that time its not accelerating.

Every help is will be really appreciated :)
Edit - i made some calculations based on what I've already found in other posts and ideas other showed me and was able to solve it on my own :), answer below
$\displaystyle V_{i}$ - initial speed at start position (known)
$\displaystyle V_{f}$ - final speed at end position (destination) (known)
$\displaystyle a$ - acceleration of body (known)
$\displaystyle d$ - deceleration of body (known)
s - distance to travel (known)
$\displaystyle V_{x}$ - speed after we reach we need to decelerate (unknown)
$\displaystyle s_{dec}$ - distance after which we need to start decelerating  (unknown)
$\displaystyle s_{acc}$ - distance after which we need to start decelerating  (unknown)
$\displaystyle t_{acc}$ - time for which we accelerate  (unknown)
$\displaystyle t_{dec}$ - time for which we decelerate  (unknown)
 A: Was able to calculate on my own :) Checked with few set of variables and it works for me :) Thanks Matti P. for showing direction.
Answer for point 1
$\displaystyle V_{i}$ - initial speed at start position (known)
$\displaystyle V_{f}$ - final speed at end position (destination) (known)
$\displaystyle a$ - acceleration of body (known)
$\displaystyle d$ - deceleration of body (known)
s - distance to travel (known)
$\displaystyle V_{x}$ - speed after we reach we need to decelerate (unknown)
$\displaystyle s_{dec}$ - distance after which we need to start decelerating \ (unknown)
$\displaystyle s_{acc}$ - distance after which we need to start decelerating \ (unknown)
$\displaystyle t_{acc}$ - time for which we accelerate \ (unknown)
$\displaystyle t_{dec}$ - time for which we decelerate \ (unknown)
\begin{equation*}
\end{equation*}
$ $
\begin{equation*}
a\ =\ \frac{V_{x} \ -\ V_{i} \ }{t_{acc}} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ d\ =\ \frac{V_{x} \ -\ V_{f} \ }{t_{dec}} \ \ \ 
\end{equation*}
(1)
\begin{equation}
t_{acc} \ =\ \frac{V_{x} \ -\ V_{i} \ }{a} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ t_{dec} \ =\ \frac{V_{x} \ -\ V_{f} \ }{d}
\end{equation}
(2)
\begin{equation}
s_{dec} \ =V_{f} \ *\ t_{dec} \ +\ \frac{1}{2} \ d\ *\ (t_{dec} )^{2\ } \ \ \ \ \ \ s_{acc} \ =V_{f} \ *\ t_{acc} +\ \frac{1}{2} \ a\ *\ (t_{acc} )^{2\ } \ \ \ \ \ 
\end{equation}
\begin{equation*}
s\ =\ \ s_{acc} \ +\ s_{dec} \ =V_{i} \ *\ t_{acc} +\ \frac{1}{2} \ a\ *\ (t_{acc} )^{2\ } \ +V_{f} \ *\ t_{dec} \ +\ \frac{1}{2} \ d\ *\ (t_{dec} )^{2\ } \ \ 
\end{equation*}
\begin{equation*}
s\ =V_{i} \ *\ \frac{V_{x} \ -\ V_{i} \ }{a} \ +\ \frac{1}{2} \ a\ *\ \left(\frac{V_{x} \ -\ V_{i} \ }{a}\right)^{2} \ +\ V_{f} \ *\ \frac{V_{x} \ -\ V_{f} \ }{d} \ +\ \ \frac{1}{2} \ d\ *\ \left(\frac{V_{x} \ -\ V_{f} \ }{d}\right)^{2}
\end{equation*}
\begin{equation*}
s\ =\frac{V_{x} V_{i} \ -\ V^{2}_{i} \ }{a} \ +\ \ \frac{V^{2}_{x} \ -\ 2V_{x} V_{i} \ +\ V^{2}_{i} \ }{2\ a} +\frac{V_{x} V_{f} \ -V^{2}_{f} \ \ }{d} +\ \ \ \frac{{V^{2}_{x} \ -\ 2V_{x} V_{f} \ +\ V_{f}}^{2}}{2\ d}
\end{equation*}
\begin{gather*}
{2\ ads\ =2dV_{x} V_{i} \ -2dV^{2}_{i} \ +\ \ dV^{2}_{x} \ -\ 2dV_{x} V_{i} \ +\ dV^{2}_{i} \ +\ 2aV_{x} V_{f} \ \ -\ 2aV^{2}_{f} \ +\ aV^{2}_{x} \ -\ 2aV_{x} V_{f} \ +\ aV_{f}}^{2}\\
\end{gather*}
\begin{equation*}
{2\ ads\ =\ dV^{2}_{x} \ -\ dV^{2}_{i} \ +\ aV^{2}_{x} \ -\ aV_{f}}^{2}
\end{equation*}
\begin{equation*}
{2\ ads\ +\ aV_{f}}^{2} \ +\ dV^{2}_{i} \ =\ V^{2}_{x} \ ( d\ +\ a)
\end{equation*}
\begin{equation*}
\frac{{2\ ads\ +\ aV_{f}}^{2} \ +\ dV^{2}_{i}}{( d\ +\ a)} \ =\ V^{2}_{x} \ 
\end{equation*}
(3)
\begin{equation}
\sqrt{\frac{{2\ ads\ +\ aV_{f}}^{2} \ +\ dV^{2}_{i}}{( d\ +\ a)}} \ =\ V_{x} \ 
\end{equation}
When I get result of Vx I can get t needed for acceleration to Vx and deceleration from Vx (formula (1)). Then I can get distance s for acceleration by using formula (3), which is the value I needed.
Answer for point 2
$\displaystyle t_{rot}$ - time for rotation of body \ (known)
$\displaystyle t$ - time to travel given distance (we can get this from previous formula)
At this point we want to know how long body need to accelerate before it can rotate and then decelerate.
\begin{equation*}
\ \ \ \ \ \ \ \ \ \ \ \ t\ =\ \ t_{acc} \ +\ t_{dec} \ +t_{rot} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ t_{dec} \ =\ \ t_{acc}
\end{equation*}
\begin{equation*}
\ \ \ \ \ \ \ \ \ \ \ \ t\ =\ 2t_{acc} +t_{rot} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
\end{equation*}
\begin{equation*}
\ \ \ \ \ \ \ \ \ \ \ \frac{\ t\ -t_{rot}}{2} \ \ \ =\ t_{acc} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
\end{equation*}
