Hi,
I have a planet S (start) and a planet D (destination). Both of the planets are orbiting a star or another planet. Stars are fixed points (they don't move). My spaceship is orbiting planet S and I want it to fly to planet D and orbit planet D. I can calculate the spaceship's position at time t and the spaceship position if it was orbiting planet D at time t2. I can calculate the time the spaceship needs to travel a given distance, so straight lines are not the problem. But I want my spaceship to fly in an arc when it starts from S and when it arrives at D to have a smooth transition.
I tried to calculate the course, but several problems occured:
1) I don't know how to transition from movement relative to the planet to movement relative to my coordinate system (which doesn't move). Well, I can of course calculate the movement vector and the speed relative to standstill, but the z-axis of my spaceship is not the movement vector. If I orbit the planet in opposite direction to the planet's movement (remember, it orbits another planet or a star), I have to turn around or accelerate in my view direction (ship's z-axis). Well, this case is easy, but what if I the angle between my view vector and the actual movement is for example 73 degrees? Well, I could turn the ship around so it is aligned to it's movement. But I also have to turn around again to fly to planet D. So I turn around twice, in worst case I make 2 180 degree turns...
2) How can I calculate the arrival time? Is it possible? Or is it better to iterate (calculate course with arrival time = current time, then calculate how long it takes if D is at the current position, then add this duration to the current time and so on) until I am close enough to the time it actually takes?
3) How can I avoid that the ship is flying through planet S or D? (Other planets and stars are irrelevant because collisions with them are very unlikely.)
I want my ship to fly an arc until it's z-axis is pointing towards the destination, fly in a straight line at "warp" speed and then fly another arc when it arrives at D. Maybe fly a straight line relative to the planet before the first arc and after the second arc.
Does anyone know how to solve these problems?