27 #include "Astro_Functions.h"
28 #include "propagateKEP.h"
50 void propagateKEP(
const double *r0_in,
const double *v0_in,
const double &t,
const double &mu,
60 double DD[9] = {1, 0, 0,
64 double ih[3] = {0,0,0};
65 double temp1[3] = {0,0,0}, temp2[3] = {0,0,0};
85 if (fabs(fabs(ih[2])-1.0) < 1e-3)
87 DD[0] = 1; DD[1] = 0; DD[2] = 0;
88 DD[3] = 0; DD[4] = 0; DD[5] = 1;
89 DD[6] = 0; DD[7] = -1; DD[8] = 0;
94 for (
int i=0; i<3; i++)
96 temp1[0] += DD[i]*r0[i];
97 temp1[1] += DD[i+3]*r0[i];
98 temp1[2] += DD[i+6]*r0[i];
99 temp2[0] += DD[i]*v0[i];
100 temp2[1] += DD[i+3]*v0[i];
101 temp2[2] += DD[i+6]*v0[i];
103 for (
int i=0; i<3; i++)
111 DD[0] = 1; DD[1] = 0; DD[2] = 0;
112 DD[3] = 0; DD[4] = 0; DD[5] = -1;
113 DD[6] = 0; DD[7] = 1; DD[8] = 0;
116 IC2par(r0, v0, mu, E);
119 M0 = E[5] - E[1]*sin(E[5]);
120 M=M0+sqrt(mu/pow(E[0],3))*t;
124 M0 = E[1]*tan(E[5]) - log(tan(0.5*E[5] + M_PI_4));
125 M=M0+sqrt(mu/pow(-E[0],3))*t;
128 E[5]=Mean2Eccentric(M, E[1]);
132 for (
int j=0; j<3; j++)
134 temp1[0] += DD[j]*r[j];
135 temp1[1] += DD[j+3]*r[j];
136 temp1[2] += DD[j+6]*r[j];
137 temp2[0] += DD[j]*v[j];
138 temp2[1] += DD[j+3]*v[j];
139 temp2[2] += DD[j+6]*v[j];
141 for (
int i=0; i<3; i++)
173 void IC2par(
const double *r0,
const double *v0,
const double &mu,
double *E)
194 k[0] = 0; k[1] = 0; k[2] = 1;
199 temp += pow(n[i], 2);
208 vett(v0, h, Dum_Vec);
211 evett[i] = Dum_Vec[i]/mu - r0[i]/R0;
215 e += pow(evett[i], 2);
221 E[2] = acos(h[2]/norm2(h));
229 if (evett[2] < 0) E[4] = 2*M_PI - E[4];
232 if (n[1] < 0) E[3] = 2*M_PI-E[3];
236 temp+=evett[i]*r0[i];
238 ni = acos(temp/e/R0);
244 if (temp<0.0) ni = 2*M_PI - ni;
247 E[5] = 2.0*atan(sqrt((1-e)/(1+e))*tan(ni/2.0));
249 E[5] =2.0*atan(sqrt((e-1)/(e+1))*tan(ni/2.0));
274 void par2IC(
const double *E,
const double &mu,
double *r0,
double *v0)
282 double b, n, xper, yper, xdotper, ydotper;
284 double cosomg, cosomp, sinomg, sinomp, cosi, sini;
292 n = sqrt(mu/(a*a*a));
296 xdotper = -(a*n*sin(EA))/(1-e*cos(EA));
297 ydotper=(b*n*cos(EA))/(1-e*cos(EA));
302 n = sqrt(-mu/(a*a*a));
304 dNdZeta = e * (1+tan(EA)*tan(EA))-(0.5+0.5*pow(tan(0.5*EA + M_PI_4),2))/tan(0.5*EA+ M_PI_4);
306 xper = a/cos(EA) - a*e;
309 xdotper = a*tan(EA)/cos(EA)*n/dNdZeta;
310 ydotper = b/pow(cos(EA), 2)*n/dNdZeta;
323 R[0][0]=cosomg*cosomp-sinomg*sinomp*cosi;
324 R[0][1]=-cosomg*sinomp-sinomg*cosomp*cosi;
326 R[1][0]=sinomg*cosomp+cosomg*sinomp*cosi;
327 R[1][1]=-sinomg*sinomp+cosomg*cosomp*cosi;
328 R[1][2]=-cosomg*sini;
336 double temp[3] = {xper, yper, 0.0};
337 double temp2[3] = {xdotper, ydotper, 0};
339 for (
int j = 0; j<3; j++)
341 r0[j] = 0.0; v0[j] = 0.0;
342 for (
int k = 0; k<3; k++)
344 r0[j]+=R[j][k]*temp[k];
345 v0[j]+=R[j][k]*temp2[k];