Somewhat of an extension of this.
I have a ship being launched from a planet, and I would like it to travel at a constant speed and direction such that it intersects another planet the soonest that it can.
(Beautiful diagram courtesy of Ausa)
I am ignoring initial velocity, end velocity, and gravity. The angular velocity of the planets and the velocity of the ship is constant. The physics that I am trying to achieve need not be realistic.
Using some quick maths I created a function! The function determines the smallest fly-by distance from the ship to the planet over time if the ship were to take the optimal route (a linear route since there's no gravity). So by determining when the fly-by distance is 0 (when the paths of the ship and planet intersect) I can work backwards to easily determine the angle of which I must launch the ship at to achieve this.
I created an implementation of the Bisection Method to find the first root of the function but depending on the variables of the function, the bisection method isn't the best solution to this problem. So now I'm trying to solve it mathematically! This is essentially what I need to solve:
Any solutions or ideas are greatly appreciated, thank you!
This means I want to find the x-intersection of the function nearest to the origin.
If you're interested in playing around with this function, I graphed it in Desmos https://www.desmos.com/calculator/tdtzt1gqkl
r_0 radius from the planet to the sun ("magic" units)
a_0 current angle of the planet in relation to the run (clockwise radians)
s_0 angular speed of the planet (clockwise radians per second
x_1 current x-position of the ship ("magic" units)
y_1 current y-position of the ship ("magic" units)
s_1 speed of the ship ("magic" units per second)
x_p planet x-position at x time ("magic" units)
y_p planet y-position at x time ("magic" units)
d_x delta x-position from ship to planet at x time ("magic" units)
d_y delta y-position from ship to planet at x time ("magic" units)
d_net net delta position from ship to planet at x time ("magic" units)
v_x optimal x-component of ship velocity ("magic" units per second)
v_y optimal y-component of ship velocity ("magic" units per second)
x_s ship x-position at x time ("magic" units)
y_s ship y-position at x time ("magic" units)
f(x) net distance from planet to ship at x time