diff --git a/PassPredict.cpp b/PassPredict.cpp index e4abe4d..867d2eb 100755 --- a/PassPredict.cpp +++ b/PassPredict.cpp @@ -138,10 +138,10 @@ void AOSLOS(const CoordGeodetic& user_geo, SGP4& sgp4, const Julian& start_time, Observer obs(user_geo); Eci eci; - Timespan time_step; - time_step.AddMinutes(kPASS_TIME_STEP); + Timespan time_step(0, 0, 0, kPASS_TIME_STEP); bool first_run = true; + bool end_of_pass = false; Julian previous_time = start_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); found_aos = false; found_los = false; + end_of_pass = true; 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; + } } first_run = false; previous_time = current_time; - current_time += time_step; + // 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; + + // check we dont go past end time if (current_time > end_time) current_time = end_time; + + end_of_pass = false; }; /* diff --git a/Timespan.cpp b/Timespan.cpp index 261b46e..4440475 100755 --- a/Timespan.cpp +++ b/Timespan.cpp @@ -6,6 +6,12 @@ Timespan::Timespan() : 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) { time_span_ = b; @@ -18,16 +24,25 @@ Timespan::Timespan(const Timespan& b) { Timespan::~Timespan(void) { } -void Timespan::AddDays(const double days) { - time_span_ += days; +void Timespan::SetValue(const unsigned int days, const unsigned int hours, + const unsigned int minutes, const double seconds) { + + time_span_ = static_cast (days); + AddHours(hours); + AddMinutes(minutes); + AddSeconds(seconds); } -void Timespan::AddHours(const double hours) { - time_span_ += (hours / kHOURS_PER_DAY); +void Timespan::AddDays(const unsigned int days) { + time_span_ += static_cast (days); } -void Timespan::AddMinutes(const double minutes) { - time_span_ += (minutes / kMINUTES_PER_DAY); +void Timespan::AddHours(const unsigned int hours) { + time_span_ += (static_cast (hours) / kHOURS_PER_DAY); +} + +void Timespan::AddMinutes(const unsigned int minutes) { + time_span_ += (static_cast (minutes) / kMINUTES_PER_DAY); } void Timespan::AddSeconds(const double seconds) { diff --git a/Timespan.h b/Timespan.h index b1e68dc..6f7b253 100755 --- a/Timespan.h +++ b/Timespan.h @@ -4,13 +4,18 @@ class Timespan { public: Timespan(); + Timespan(const unsigned int days, const unsigned int hours, + const unsigned int minutes, const double seconds); Timespan(const double b); Timespan(const Timespan& b); virtual ~Timespan(void); - void AddDays(const double days); - void AddHours(const double hours); - void AddMinutes(const double minutes); + void SetValue(const unsigned int days, const unsigned int hours, + const unsigned int minutes, const double seconds); + + void AddDays(const unsigned int days); + void AddHours(const unsigned int hours); + void AddMinutes(const unsigned int minutes); void AddSeconds(const double seconds); double GetTotalDays() const;