Commit 4501f8f4 authored by Alexander Lapshin's avatar Alexander Lapshin

asc node fix

parent d79da3e0
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "DrPeriod.h" #include "DrPeriod.h"
#include "GreenwichFrame.h" #include "GreenwichFrame.h"
#include "ECIFrame.h" #include "ECIFrame.h"
#include "METEFrame.h"
#include "XMLFunctions.h" #include "XMLFunctions.h"
#include "mathconst.h" #include "mathconst.h"
...@@ -27,7 +28,7 @@ void AscNodeOrbit::calc_asc_node(Propagator& prop, const TimeJD& date, const boo ...@@ -27,7 +28,7 @@ void AscNodeOrbit::calc_asc_node(Propagator& prop, const TimeJD& date, const boo
//if(!GetAscNodeYZ(*prop.GetPredictor()->GetPredictor(), prop.GetPredictor()->GetTime(), result, GetZ, GetVZ)){ //if(!GetAscNodeYZ(*prop.GetPredictor()->GetPredictor(), prop.GetPredictor()->GetTime(), result, GetZ, GetVZ)){
// return false; // return false;
//}; //};
SInitOrbit ascNodeOrbit; SInitOrbit ascNodeOrbit;
if (!jump_arg_of_lat(date, prop, 0, gcs_node, ascNodeOrbit)) { if (!jump_arg_of_lat(date, prop, 0, gcs_node, ascNodeOrbit)) {
throw Exp() << "internal error in ascending node method 1"; throw Exp() << "internal error in ascending node method 1";
...@@ -37,6 +38,10 @@ void AscNodeOrbit::calc_asc_node(Propagator& prop, const TimeJD& date, const boo ...@@ -37,6 +38,10 @@ void AscNodeOrbit::calc_asc_node(Propagator& prop, const TimeJD& date, const boo
if (DaysInterval(date, result.T) * 86400 > 1) { if (DaysInterval(date, result.T) * 86400 > 1) {
// TODO sometimes date lower result.T less than 1 sec // TODO sometimes date lower result.T less than 1 sec
//SInitOrbit ascNodeOrbit;
//if (!jump_arg_of_lat(date, prop, 0, gcs_node, ascNodeOrbit)) {
// throw Exp() << "internal error in ascending node method 1";
//}
throw Exp() << "internal error in ascending node method 2 " << DaysInterval(date, result.T)*86400; throw Exp() << "internal error in ascending node method 2 " << DaysInterval(date, result.T)*86400;
} }
...@@ -50,9 +55,6 @@ void AscNodeOrbit::calc_asc_node(Propagator& prop, const TimeJD& date, const boo ...@@ -50,9 +55,6 @@ void AscNodeOrbit::calc_asc_node(Propagator& prop, const TimeJD& date, const boo
void AscNodeOrbit::calc_desc_node(Propagator& prop, const TimeJD& date, const bool vzmode, const bool gcs_node, PhasePoint6D& result) const void AscNodeOrbit::calc_desc_node(Propagator& prop, const TimeJD& date, const bool vzmode, const bool gcs_node, PhasePoint6D& result) const
{ {
// std::string date_s = DateToStr(date);
// std::cout << date_s << "\n";
if (vzmode) { if (vzmode) {
//if(!GetAscNodeYZ(*prop.GetPredictor()->GetPredictor(), prop.GetPredictor()->GetTime(), result, GetZ, GetVZ)){ //if(!GetAscNodeYZ(*prop.GetPredictor()->GetPredictor(), prop.GetPredictor()->GetTime(), result, GetZ, GetVZ)){
// return false; // return false;
...@@ -64,11 +66,9 @@ void AscNodeOrbit::calc_desc_node(Propagator& prop, const TimeJD& date, const bo ...@@ -64,11 +66,9 @@ void AscNodeOrbit::calc_desc_node(Propagator& prop, const TimeJD& date, const bo
} }
result = ascNodeOrbit.GetPhasePointJ2000(); result = ascNodeOrbit.GetPhasePointJ2000();
//std::string res_s = DateToStr(result.T);
if (date < result.T) { if (date < result.T) {
throw Exp() << "internal error in descending node method 2 " << DaysInterval(date, result.T) * 86400;; throw Exp() << "internal error in descending node method 2 " << DaysInterval(date, result.T) * 86400;
} }
} }
...@@ -136,44 +136,71 @@ double AscNodeOrbit::get_kep_time(double TA, double e, double w) const ...@@ -136,44 +136,71 @@ double AscNodeOrbit::get_kep_time(double TA, double e, double w) const
bool AscNodeOrbit::jump_arg_of_lat(const TimeJD& date, Propagator& prop, double dstU, bool gcs_node, SInitOrbit& result) const bool AscNodeOrbit::jump_arg_of_lat(const TimeJD& date, Propagator& prop, double dstU, bool gcs_node, SInitOrbit& result) const
{ {
int maxInter = 20; const int maxInter = 20;
int iter = 0; int iter = 0;
bool nearestAscendingNode = false; const bool nearestAscendingNode = false;
double u_tol = 0.001; const double u_tol = 0.001;
double time_tol = 0.001; const double time_tol = 0.001;
PhasePoint6D p; PhasePoint6D p;
prop.Propagate(date, p); prop.Propagate(date, p);
if (!nearestAscendingNode) { if (!nearestAscendingNode) {
Kepler kep; Kepler kep;
kep.SetXYZ(p.CoordsVel); PhasePoint6D pt = p;
prop.Propagate(kep.GetTimeFromAN(p.T), p);
//if (gcs_node) {
// pt.Convert(METEFrame(pt.T));
//}
kep.SetXYZ(pt.CoordsVel);
prop.Propagate(kep.GetTimeFromAN(pt.T), p);
} }
while (true) { while (true) {
Kepler kep; double u;
double e;
double arg_of_per;
double period;
//std::string date_s = DateToStr(p.T);
//std::cout << date_s << "\n";
if (gcs_node) { if (gcs_node) {
PhasePoint6D gcs = p; PhasePoint6D gcs = p;
gcs.Convert(GreenwichFrame()); gcs.Convert(ECIFrame(gcs.T));
kep.SetXYZ(gcs.CoordsVel); Kepler gcs_kep;
gcs_kep.SetXYZ(gcs.CoordsVel);
u = gcs_kep.U;
arg_of_per = gcs_kep.GetArgP();
e = gcs_kep.GetEcc();
period = gcs_kep.GetPeriod();
} }
else { else {
Kepler kep;
kep.SetXYZ(p.CoordsVel); kep.SetXYZ(p.CoordsVel);
u = kep.U;
e = kep.GetEcc();
arg_of_per = kep.GetArgP();
period = kep.GetPeriod();
} }
if (fabs(Distance(0, kep.U, 0, dstU)) * rad2deg < u_tol) { if (fabs(Distance(0, u, 0, dstU)) * rad2deg < u_tol) {
break; break;
} }
double e = kep.GetEcc();
double u = kep.U;
double period = kep.GetPeriod();
double w = 86400 / period / 1000 * Pi2 / 1440 / 60; double w = 86400 / period / 1000 * Pi2 / 1440 / 60;
double t = get_kep_time((u - kep.GetArgP()), e, w); double t = get_kep_time((u - arg_of_per), e, w);
double t2 = get_kep_time((dstU - kep.GetArgP()), e, w); double t2 = get_kep_time((dstU - arg_of_per), e, w);
double step = t2 - t; double step = t2 - t;
if (step > period * 1000 / 2) {
step = step - period * 1000;
}
else if (step < -period * 1000 / 2) {
step = period * 1000 - step;
}
if (fabs(step) < time_tol) { if (fabs(step) < time_tol) {
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment