25#include "internal/egm96Coeffs.hpp"
57template<std::
floating_po
int Scalar>
61 auto g_0 = 9.7803253359 * (1.0 + 1.931853e-3 * std::pow(std::sin(latitude), 2))
72 return { 0.0, 0.0, k * g_0 };
82template<std::
floating_po
int Scalar>
95 return { 0, 0, gravitationMagnitude };
105template<std::
floating_po
int Scalar>
116 - std::pow(
InsConst::omega_ie, 2.0) * radiusSpheroid * std::pow(std::cos(latitudeGeocentric), 2.0);
118 return { 0, 0, gravitationMagnitude };
128template<
typename Derived>
129[[nodiscard]] Eigen::Vector3<typename Derived::Scalar>
n_calcGravitation_EGM96(
const Eigen::MatrixBase<Derived>& lla_position,
size_t ndegree = 10)
134 auto e_position = trafo::lla2ecef_WGS84(lla_position);
137 auto latitudeGeocentric = std::atan(e_position(2) / std::sqrt(e_position(0) * e_position(0) + e_position(1) * e_position(1)));
140 auto radius = std::sqrt(e_position(0) * e_position(0) + e_position(1) * e_position(1) + e_position(2) * e_position(2));
141 auto elevation = M_PI_2 - latitudeGeocentric;
142 auto azimuth = lla_position(1);
145 Eigen::Vector3<typename Derived::Scalar> n_gravitation = Eigen::Vector3<typename Derived::Scalar>::Zero();
147 typename Derived::Scalar Pnm = 0;
148 typename Derived::Scalar Pnmd = 0;
150 auto coeffsRows = egm96Coeffs.size();
153 auto [P, Pd] = associatedLegendre(
static_cast<double>(elevation), ndegree);
155 for (
size_t i = 0; i < coeffsRows; i++)
158 auto n =
static_cast<int>(egm96Coeffs.at(i).at(0));
159 auto m =
static_cast<int>(egm96Coeffs.at(i).at(1));
160 auto C = egm96Coeffs.at(i).at(2);
161 auto S = egm96Coeffs.at(i).at(3);
163 if (
static_cast<size_t>(n) == ndegree + 1)
174 auto nd =
static_cast<double>(n);
175 auto md =
static_cast<double>(m);
178 n_gravitation(0) += std::pow((
InsConst::WGS84::a / radius), nd) * (C * std::cos(md * azimuth) + S * std::sin(md * azimuth)) * Pnmd;
179 n_gravitation(1) += std::pow((
InsConst::WGS84::a / radius), nd) * md * (C * std::sin(md * azimuth) - S * std::cos(md * azimuth)) * Pnm;
180 n_gravitation(2) += (nd + 1.0) * std::pow((
InsConst::WGS84::a / radius), nd) * (C * std::cos(md * azimuth) + S * std::sin(md * azimuth)) * Pnm;
185 (1.0 / std::sin(elevation)) * (-
InsConst::WGS84::MU / (radius * radius)) * n_gravitation(1),
193template<
typename Derived>
194[[nodiscard]] Eigen::Vector3<typename Derived::Scalar>
n_calcGravitation(
const Eigen::MatrixBase<Derived>& lla_position,
197 const typename Derived::Scalar& latitude = lla_position(0);
198 const typename Derived::Scalar& altitude = lla_position(2);
200 if (gravitationModel == GravitationModel::WGS84)
204 if (gravitationModel == GravitationModel::WGS84_Skydel)
208 if (gravitationModel == GravitationModel::Somigliana)
212 if (gravitationModel == GravitationModel::EGM96)
216 return Eigen::Vector3<typename Derived::Scalar>::Zero();
Associated Legendre Polynomials for EGM96.
Transformation collection.
@ None
None.
Definition GlobalActions.hpp:21
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:194
GravitationModel
Available Gravitation Models.
Definition Gravity.hpp:31
@ WGS84_Skydel
World Geodetic System 1984 implemented by the Skydel Simulator // FIXME: Remove after Skydel uses the...
@ WGS84
World Geodetic System 1984.
@ EGM96
Earth Gravitational Model 1996.
@ Somigliana
Somigliana gravity model.
Eigen::Vector3< Scalar > n_calcGravitation_WGS84(const Scalar &latitude, const Scalar &altitude)
Calculates the gravitation (acceleration due to mass attraction of the Earth) at the WGS84 reference ...
Definition Gravity.hpp:106
Eigen::Vector3< Scalar > n_calcGravitation_SomiglianaAltitude(const Scalar &latitude, const Scalar &altitude)
Calculates the gravitation (acceleration due to mass attraction of the Earth) at the WGS84 reference ...
Definition Gravity.hpp:58
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:129
Eigen::Vector3< Scalar > n_calcGravitation_WGS84_Skydel(const Scalar &latitude, const Scalar &altitude)
Calculates the gravitation (acceleration due to mass attraction of the Earth) at the WGS84 reference ...
Definition Gravity.hpp:83
@ COUNT
Amount of items in the enum.
Utility class for logging to console and file.
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::MatrixXd, Eigen::MatrixXd > associatedLegendre(double theta, size_t ndegree=10)
Calculates the associated Legendre Polynomial coefficients necessary for the EGM96.