1 // ------------------------------------------------------------------------ //
2 // This source file is part of the 'ESA Advanced Concepts Team's //
3 // Space Mechanics Toolbox' software. //
5 // The source files are for research use only, //
6 // and are distributed WITHOUT ANY WARRANTY. Use them on your own risk. //
8 // Copyright (c) 2004-2007 European Space Agency //
9 // ------------------------------------------------------------------------ //
11 #include "PowSwingByInv.h"
14 void PowSwingByInv (const double Vin
,const double Vout
,const double alpha
,
15 double &DV
,double &rp
)
17 const int maxiter
= 30;
20 double f
,df
; // function and its derivative
22 const double tolerance
= 1e-8;
24 double aIN
= 1.0/pow(Vin
,2); // semimajor axis of the incoming hyperbola
25 double aOUT
= 1.0/pow(Vout
,2); // semimajor axis of the incoming hyperbola
28 while ((err
> tolerance
)&&(i
< maxiter
))
31 f
= asin(aIN
/(aIN
+ rp
)) + asin(aOUT
/(aOUT
+ rp
)) - alpha
;
32 df
= -aIN
/sqrt((rp
+ 2 * aIN
) * rp
)/(aIN
+rp
) -
33 aOUT
/sqrt((rp
+ 2 * aOUT
) * rp
)/(aOUT
+rp
);
37 err
= fabs(rp_new
- rp
);
44 // Evaluation of the DV
45 DV
= fabs (sqrt(Vout
*Vout
+ (2.0/rp
)) - sqrt(Vin
*Vin
+ (2.0/rp
)));