I'm attempting to develop an equation to determine the "switching time" for a control system. I've managed to work out a specific solution for when starting and ending velocities are are the same, yet am unable to adapt this for determining the switching time given an arbitrary starting velocity, and an arbitrary ending velocity.

More formally, given the acceleration of an object:

$a(t) = \left\\{ \begin{array}{lr} MaxAccel & : 0 \lt t \le switchTime\\\ -MaxAccel & : switchTime \lt t \lt stopTime\\\ 0 & : otherwise \end{array} \right.$

determine $switchTime$, such that the object starting at $velocityInitial$, will travel $distance$, and arrive there travelling at $velocityFinal$. The calculation of $stopTime$ is trivial.

My current specific solution for starting and ending at the same velocity is:

$-velocityInitial + \sqrt{velocityInitial^2+MaxAccel*distance} \over a$

Sorry for the lack of a more formalized mathematical definition, I'm doing my best. =)

For those curious, yes this is related to my other navigation question. I'm trying to now integrate proportional navigation for small facing adjustments, and a limited bang-bang algorithm for increasing velocity towards the object. I'll post the whole algorithm once I get it working.

(Side note: This is the first time I'm actually using LaTeX for something "real" instead of fiddling around. Awesome!)