getGroundTrack method
Gets a polygon on the surface of the planet where a satellite
or flying object can see.
satellite
Altitude must be in Kilometers and positive (altitude > 0).
Implementation
List<LatLng> getGroundTrack(
LatLngAlt satellite, {
double precesion = 1,
}) {
final zone = <LatLng>[];
final latitude = satellite.latitude.radians;
final longitude = satellite.longitude.radians;
final temp = satellite.altitude;
if (temp <= 0) {
throw Exception('Altitude must be higher then 0 ($temp).');
}
final altitude = radius + temp;
final cosLat = cos(latitude);
final sinLat = sin(latitude);
double asocAlt = acos(radius / altitude);
if (asocAlt.isNaN) {
asocAlt = 0.0;
}
final cosAlt = cos(asocAlt);
final sinAlt = sin(asocAlt);
int i = 0;
do {
final angle = pi / 180.0 * i;
final lat = asin(sinLat * cosAlt + cos(angle) * sinAlt * cosLat);
final num9 = (cosAlt - sinLat * sin(lat)) / (cosLat * cos(lat));
final lng = (((i != 0 || !(asocAlt > pi / 2.0 - latitude)) && 0 == 0)
? (((i == 180 && asocAlt > pi / 2.0 + latitude))
? (longitude + pi)
: ((num9.abs() > 1.0)
? longitude
: ((i > 180)
? (longitude - acos(num9))
: (longitude + acos(num9)))))
: (longitude + pi));
final z = LatLng(
Angle.radian(lat),
Angle.radian(lng),
);
zone.add(z);
i++;
} while (i <= 359);
zone.add(
LatLng(
zone[0].latitude,
zone[0].longitude,
),
);
return zone;
}