diff --git a/model/Rocket.cpp b/model/Rocket.cpp index d83535e..180e1b9 100644 --- a/model/Rocket.cpp +++ b/model/Rocket.cpp @@ -23,6 +23,14 @@ void Rocket::launch() propagator.runUntilTerminate(); } +bool Rocket::terminateCondition(const std::pair>& cond) +{ + if(cond.second[2] < 0) + return true; + else + return false; +} + double Rocket::getThrust(double t) { return tc.getThrust(t); diff --git a/model/Rocket.h b/model/Rocket.h index 4382af5..44a705c 100644 --- a/model/Rocket.h +++ b/model/Rocket.h @@ -25,6 +25,8 @@ public: double getThrust(double t); void setThrustCurve(const Thrustcurve& curve); + + bool terminateCondition(const std::pair>& cond); private: sim::Propagator propagator; diff --git a/sim/Propagator.cpp b/sim/Propagator.cpp index 23f1272..a2fcf23 100644 --- a/sim/Propagator.cpp +++ b/sim/Propagator.cpp @@ -60,7 +60,7 @@ void Propagator::runUntilTerminate() { states.push_back(std::make_pair(currentTime, currentState)); } - if(currentState[2] < 0.0) + if(rocket->terminateCondition(std::make_pair(currentTime, currentState))) break; currentTime += timeStep;