# Spaceship course calculation

This topic is 1092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
As far as the actual maneuver calculations... something like this maybe? (Though this may be overkill...)

https://en.wikipedia.org/wiki/Hohmann_transfer_orbit

I believe this just gets you from one orbit to another, but doesn't actually factor in the positions of the planets within those orbits. Being able to launch at any time probably requires much more fancy calculations to alter the transfer path. Edited by Nypyren

##### Share on other sites

Welcome to the complex world of orbital mechanics. The task you are trying to solve would still require lot's of work in 2D, and with two planets orbiting the same star. Remember that the pussys over at NASA have had it really easy because the planets of the solar system are almost aligned in the same plane. Yours arent...

Are you simulating real gravity through n-body interaction and an integration algorithm, or are you simply having the planets and ships appear to visually "orbit" each other in perfect circles using cos / sin?

This site is really good at explaining all the concepts: http://www.braeunig.us/space/orbmech.htm

Cheers,

Mike

##### Share on other sites

I do not simulate gravity, there is an orbit axis and an angle and I determine the position of the planet based on this.

##### Share on other sites

Well, since there is a good deal of non-physics going on, like stars with fixed positions, kinematic clockwork orbits and ftl warp speed space travel, I suggest a non-physical solution. Simply make the ship disappear from its starting position and re-appear in orbit around the desired target after a pre-determined travel time.

Edited by h4tt3n

##### Share on other sites

This is not possible, because the player is on the spaceship...

##### Share on other sites

I'd still go for a non-physical solution. How about this: define four waypoints that describe the trajectory. Point 1 and 2 are connected with a spline (for the smooth curve), 2 and 3 with a straight line, 3 and 4 with another spline. Compute travel time from trajectory length. Now compute destination position from travel time. Iterate until convergence is reached.

Edited by h4tt3n

##### Share on other sites

Have you tried NOT plotting a course and simply steering toward your destination? Assuming your ship is much faster than an orbiting planet then it should follow a pretty reasonable path, but you don't need to work out exactly what that path will be in advance.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633704
• Total Posts
3013458
×