diff --git a/QtRocket.ui b/QtRocket.ui index 91751eb..9cfd349 100644 --- a/QtRocket.ui +++ b/QtRocket.ui @@ -13,6 +13,10 @@ QtRocket + + + resources/qtrocket.pngresources/qtrocket.png + diff --git a/main.cpp b/main.cpp index ed45820..845cef4 100644 --- a/main.cpp +++ b/main.cpp @@ -12,9 +12,11 @@ int main(int argc, char *argv[]) // TODO: Only support US English at the moment. Anyone want to help translate? QTranslator translator; const QStringList uiLanguages = QLocale::system().uiLanguages(); - for (const QString &locale : uiLanguages) { + for (const QString &locale : uiLanguages) + { const QString baseName = "qtrocket_" + QLocale(locale).name(); - if (translator.load(":/i18n/" + baseName)) { + if (translator.load(":/i18n/" + baseName)) + { a.installTranslator(&translator); break; } diff --git a/qtrocket.pro b/qtrocket.pro index 5ec3737..c3c5d16 100644 --- a/qtrocket.pro +++ b/qtrocket.pro @@ -17,13 +17,17 @@ SOURCES += \ qcustomplot.cpp \ sim/AtmosphericModel.cpp \ sim/GravityModel.cpp \ + sim/Propagator.cpp \ + sim/RK4Solver.cpp \ sim/SphericalGeoidModel.cpp \ sim/SphericalGravityModel.cpp \ sim/USStandardAtmosphere.cpp \ sim/WindModel.cpp \ utils/BinMap.cpp \ utils/CurlConnection.cpp \ - utils/ThrustCurveAPI.cpp + utils/ThrustCurveAPI.cpp \ + utils/math/Quaternion.cpp \ + utils/math/Vector3.cpp HEADERS += \ QtRocket.h \ @@ -32,8 +36,11 @@ HEADERS += \ model/Thrustcurve.h \ qcustomplot.h \ sim/AtmosphericModel.h \ + sim/DESolver.h \ sim/GeoidModel.h \ sim/GravityModel.h \ + sim/Propagator.h \ + sim/RK4Solver.h \ sim/SphericalGeoidModel.h \ sim/SphericalGravityModel.h \ sim/USStandardAtmosphere.h \ @@ -41,7 +48,9 @@ HEADERS += \ utils/BinMap.h \ utils/CurlConnection.h \ utils/ThrustCurveAPI.h \ - utils/math/Constants.h + utils/math/Constants.h \ + utils/math/Quaternion.h \ + utils/math/Vector3.h FORMS += \ QtRocket.ui diff --git a/resources/qtrocket.png b/resources/qtrocket.png new file mode 100644 index 0000000..b41bf2b Binary files /dev/null and b/resources/qtrocket.png differ diff --git a/sim/DESolver.h b/sim/DESolver.h new file mode 100644 index 0000000..46b979d --- /dev/null +++ b/sim/DESolver.h @@ -0,0 +1,18 @@ +#ifndef SIM_DESOLVER_H +#define SIM_DESOLVER_H + +namespace sim +{ + +class DESolver +{ +public: + DESolver() {} + virtual ~DESolver() {} + + virtual double step(double curVal, double t, double dt) = 0; +}; + +} // namespace sim + +#endif // SIM_DESOLVER_H diff --git a/sim/Propagator.cpp b/sim/Propagator.cpp new file mode 100644 index 0000000..43cdaef --- /dev/null +++ b/sim/Propagator.cpp @@ -0,0 +1,10 @@ +#include "Propagator.h" + +namespace sim { + +Propagator::Propagator() +{ + +} + +} // namespace sim diff --git a/sim/Propagator.h b/sim/Propagator.h new file mode 100644 index 0000000..0662b0b --- /dev/null +++ b/sim/Propagator.h @@ -0,0 +1,18 @@ +#ifndef SIM_PROPAGATOR_H +#define SIM_PROPAGATOR_H + + +namespace sim +{ + +class Propagator +{ +public: + Propagator(); + +private: +}; + +} // namespace sim + +#endif // SIM_PROPAGATOR_H diff --git a/sim/RK4Solver.cpp b/sim/RK4Solver.cpp new file mode 100644 index 0000000..c6ef857 --- /dev/null +++ b/sim/RK4Solver.cpp @@ -0,0 +1,19 @@ +#include "RK4Solver.h" + +namespace sim { + +double RK4Solver::step(double curVal, double t, double dt) +{ + double retVal(0.0); + + k1 = de(t, curVal); + k2 = de(t + dt / 2.0, curVal + (dt * k1 / 2.0)); + k3 = de(t + dt / 2.0, curVal + (dt * k2 / 2.0)); + k4 = de(t + dt, curVal + dt * k3); + retVal = curVal + (1.0 / 6.0)*dt*(k1 + 2.0*k2 + 2.0*k3 + k4); + + return retVal; +} + + +} // namespace sim diff --git a/sim/RK4Solver.h b/sim/RK4Solver.h new file mode 100644 index 0000000..2c89a5e --- /dev/null +++ b/sim/RK4Solver.h @@ -0,0 +1,27 @@ +#ifndef SIM_RK4SOLVER_H +#define SIM_RK4SOLVER_H + +#include "DESolver.h" + +#include + +namespace sim { + +class RK4Solver : public DESolver +{ +public: + RK4Solver(const std::function& d) : de(d) {} + virtual ~RK4Solver() {} + + virtual double step(double curVal, double t, double dt) override; + +private: + std::function de; + + double k1, k2, k3, k4; + +}; + +} // namespace sim + +#endif // SIM_RK4SOLVER_H diff --git a/utils/math/Quaternion.cpp b/utils/math/Quaternion.cpp new file mode 100644 index 0000000..4c23d11 --- /dev/null +++ b/utils/math/Quaternion.cpp @@ -0,0 +1,11 @@ +#include "Quaternion.h" + +namespace math +{ + +Quaternion::Quaternion() +{ + +} + +} // namespace math diff --git a/utils/math/Quaternion.h b/utils/math/Quaternion.h new file mode 100644 index 0000000..25fd934 --- /dev/null +++ b/utils/math/Quaternion.h @@ -0,0 +1,32 @@ +#ifndef MATH_QUATERNION_H +#define MATH_QUATERNION_H + +#include "Vector3.h" + +namespace math +{ + +class Quaternion +{ +public: + Quaternion(); + + Quaternion(double r, const Vector3& i); + Quaternion(double r, double i1, double i2, double i3); + + ~Quaternion(); + + Quaternion operator-(); + Quaternion operator-(const Quaternion& rhs); + Quaternion operator+(const Quaternion& rhs); + Quaternion operator*(double s); + Quaternion operator*(const Quaternion& rhs); + +private: + double real; + Vector3 imag; +}; + +} // namespace math + +#endif // MATH_QUATERNION_H diff --git a/utils/math/Vector3.cpp b/utils/math/Vector3.cpp new file mode 100644 index 0000000..05282ad --- /dev/null +++ b/utils/math/Vector3.cpp @@ -0,0 +1,66 @@ +#include "Vector3.h" + +namespace math +{ + +Vector3::Vector3() + : x1(0.0), + x2(0.0), + x3(0.0) +{ + +} + +Vector3::Vector3(const double& inX1, + const double& inX2, + const double& inX3) + : x1(inX1), + x2(inX2), + x3(inX3) +{ + +} + +Vector3::Vector3(const Vector3& o) + : x1(o.x1), + x2(o.x2), + x3(o.x3) +{ + +} + +Vector3::~Vector3() +{} + +Vector3 Vector3::operator=(const Vector3& rhs) +{ + return Vector3(rhs.x1, rhs.x2, rhs.x3); +} + +Vector3 Vector3::operator-() +{ + return Vector3(-x1, -x2, -x3); +} + +Vector3 Vector3::operator-(const Vector3& rhs) +{ + return Vector3(x1 - rhs.x1, + x2 - rhs.x2, + x3 - rhs.x3); +} + +Vector3 Vector3::operator+(const Vector3& rhs) +{ + return Vector3(x1 + rhs.x1, + x2 + rhs.x2, + x3 + rhs.x3); +} + +Vector3 Vector3::operator*(const double& s) +{ + return Vector3(x1 * s, + x2 * s, + x3 * s); +} + +} // namespace math diff --git a/utils/math/Vector3.h b/utils/math/Vector3.h new file mode 100644 index 0000000..5dc7f39 --- /dev/null +++ b/utils/math/Vector3.h @@ -0,0 +1,40 @@ +#ifndef MATH_VECTOR3_H +#define MATH_VECTOR3_H + + +namespace math +{ + +class Vector3 +{ +public: + Vector3(); + Vector3(const double& inX1, + const double& inX2, + const double& inX3); + + Vector3(const Vector3& o); + + ~Vector3(); + + Vector3 operator=(const Vector3& rhs); + + Vector3 operator-(); + Vector3 operator-(const Vector3& rhs); + Vector3 operator+(const Vector3& rhs); + Vector3 operator*(const double& s); + + double getX1() { return x1; } + double getX2() { return x2; } + double getX3() { return x3; } + + +private: + double x1; + double x2; + double x3; +}; + +} // namespace math + +#endif // MATH_VECTOR3_H