Commit a1ff8cdb authored by Alexander Lapshin's avatar Alexander Lapshin

+ orb_date

parent 6969ff1e
#include "integratorcfg.h"
void IntegratorCfg::load(const jsonval& parent)
{
m_eps = -1;
loadjson(parent, "eps", m_eps, false);
m_stepinit = -1;
loadjson(parent, "init_step", m_stepinit, false);
m_stepmin = -1;
loadjson(parent, "min_step", m_stepmin, false);
m_precItrf = false;
loadjson(parent, "prec_itrf", m_precItrf, false);
}
#ifndef INTEGRATORCFG_H #pragma once
#define INTEGRATORCFG_H
#include "json_functions.h"
#define IEPS 1E-9 #define IEPS 1E-9
#define ISTEPINIT 10E-3 #define ISTEPINIT 10E-3
...@@ -17,6 +18,7 @@ public: ...@@ -17,6 +18,7 @@ public:
{ {
} }
void load(const jsonval& parent);
double getEps() const { return m_eps > 0 ? m_eps : IEPS; } double getEps() const { return m_eps > 0 ? m_eps : IEPS; }
double getStepInit() const { return m_stepinit > 0 ? m_stepinit : ISTEPINIT; } double getStepInit() const { return m_stepinit > 0 ? m_stepinit : ISTEPINIT; }
double getStepMin() const { return m_stepmin > 0 ? m_stepmin : ISTEPMIN; } double getStepMin() const { return m_stepmin > 0 ? m_stepmin : ISTEPMIN; }
...@@ -27,6 +29,3 @@ private: ...@@ -27,6 +29,3 @@ private:
double m_stepmin; double m_stepmin;
bool m_precItrf; bool m_precItrf;
}; };
#endif
...@@ -12,6 +12,7 @@ public: ...@@ -12,6 +12,7 @@ public:
Vect6 get_pos() const { return m_vec; } Vect6 get_pos() const { return m_vec; }
int get_step() const { return m_step; } int get_step() const { return m_step; }
bool is_addon() const { return m_addon; } bool is_addon() const { return m_addon; }
double get_age() const { return m_age; }
private: private:
TOrbitId m_orbitid; TOrbitId m_orbitid;
Vect6 m_vec; Vect6 m_vec;
......
#include "orb_date.h"
#include "Propagator.h"
template<bool dir, typename vartype> struct cmppos : public std::binary_function<vartype, vartype, bool>
{
bool operator()(vartype s1, vartype s2) const
{
const TimeJD& v1 = s1.get_date();
const TimeJD& v2 = s2.get_date();
return (v1 == v2) ? false : (v1 < v2) ^ dir;
}
};
std::vector<TimeJD> generate_dates(const TimeJD& sdate, const TimeJD& edate, int step)
{
std::vector<TimeJD> result;
result.push_back(sdate);
if (sdate >= edate) {
return result;
}
int n = (int)(DaysInterval(sdate, edate) * 86400 / step);
for (int i = 0; i < n; ++i) {
result.push_back(ShiftDateX(sdate, step * (i + 1)));
}
if (result.back() != edate) {
result.push_back(edate);
}
return result;
}
IRes propagate_date(Propagator& prop, const TimeJD& date)
{
PhasePoint6D pos;
prop.Propagate(date, pos);
return IRes(pos.CoordsVel, date, 0, DaysInterval(prop.GetInitOrbit().GetDate(), date), prop.GetInitOrbit().GetId());
}
void propagate_dir(const SInitOrbit& orbit, const std::vector<TimeJD>& dates, int dir, std::vector<IRes>& result)
{
Propagator prop(orbit, false);
if (dir > 0) {
for (std::vector<TimeJD>::const_iterator it = dates.begin(); it != dates.end(); it++) {
result.push_back(propagate_date(prop, *it));
}
}
else if (dir < 0) {
for (std::vector<TimeJD>::const_reverse_iterator it = dates.rbegin(); it != dates.rend(); it++) {
result.push_back(propagate_date(prop, *it));
}
}
}
void split_dates(const std::vector<TimeJD>& dates, const TimeJD& date, std::vector<TimeJD>& dates_left, std::vector<TimeJD>& dates_right)
{
for (std::vector<TimeJD>::const_iterator it = dates.begin(); it != dates.end(); ++it) {
if (*it < date) {
dates_left.push_back(*it);
}
else {
dates_right.push_back(*it);
}
}
}
std::vector<IRes> calc_positions(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end, int step)
{
std::vector<IRes> result;
std::vector<TimeJD> dates = generate_dates(beg, end, step);
if (dates.empty()) {
return result;
}
TimeJD beg_ext = dates.front();
TimeJD end_ext = dates.back();
if (orbit.GetDate() <= beg_ext) {
propagate_dir(orbit, dates, 1, result);
}
else if (orbit.GetDate() >= end_ext) {
propagate_dir(orbit, dates, -1, result);
}
else {
std::vector<TimeJD> dates_left, dates_right;
split_dates(dates, orbit.GetDate(), dates_left, dates_right);
propagate_dir(orbit, dates_left, -1, result);
propagate_dir(orbit, dates_right, +1, result);
}
std::sort(result.begin(), result.end(), cmppos<false, IRes>());
return result;
}
#pragma once
#include "TM.h"
#include <vector>
#include "ires.h"
#include "StateVector.h"
std::vector<TimeJD> generate_dates(const TimeJD& sdate, const TimeJD& edate, int step);
std::vector<IRes> calc_positions(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end, int step);
\ No newline at end of file
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