lla; fix conversion to ECEF

This commit is contained in:
bresch
2024-12-02 18:17:17 +01:00
committed by Mathieu Bresciani
parent 4696338d29
commit 6b637f82f8
2 changed files with 15 additions and 1 deletions

View File

@@ -77,7 +77,7 @@ Vector3d LatLonAlt::toEcef() const
return Vector3d(r_total * cos_lat * cos_lon,
r_total * cos_lat * sin_lon,
((1.0 - Wgs84::eccentricity2) * r_total) * sin_lat);
((1.0 - Wgs84::eccentricity2) * r_e + static_cast<double>(_altitude)) * sin_lat);
}
Vector3f LatLonAlt::computeAngularRateNavFrame(const Vector3f &v_ned) const

View File

@@ -105,3 +105,17 @@ TEST(TestLatLonAlt, subLatLonAlt)
EXPECT_NEAR(delta_pos(1), delta_pos_true(1), 1e-2);
EXPECT_EQ(delta_pos(2), delta_pos_true(2));
}
TEST(TestLatLonAlt, fromAndToECEF)
{
for (double lat = -M_PI; lat < M_PI; lat += M_PI / 4.0) {
for (double lon = -M_PI; lon < M_PI; lon += M_PI / 4.0) {
for (float alt = -500.f; alt < 8000.f; alt += 500.f) {
LatLonAlt lla(lat, lon, alt);
LatLonAlt res = LatLonAlt::fromEcef(lla.toEcef());
EXPECT_TRUE(!(lla - res).longerThan(10e-6f)) << "lat: " << lat << ", lon: " << lon << ", alt: " << alt;
}
}
}
}