diff --git a/launch.ks b/launch.ks index 6f49322..56059f5 100755 --- a/launch.ks +++ b/launch.ks @@ -80,7 +80,6 @@ function launch { wait until APOAPSIS > target_orbit_altitude. lock THROTTLE TO 0. - unlock_control(). print "--- CIRCULARIZE ---". @@ -95,7 +94,7 @@ function launch { local node is NODE(TIME:SECONDS + ETA:APOAPSIS, 0, 0, 0). // Burn magnitude in the prograde direction is the difference between the required velocity to acheive circular orbit at apoapsis altitude and our velocity at apoapsis - local required_velocity is orbital_velocity_from_ap_pe(APOAPSIS, target_orbit_altitude, target_orbit_altitude). + local required_velocity is orbital_velocity_from_ap_pe(APOAPSIS, APOAPSIS, target_orbit_altitude). set node:PROGRADE to required_velocity - VELOCITYAT(SHIP, TIME:SECONDS + ETA:APOAPSIS):ORBIT:MAG. add node. @@ -118,7 +117,7 @@ function calculate_launch_azimuth { local inertial_azimuth is ARCSIN(COS(target_orbit_inclination) / COS(launch_site_latitude)). // azimuth in inertial space, that is, disregarding the rotation of the body local equatorial_rotational_velocity is (2 * CONSTANT:PI * BODY:RADIUS) / BODY:ROTATIONPERIOD. - local target_orbit_velocity is orbital_velocity_from_ap_pe(APOAPSIS, target_orbit_altitude, target_orbit_altitude). + local target_orbit_velocity is orbital_velocity_from_ap_pe(target_orbit_altitude, target_orbit_altitude, target_orbit_altitude). local launch_vector_x_component is target_orbit_velocity * SIN(inertial_azimuth) - equatorial_rotational_velocity * COS(launch_site_latitude). local launch_vector_y_component is target_orbit_velocity * COS(inertial_azimuth). diff --git a/lib/equations.ks b/lib/equations.ks index 563bc4e..453d097 100644 --- a/lib/equations.ks +++ b/lib/equations.ks @@ -42,9 +42,9 @@ function orbital_velocity { // http://www.orbiterwiki.org/wiki/Front_Cover_Equations // https://en.wikipedia.org/wiki/Vis-viva_equation parameter altitude. - parameter semi_major_axis is semi_major_axis(). + parameter sma is semi_major_axis(). - return SQRT(BODY:MU * ((2 / (altitude+BODY:RADIUS)) - (1 / semi_major_axis))). // add body radius because KSP measures altitude from the surface + return SQRT(BODY:MU * ((2 / (altitude+BODY:RADIUS)) - (1 / sma))). // add body radius because KSP measures altitude from the surface } function orbital_velocity_from_ap_pe {