| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This file is part of INSTINCT, the INS Toolkit for Integrated | ||
| 2 | // Navigation Concepts and Training by the Institute of Navigation of | ||
| 3 | // the University of Stuttgart, Germany. | ||
| 4 | // | ||
| 5 | // This Source Code Form is subject to the terms of the Mozilla Public | ||
| 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| 7 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include <numbers> | ||
| 12 | #include <Eigen/Core> | ||
| 13 | |||
| 14 | namespace NAV | ||
| 15 | { | ||
| 16 | |||
| 17 | /// @brief Convert Degree to Radians | ||
| 18 | /// @param[in] deg Value to convert in [deg] | ||
| 19 | /// @return The converted value in [rad] | ||
| 20 | template<class T> | ||
| 21 | 59423262 | [[nodiscard]] constexpr auto deg2rad(const T& deg) | |
| 22 | { | ||
| 23 |
2/4✓ Branch 1 taken 130452 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 130452 times.
✗ Branch 5 not taken.
|
59423262 | return deg * std::numbers::pi_v<double> / 180.0; |
| 24 | } | ||
| 25 | |||
| 26 | /// @brief Convert Degree to Radians | ||
| 27 | /// @param[in] deg Value to convert in [deg] | ||
| 28 | /// @return The converted value in [rad] | ||
| 29 | template<typename Scalar> | ||
| 30 | 72881 | [[nodiscard]] inline Eigen::Vector3<Scalar> deg2rad(const Eigen::Vector3<Scalar>& deg) | |
| 31 | { | ||
| 32 |
3/6✓ Branch 1 taken 72881 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72881 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 72881 times.
✗ Branch 8 not taken.
|
72881 | return deg * std::numbers::pi_v<double> / 180.0; |
| 33 | } | ||
| 34 | |||
| 35 | /// @brief Convert Radians to Degree | ||
| 36 | /// @param[in] rad Value to convert in [rad] | ||
| 37 | /// @return The converted value in [deg] | ||
| 38 | template<class T> | ||
| 39 | 761665 | [[nodiscard]] constexpr auto rad2deg(const T& rad) | |
| 40 | { | ||
| 41 | 761665 | return rad * 180.0 / std::numbers::pi_v<double>; | |
| 42 | } | ||
| 43 | |||
| 44 | /// @brief Convert Radians to Degree | ||
| 45 | /// @param[in] rad Value to convert in [rad] | ||
| 46 | /// @return The converted value in [deg] | ||
| 47 | template<typename Scalar> | ||
| 48 | 1058611 | [[nodiscard]] inline Eigen::Vector3<Scalar> rad2deg(const Eigen::Vector3<Scalar>& rad) | |
| 49 | { | ||
| 50 |
3/6✓ Branch 1 taken 1058611 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1058611 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1058611 times.
✗ Branch 8 not taken.
|
2117222 | return rad * 180.0 / std::numbers::pi_v<double>; |
| 51 | } | ||
| 52 | |||
| 53 | /// @brief Convert Semicircles to Radians | ||
| 54 | /// @param[in] semicircles Value to convert in [semicircles] | ||
| 55 | /// @return The converted value in [rad] | ||
| 56 | template<class T> | ||
| 57 | 284872 | [[nodiscard]] constexpr auto semicircles2rad(const T& semicircles) | |
| 58 | { | ||
| 59 | 284872 | return semicircles * std::numbers::pi_v<double>; | |
| 60 | } | ||
| 61 | |||
| 62 | /// @brief Convert Radians to Semicircles | ||
| 63 | /// @param[in] rad Value to convert in [rad] | ||
| 64 | /// @return The converted value in [semicircles] | ||
| 65 | template<class T> | ||
| 66 | 422463 | [[nodiscard]] constexpr auto rad2semicircles(const T& rad) | |
| 67 | { | ||
| 68 | 422463 | return rad / std::numbers::pi_v<double>; | |
| 69 | } | ||
| 70 | |||
| 71 | /// @brief Converts [degree] to [radian] | ||
| 72 | 953 | constexpr long double operator"" _deg(long double deg) | |
| 73 | { | ||
| 74 | 953 | return deg2rad(deg); | |
| 75 | } | ||
| 76 | |||
| 77 | /// @brief Converts [milliarcseconds] to [radian] | ||
| 78 | constexpr long double operator"" _mas(long double mas) | ||
| 79 | { | ||
| 80 | return mas * std::numbers::pi_v<long double> / 648000000.0L; | ||
| 81 | } | ||
| 82 | |||
| 83 | /// @brief Converts [milliarcseconds] to [radian] | ||
| 84 | constexpr long double operator"" _mas(unsigned long long mas) // NOLINT(google-runtime-int) | ||
| 85 | { | ||
| 86 | return static_cast<long double>(mas) * std::numbers::pi_v<long double> / 648000000.0L; | ||
| 87 | } | ||
| 88 | |||
| 89 | /// @brief Parts per billion | ||
| 90 | constexpr long double operator"" _ppb(long double ppb) | ||
| 91 | { | ||
| 92 | return ppb * 1e-9L; | ||
| 93 | } | ||
| 94 | |||
| 95 | /// @brief Parts per billion | ||
| 96 | constexpr long double operator"" _ppb(unsigned long long ppb) // NOLINT(google-runtime-int) | ||
| 97 | { | ||
| 98 | return static_cast<long double>(ppb) * 1e-9L; | ||
| 99 | } | ||
| 100 | |||
| 101 | } // namespace NAV | ||
| 102 |