74 #include <boost/math/special_functions/acosh.hpp>
75 #include <boost/math/special_functions/asinh.hpp>
79 #include "Astro_Functions.h"
81 #include "../exceptions.h"
85 void LambertI (
const double *r1_in,
const double *r2_in,
double t,
const double &mu,
87 double *v1,
double *v2,
double &a,
double &p,
double &theta,
int &iter)
96 x,x1,x2,y1,y2,x_new=0,y_new,err,alfa,beta,psi,eta,eta2,sigma1,vr1,vt1,vt2,vr2,R=0.0;
98 const double tolerance = 1e-11;
99 double r1[3], r2[3], r2_vers[3];
100 double ih_dum[3], ih[3], dum[3];
109 pagmo_throw(value_error,
"ERROR in Lambert Solver: Negative Time in input.");
112 for (i = 0; i < 3; i++)
129 r2_mod += r2[i]*r2[i];
133 r2_mod = sqrt(r2_mod);
135 for (i = 0;i < 3;i++)
136 dot_prod += (r1[i] * r2[i]);
138 theta = acos(dot_prod/r2_mod);
141 theta=2*acos(-1.0)-theta;
143 c = sqrt(1 + r2_mod*(r2_mod - 2.0 * cos(theta)));
144 s = (1 + r2_mod + c)/2.0;
146 lambda = sqrt (r2_mod) * cos (theta/2.0)/s;
154 y1=log(x2tof(-.5233,s,c,lw))-log(t);
155 y2=log(x2tof(.5233,s,c,lw))-log(t);
160 while ((err>tolerance) && (y1 != y2))
163 x_new=(x1*y2-y1*x2)/(y2-y1);
164 y_new=log(x2tof(exp(x_new)-1,s,c,lw))-log(t);
169 err = fabs(x1-x_new);
186 beta = 2 * asin (sqrt( (s-c)/(2*a) ));
187 if (lw) beta = -beta;
190 eta2=2*a*pow(sin(psi),2)/s;
195 beta = 2*boost::math::asinh(sqrt((c-s)/(2*a)));
196 if (lw) beta = -beta;
197 alfa = 2*boost::math::acosh(x);
199 eta2 = -2 * a * pow(sinh(psi),2)/s;
204 p = ( r2_mod / (am * eta2) ) * pow (sin (theta/2),2);
205 sigma1 = (1/(eta * sqrt(am)) )* (2 * lambda * am - (lambda + x * eta));
211 for (i = 0; i < 3;i++)
219 for (i = 0;i < 3 ;i++)
220 v1[i] = vr1 * r1[i] + vt1 * dum[i];
223 vr2 = -vr1 + (vt1 - vt2)/tan(theta/2);
225 vett(ih,r2_vers,dum);
226 for (i = 0;i < 3 ;i++)
227 v2[i] = vr2 * r2[i] / r2_mod + vt2 * dum[i];
229 for (i = 0;i < 3;i++)