Added setter functions to Timespan. At end of pass move time along by 20minutes.

feature/19
Daniel Warner 2011-06-10 21:09:02 +00:00
parent 8cba7f685f
commit 3ce723ded4
3 changed files with 42 additions and 12 deletions

View File

@ -138,10 +138,10 @@ void AOSLOS(const CoordGeodetic& user_geo, SGP4& sgp4, const Julian& start_time,
Observer obs(user_geo); Observer obs(user_geo);
Eci eci; Eci eci;
Timespan time_step; Timespan time_step(0, 0, 0, kPASS_TIME_STEP);
time_step.AddMinutes(kPASS_TIME_STEP);
bool first_run = true; bool first_run = true;
bool end_of_pass = false;
Julian previous_time = start_time; Julian previous_time = start_time;
Julian aos_time; Julian aos_time;
@ -187,17 +187,27 @@ void AOSLOS(const CoordGeodetic& user_geo, SGP4& sgp4, const Julian& start_time,
los_time = FindCrossingPoint(user_geo, sgp4, previous_time, current_time, false); los_time = FindCrossingPoint(user_geo, sgp4, previous_time, current_time, false);
found_aos = false; found_aos = false;
found_los = false; found_los = false;
end_of_pass = true;
double max_elevation = FindMaxElevation(user_geo, sgp4, aos_time, los_time); double max_elevation = FindMaxElevation(user_geo, sgp4, aos_time, los_time);
std::cout << "AOS: " << aos_time << ", LOS: " << los_time << ", Max El: " << RadiansToDegrees(max_elevation) << std::endl; std::cout << "AOS: " << aos_time << ", LOS: " << los_time << ", Max El: " << RadiansToDegrees(max_elevation) << std::endl;
} }
} }
first_run = false; first_run = false;
previous_time = current_time; previous_time = current_time;
// at end of pass, move time along by 20 minutes
if (end_of_pass)
current_time += Timespan(0, 0, 20, 0);
else
current_time += time_step; current_time += time_step;
// check we dont go past end time
if (current_time > end_time) if (current_time > end_time)
current_time = end_time; current_time = end_time;
end_of_pass = false;
}; };
/* /*

View File

@ -6,6 +6,12 @@ Timespan::Timespan()
: time_span_(0.0) { : time_span_(0.0) {
} }
Timespan::Timespan(const unsigned int days, const unsigned int hours,
const unsigned int minutes, const double seconds) {
SetValue(days, hours, minutes, seconds);
}
Timespan::Timespan(const double b) { Timespan::Timespan(const double b) {
time_span_ = b; time_span_ = b;
@ -18,16 +24,25 @@ Timespan::Timespan(const Timespan& b) {
Timespan::~Timespan(void) { Timespan::~Timespan(void) {
} }
void Timespan::AddDays(const double days) { void Timespan::SetValue(const unsigned int days, const unsigned int hours,
time_span_ += days; const unsigned int minutes, const double seconds) {
time_span_ = static_cast<double> (days);
AddHours(hours);
AddMinutes(minutes);
AddSeconds(seconds);
} }
void Timespan::AddHours(const double hours) { void Timespan::AddDays(const unsigned int days) {
time_span_ += (hours / kHOURS_PER_DAY); time_span_ += static_cast<double> (days);
} }
void Timespan::AddMinutes(const double minutes) { void Timespan::AddHours(const unsigned int hours) {
time_span_ += (minutes / kMINUTES_PER_DAY); time_span_ += (static_cast<double> (hours) / kHOURS_PER_DAY);
}
void Timespan::AddMinutes(const unsigned int minutes) {
time_span_ += (static_cast<double> (minutes) / kMINUTES_PER_DAY);
} }
void Timespan::AddSeconds(const double seconds) { void Timespan::AddSeconds(const double seconds) {

View File

@ -4,13 +4,18 @@
class Timespan { class Timespan {
public: public:
Timespan(); Timespan();
Timespan(const unsigned int days, const unsigned int hours,
const unsigned int minutes, const double seconds);
Timespan(const double b); Timespan(const double b);
Timespan(const Timespan& b); Timespan(const Timespan& b);
virtual ~Timespan(void); virtual ~Timespan(void);
void AddDays(const double days); void SetValue(const unsigned int days, const unsigned int hours,
void AddHours(const double hours); const unsigned int minutes, const double seconds);
void AddMinutes(const double minutes);
void AddDays(const unsigned int days);
void AddHours(const unsigned int hours);
void AddMinutes(const unsigned int minutes);
void AddSeconds(const double seconds); void AddSeconds(const double seconds);
double GetTotalDays() const; double GetTotalDays() const;