public static List <Pass> CalculatePasses(Coordinate position, Tle satellite, EpochTime startTime, int accuracy = 15, int maxNumberOfDays = 5, Sgp4.wgsConstant wgs = Sgp4.wgsConstant.WGS_84) { List <Pass> results = new List <Pass>(); EpochTime epoch = new EpochTime(startTime); EpochTime end = new EpochTime(startTime); end.addDays(maxNumberOfDays); while (epoch < end) { Sgp4Data satPos = getSatPositionAtTime(satellite, epoch, wgs); if (SatFunctions.isSatVisible(position, 0.0, epoch, satPos)) { EpochTime passStart = new EpochTime(epoch); Point3d spherical = SatFunctions.calcSphericalCoordinate(position, epoch, satPos); double maxElevation = spherical.z; epoch.addTick(accuracy); satPos = getSatPositionAtTime(satellite, epoch, wgs); while (SatFunctions.isSatVisible(position, 0.0, epoch, satPos)) { spherical = SatFunctions.calcSphericalCoordinate(position, epoch, satPos); if (maxElevation < spherical.z) { maxElevation = spherical.z; } epoch.addTick(accuracy); } results.Add(new One_Sgp4.Pass(position, passStart, new EpochTime(epoch), maxElevation * 180.0 / pi)); } epoch.addTick(accuracy); } return(results); }
//! Calculate satellite position at a single point in time /*! * \param tle of satellite * \param EpochTime to calculate position * \param int WGS-Data to use 0 = WGS_72; 1 = WGS_84 * \return SGP4Data containing satellite position data */ public static Sgp4Data getSatPositionAtTime(Tle satellite, EpochTime atTime, Sgp4.wgsConstant wgs) { Sgp4 sgp4Propagator = new Sgp4(satellite, wgs); sgp4Propagator.runSgp4Cal(atTime, atTime, 1 / 60.0); return(sgp4Propagator.getResults()[0]); }
//! Convert to ECI /*! * \param double SidrealTime * \param WGSconstant default WGS_84 * \return point3D ECI-Position vector of the Coordinate */ public Point3d toECI(double siderealTime, Sgp4.wgsConstant wgs = Sgp4.wgsConstant.WGS_84) { double f = WGS_72.f; double a = WGS_72.radiusEarthKM; if (wgs == Sgp4.wgsConstant.WGS_84) { f = WGS_84.f; a = WGS_84.radiusEarthKM; } double srt = siderealTime + (toRadians * longitude); double lat_rad = toRadians * latitude; Point3d eciPos = new Point3d(); //oblate earth double c = 1.0 / (Math.Sqrt(1.0 + f * (f - 2.0) * (Math.Sin(lat_rad) * Math.Sin(lat_rad)))); double s = (1.0 - f) * (1.0 - f) * c; eciPos.x = a * c * Math.Cos(lat_rad) * Math.Cos(srt); eciPos.y = a * c * Math.Cos(lat_rad) * Math.Sin(srt); eciPos.z = a * s * Math.Sin(lat_rad); return(eciPos); }
//! Calculate Passes of a satellite for ceratin number of days from a starting time /*! * \param Coordinate position of observer * \param Tle satellite data * \param EpochTime of startpoint * \param int accuracy time between calculations default 15 seconds * \param int number of days to calculate default 5 days * \param int WGS-Data to use 0 = WGS_72; 1 = WGS_84 default WGS 84 * \return List<Pass> List of passes satellite is visible */ public static List <Pass> CalculatePasses(Coordinate position, Tle satellite, EpochTime startTime, int accuracy = 15, int maxNumberOfDays = 5, Sgp4.wgsConstant wgs = Sgp4.wgsConstant.WGS_84) { List <Pass> results = new List <Pass>(); EpochTime epoch = new EpochTime(startTime); EpochTime end = new EpochTime(startTime); end.addDays(maxNumberOfDays); while (epoch < end) { Sgp4Data satPos = getSatPositionAtTime(satellite, epoch, wgs); if (SatFunctions.isSatVisible(position, 0.0, epoch, satPos)) { Point3d spherical = SatFunctions.calcSphericalCoordinate(position, epoch, satPos); PassDetail startDetails = new PassDetail(new EpochTime(epoch), spherical.z, spherical.y, spherical.x); PassDetail maxEleDetails = new PassDetail(new EpochTime(epoch), spherical.z, spherical.y, spherical.x); //double maxElevation = spherical.z; epoch.addTick(accuracy); satPos = getSatPositionAtTime(satellite, epoch, wgs); while (spherical.z >= 0) //while (SatFunctions.isSatVisible(position, 0.0, epoch, satPos)) { spherical = SatFunctions.calcSphericalCoordinate(position, epoch, satPos); if (maxEleDetails.elevation < spherical.z) { maxEleDetails = new PassDetail(new EpochTime(epoch), spherical.z, spherical.y, spherical.x); } epoch.addTick(accuracy); satPos = getSatPositionAtTime(satellite, epoch, wgs); } PassDetail endDetails = new PassDetail(new EpochTime(epoch), spherical.z, spherical.y, spherical.x); results.Add(new One_Sgp4.Pass(position, startDetails, maxEleDetails, endDetails)); } epoch.addTick(accuracy); } return(results); }