calc.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. *openPilot Log - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020 Felix Turowsky
  4. *
  5. *This program is free software: you can redistribute it and/or modify
  6. *it under the terms of the GNU General Public License as published by
  7. *the Free Software Foundation, either version 3 of the License, or
  8. *(at your option) any later version.
  9. *
  10. *This program is distributed in the hope that it will be useful,
  11. *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. *GNU General Public License for more details.
  14. *
  15. *You should have received a copy of the GNU General Public License
  16. *along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef CALC_H
  19. #define CALC_H
  20. #include <QDateTime>
  21. #include <cmath>
  22. #include <QDebug>
  23. /*!
  24. * \brief The calc class provides functionality for various calculations that are performed
  25. * outside of the database. This includes tasks like converting different units and formats,
  26. * or functions calculating block time or night time.
  27. */
  28. class calc
  29. {
  30. public:
  31. static QTime blocktime(QTime tofb, QTime tonb);
  32. static QString minutes_to_string(QString blockminutes);
  33. static int string_to_minutes(QString time);
  34. static int time_to_minutes(QTime time);
  35. static double radToDeg(double rad);
  36. static double degToRad(double deg);
  37. static double radToNauticalMiles(double rad);
  38. static double greatCircleDistance(double lat1, double lon1, double lat2, double lon2);
  39. static QVector<QVector<double>> intermediatePointsOnGreatCircle(double lat1, double lon1, double lat2, double lon2, int tblk);
  40. static double solarElevation(QDateTime utc_time_point, double lat, double lon);
  41. static int calculateNightTime(QString dept, QString dest, QDateTime departureTime, int tblk);
  42. };
  43. #endif // CALC_H