Skip to content

Instantly share code, notes, and snippets.

@alterbaron
alterbaron / landingcalc.m
Created May 24, 2013 14:05
Useful calculation routines and landing phase angle calculator for Kerbal Space Program
function [phi_out] = landingcalc( orbit_alt, landing_pe )
% Returns the landing phase angle, where the ship starts in a circular
% orbit and drops its PE down to landing_pe.
% Set to true to log a bunch of details.
details = false;
% Kerbin planetary data from Wiki
dt = 1;
m = 1.0;
@alterbaron
alterbaron / gist:6407325
Created September 1, 2013 21:08
KSP 2D Ascent Trajectory Optimization with PSOPT
// KSP 2D Ascent Trajectory Optimization Problem
#include "psopt.h"
//////////////////////////////////////////////////////////////////////////
/////////////////// Define the end point (Mayer) cost function //////////
//////////////////////////////////////////////////////////////////////////
adouble endpoint_cost(adouble* initial_states, adouble* final_states,
adouble* parameters,adouble& t0, adouble& tf,
adouble* xad, int iphase)