I am attempting to calculate a the required dV for a circularisation burn using kOS. I am calculating the required dV for both a prograde burn, as well as the required dV to achieve the desired inclination to cancel out the rotation.
For the prograde burn I am doing:
v_old = sqrt(body:mu * (2/(orbitAlt + body:radius) - 2/(ship:periapsis + orbitAlt + 2*body:radius)))
v_new = sqrt(body:mu * (2/(orbAlt + body:radius) - 2/(2*orbAlt + 2*body:radius)))
dv_prograde = v_new - v_old
For the normal burn I am doing:
i_deg = targetInclination - ship:orbit:inclination.
dv_normal = 2 * orbitalVelocity * sin(i_deg / 2).
I then add the two together to get overall dv required. I then create a manoeuvre node using these values:
burnNode = node(time:seconds + eta:apoapsis, 0, dv_normal, dv_prograde).
This produces a manoeuvre node orbit on the map view which has the correct inclination, but the final apoapsis is way too high ( aiming for 75km circular, get 75km periapsis and 161.268km apoapsis).
I am currently getting round this in my script by checking for ship:periapsis >= orbAlt, but I would really like to know what is going wrong!
I assume that I am missing some magic around adding these two delta-V values together, so if anyone knows why this is and how to fix it I would be grateful!