toEcf method
Implementation
EarthCenteredEarthFixed toEcf(Planet planet) {
final geodetic = this;
final longitude = geodetic.longitude.radians;
final latitude = geodetic.latitude.radians;
final height = geodetic.altitude;
final radius = planet.radius;
final f = planet.flattening;
final e2 = 2 * f - f * f;
final normal = radius / sqrt(1 - e2 * (sin(latitude) * sin(latitude)));
final x = (normal + height) * cos(latitude) * cos(longitude);
final y = (normal + height) * cos(latitude) * sin(longitude);
final z = (normal * (1 - e2) + height) * sin(latitude);
return EarthCenteredEarthFixed(x, y, z);
}