I have a game with planet objects traveling in elliptical orbits. I want to plot a path from an object in one orbit to an object in another orbit. I'm not concerned with gravity etc as this is mainly for effect, not perfect realism. I just want it to look like ships traveling between them are intercepting them, not following them around.
Edit: In short, I want a Ship (with a known x, y, and velocity) to leave immediately to intercept a Planet that traveling on a fixed elliptical path. It doesn't have to be the shortest distance or even the shortest time, so long as the ship doesn't have to turn mid-flight to adjust. I have all of the ellipse's data, it's x, y, width, height, and angle. I also have any information on the current location of the Ship and its target Planet. I seek the x and y coordinates of the intercept or the angle from the ship's starting place. I think I'm comfortable finding one from the other.
Unfortunately, because all of this data changes as the program runs, it would be difficult for me to replace variables with constants for the sake of finding a solution here. I basically need a formula assembled that my application can plug variables into.
This is how I determine the locations of the objects based on time.
- θ = angle of the ellipse
- t = time
- a = ellipse width
- b = ellipse height
- x = ellipse x
- y = ellipse y
xplanet(t) = a cos(t) cos(θ) - b sin(t) sin(θ) + x
yplanet(t) = a cos(t) cos(θ) + b sin(t) cos(θ) + y
I found something for intercepts of objects traveling on a linear path, but I'm having trouble converting it to my purposes:
(xplanet(t))2 + (yplanet(t))2 − x2ship0 − y2ship0 = (vshipt)2