I'm trying to write a script for a 'shape based' trajectory, based on the exponential sinusoid shape, for an Earth - Mars transfer. Essentially, I know where I want to start, and I know where I want to end, and I know how much time I want to take. I have the script that can generate my trajectory, for user specified shaping parameters (k1 and k2) and revolutions around the sun (N). What I would like to do is basically the reverse, for a known start point A, and a known end point B, with a given TOF(which is usually determined after the shape trajectory is drawn), find the optimal shaping parameters k1,k2 and revolutions N.
I basically want the 'optimum' k1, k2 and N for a given three year trajectory. Some of the code is provided below; I don't know how to include MATLAB script.
r = k0*exp((k1*sin(k2*th+phi))); - this equation is the equation of the eponential sinusoid. It goes into a for loop and spits out a vector of radii that can be plotted until the end point.
k0 = r1/exp(k1*sin(phi)); k0 is merely a scalar factor, with r1 being start point. Phi is a constant and is always pi/2
k1 = sqrt( ( (log(r1/r2) + sin(k2*th_f)*tan(g_i)/k2) / (1-cos(k2*th_f)) )^2 + tan(g_i)^2/k2^2 ); - r2 is the end point, th_f is the final polar angle in polar co-ordinates, g_i is set to 0 for this problem and k2 is user specified (usually about 1/12)
th_f = psi + 2*pi*N; - psi is the final angle you want to make with your start point (pi/2 in this case) and N is the number of whole revolutions around the sun.
Apologies for the lengthy question; for thoroughness k1 is apoapsis to periapsis radius, and k2 is a winding parameter, tells you how windy your spiral is.
EDIT I think, with thanks to Tristan, I can find a way of expressing the equation for TOF in terms of N, k2, k1, and create a function that way where the it would like f(x) = TOF(k2,N,k1) -3 years and use the genetic algorithm to optimise f(x) that way. Will post results soon!