% Hohmann transfer
% Earth -> neptune 

% Astronomical Unit
AU = 149.56e9;

% Orbit of Earth around Sun.
VE = sqrt(G*(M_S+M_E)/AU);

% Orbit of Neptune around Sun
M_N = 1.03e26; % Mass of neptune
dN  = 30.1*AU; % Distance from sun to Neptune.
dE  = AU;
VN = sqrt(G*(M_S+M_N)/dN);

% Velocity at peri- and apoapsis of elliptical transfer orbit.
Vp = sqrt(2*G*M_S/dE*dN/(dN+dE))
Va = sqrt(2*G*M_S/dN*dE/(dE+dN))

% Delta
dV1 = Vp - VE % Velocity delta at perihelion.
dV2 = VN - Va %

dVtot = dV1 + dV2

% Time taken in maneuver (using K3)
a = 0.5*(dN + dE)

T = 2*pi*sqrt(a^3/(G*M_S)) % Time for full orbit of ellipse.
Ttransit = T/2 / 60/60/24/365 % 