24#include "internal/egm96Coeffs.hpp"
60 auto g_0 = 9.7803253359 * (1.0 + 1.931853e-3 * std::pow(std::sin(latitude), 2))
71 return { T(0.0), T(0.0), k * g_0 };
94 return { T(0.0), T(0.0), gravitationMagnitude };
115 - std::pow(
InsConst::omega_ie, 2.0) * radiusSpheroid * std::pow(std::cos(latitudeGeocentric), 2.0);
117 return { T(0.0), T(0.0), gravitationMagnitude };
127template<
typename Derived>
128[[nodiscard]] Eigen::Vector3<typename Derived::Scalar>
n_calcGravitation_EGM96(
const Eigen::MatrixBase<Derived>& lla_position,
size_t ndegree = 10)
136 auto latitudeGeocentric = std::atan(e_position(2) / std::sqrt(e_position(0) * e_position(0) + e_position(1) * e_position(1)));
139 auto radius = std::sqrt(e_position(0) * e_position(0) + e_position(1) * e_position(1) + e_position(2) * e_position(2));
140 auto elevation = M_PI_2 - latitudeGeocentric;
141 const auto& azimuth = lla_position(1);
144 Eigen::Vector3<typename Derived::Scalar> n_gravitation = Eigen::Vector3<typename Derived::Scalar>::Zero();
146 typename Derived::Scalar Pnm(0.0);
147 typename Derived::Scalar Pnmd(0.0);
149 auto coeffsRows = egm96Coeffs.size();
152 auto [P, Pd] = associatedLegendre(elevation, ndegree);
154 for (
size_t i = 0; i < coeffsRows; i++)
157 auto n =
static_cast<int>(egm96Coeffs.at(i).at(0));
158 auto m =
static_cast<int>(egm96Coeffs.at(i).at(1));
159 auto C = egm96Coeffs.at(i).at(2);
160 auto S = egm96Coeffs.at(i).at(3);
162 if (
static_cast<size_t>(n) == ndegree + 1)
173 auto nd =
static_cast<double>(n);
174 auto md =
static_cast<double>(m);
177 n_gravitation(0) += std::pow((
InsConst::WGS84::a / radius), nd) * (C * std::cos(md * azimuth) + S * std::sin(md * azimuth)) * Pnmd;
178 n_gravitation(1) += std::pow((
InsConst::WGS84::a / radius), nd) * md * (C * std::sin(md * azimuth) - S * std::cos(md * azimuth)) * Pnm;
179 n_gravitation(2) += (nd + 1.0) * std::pow((
InsConst::WGS84::a / radius), nd) * (C * std::cos(md * azimuth) + S * std::sin(md * azimuth)) * Pnm;
184 (1.0 / std::sin(elevation)) * (-
InsConst::WGS84::MU / (radius * radius)) * n_gravitation(1),
192template<
typename Derived>
193[[nodiscard]] Eigen::Vector3<typename Derived::Scalar>
n_calcGravitation(
const Eigen::MatrixBase<Derived>& lla_position,
196 const typename Derived::Scalar& latitude = lla_position(0);
197 const typename Derived::Scalar& altitude = lla_position(2);
215 return Eigen::Vector3<typename Derived::Scalar>::Zero();
Associated Legendre Polynomials for EGM96.
Transformation collection.
Eigen::Vector3< typename Derived::Scalar > lla2ecef_WGS84(const Eigen::MatrixBase< Derived > &lla_position)
Converts latitude, longitude and altitude into Earth-centered-Earth-fixed coordinates using WGS84.
Definition CoordinateFrames.hpp:402
Eigen::Vector3< typename Derived::Scalar > n_calcGravitation(const Eigen::MatrixBase< Derived > &lla_position, GravitationModel gravitationModel=GravitationModel::EGM96)
Calculates the gravitation (acceleration due to mass attraction of the Earth)
Definition Gravity.hpp:193
Eigen::Vector3< T > n_calcGravitation_WGS84(const T &latitude, const T &altitude)
Calculates the gravitation (acceleration due to mass attraction of the Earth) at the WGS84 reference ...
Definition Gravity.hpp:105
Eigen::Vector3< T > n_calcGravitation_WGS84_Skydel(const T &latitude, const T &altitude)
Calculates the gravitation (acceleration due to mass attraction of the Earth) at the WGS84 reference ...
Definition Gravity.hpp:82
GravitationModel
Available Gravitation Models.
Definition Gravity.hpp:30
@ WGS84_Skydel
World Geodetic System 1984 implemented by the Skydel Simulator // FIXME: Remove after Skydel uses the...
Definition Gravity.hpp:33
@ WGS84
World Geodetic System 1984.
Definition Gravity.hpp:32
@ EGM96
Earth Gravitational Model 1996.
Definition Gravity.hpp:35
@ Somigliana
Somigliana gravity model.
Definition Gravity.hpp:34
bool ComboGravitationModel(const char *label, GravitationModel &gravitationModel)
Shows a ComboBox to select the gravitation model.
Eigen::Vector3< typename Derived::Scalar > n_calcGravitation_EGM96(const Eigen::MatrixBase< Derived > &lla_position, size_t ndegree=10)
Calculates the gravitation (acceleration due to mass attraction of the Earth) at the WGS84 reference ...
Definition Gravity.hpp:128
Eigen::Vector3< T > n_calcGravitation_SomiglianaAltitude(const T &latitude, const T &altitude)
Calculates the gravitation (acceleration due to mass attraction of the Earth) at the WGS84 reference ...
Definition Gravity.hpp:57
@ COUNT
Amount of items in the enum.
Definition Ionosphere.hpp:31
@ None
Ionosphere model turned off.
Definition Ionosphere.hpp:29
static constexpr double f
Flattening f = (a-b)/a.
Definition Constants.hpp:52
static constexpr double J2
Dynamic form factor, derived [-].
Definition Constants.hpp:60
static constexpr double b
Semi-minor axis = polar radius.
Definition Constants.hpp:54
static constexpr double MU
Gravitational constant (mass of Earth’s atmosphere included) [m³/s²].
Definition Constants.hpp:58
static constexpr double a
Semi-major axis = equatorial radius.
Definition Constants.hpp:50
static constexpr double e_squared
Square of the first eccentricity of the ellipsoid.
Definition Constants.hpp:56
static constexpr double omega_ie
Nominal mean angular velocity of the Earth in [rad/s].
Definition Constants.hpp:217
static constexpr double omega_ie_Skydel
Nominal mean angular velocity of the Earth in [rad/s]. Value implemented by the Skydel GNSS simulator...
Definition Constants.hpp:219
std::array< std::array< double, 6 >, 65338 > egm96Coeffs
EGM96 coefficients.
std::pair< Eigen::MatrixX< T >, Eigen::MatrixX< T > > associatedLegendre(const T &theta, size_t ndegree=10)
Calculates the associated Legendre Polynomial coefficients necessary for the EGM96.
Definition AssociatedLegendre.hpp:33