Hi, I am currently working on a 2d strategy game/simulation involving spaceships moving around in a solar system and have hit a problem I'm not sure how to solve.
The basic idea is, I have a spaceship at some position and want to move to some other position, the ship can only accelerate along a fixed axis, with a fixed magnitude of acceleration, change of acceleration and orientation of the ship can be treated as instant. So far I've only dealt with the situation where the initial (and final) velocities were zero. Accelerate towards the target for half the distance, turn around, brake. Now I've been trying to extend this to ships already moving, without much success. I figured that I could still use the same approach of splitting the movement into two segments, first accelerating (or aligning the velocity with the vector towards the target) and then braking, as before, but I can't solve the resulting equations and I'm hoping one of you can help me or tell me that I'm stuck with numerical methods.
The equations I have are:
P=v0*t1+0.5*a1*t1^2+v1*t2+0.5*a2*t2^2 //We want to end up at our target
v0+a1*t1+a2*t2 =(0,0) //and standing still
with P being the target position, v0 initial velocity,a1, a2 and t1,t2 the direction vectors and durations of the acceleration burns and finally
v1 = v0+a1*t1 the velocity after the first burn.
And for example we can now eliminate a2 = normalize(-v1) and t2 = ||v1||, to leave only a1 and t1 as unknowns, but the result is still a mess that I can't solve. Does anyone have a suggestion?