0.2.0
Loading...
Searching...
No Matches
Units.hpp
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
14namespace NAV
15{
16
20template<class T>
21[[nodiscard]] constexpr auto deg2rad(const T& deg)
22{
23 return deg * std::numbers::pi_v<double> / 180.0;
24}
25
29template<typename Scalar>
30[[nodiscard]] inline Eigen::Vector3<Scalar> deg2rad(const Eigen::Vector3<Scalar>& deg)
31{
32 return deg * std::numbers::pi_v<Scalar> / 180.0;
33}
34
38template<class T>
39[[nodiscard]] constexpr auto rad2deg(const T& rad)
40{
41 return rad * 180.0 / std::numbers::pi_v<double>;
42}
43
47template<typename Scalar>
48[[nodiscard]] inline Eigen::Vector3<Scalar> rad2deg(const Eigen::Vector3<Scalar>& rad)
49{
50 return rad * 180.0 / std::numbers::pi_v<Scalar>;
51}
52
56template<class T>
57[[nodiscard]] constexpr auto semicircles2rad(const T& semicircles)
58{
59 return semicircles * std::numbers::pi_v<double>;
60}
61
65template<class T>
66[[nodiscard]] constexpr auto rad2semicircles(const T& rad)
67{
68 return rad / std::numbers::pi_v<double>;
69}
70
72constexpr long double operator"" _deg(long double deg)
73{
74 return deg2rad(deg);
75}
76
78constexpr long double operator"" _mas(long double mas)
79{
80 return mas * std::numbers::pi_v<long double> / 648000000.0L;
81}
82
84constexpr 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
90constexpr long double operator"" _ppb(long double ppb)
91{
92 return ppb * 1e-9L;
93}
94
96constexpr 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