/// <summary>
    /// Convert Galactic Coordinates to Equatorial Coordinates
    /// </summary>
    /// <returns>Tuple (raHours, raMinutes, raSeconds, decDegrees, decMinutes, decSeconds)</returns>
    public (double raHours, double raMinutes, double raSeconds, double decDegrees, double decMinutes, double decSeconds) GalacticCoordinateToEquatorialCoordinate(double galLongDeg, double galLongMin, double galLongSec, double galLatDeg, double galLatMin, double galLatSec)
    {
        var glongDeg   = PAMacros.DegreesMinutesSecondsToDecimalDegrees(galLongDeg, galLongMin, galLongSec);
        var glatDeg    = PAMacros.DegreesMinutesSecondsToDecimalDegrees(galLatDeg, galLatMin, galLatSec);
        var glongRad   = glongDeg.ToRadians();
        var glatRad    = glatDeg.ToRadians();
        var sinDec     = glatRad.Cosine() * (27.4).ToRadians().Cosine() * (glongRad - (33.0).ToRadians()).Sine() + glatRad.Sine() * (27.4).ToRadians().Sine();
        var decRadians = sinDec.ASine();
        var decDeg     = PAMacros.Degrees(decRadians);
        var y          = glatRad.Cosine() * (glongRad - (33.0).ToRadians()).Cosine();
        var x          = glatRad.Sine() * ((27.4).ToRadians()).Cosine() - (glatRad).Cosine() * ((27.4).ToRadians()).Sine() * (glongRad - (33.0).ToRadians()).Sine();

        var raDeg1   = PAMacros.Degrees(y.AngleTangent2(x)) + 192.25;
        var raDeg2   = raDeg1 - 360 * (raDeg1 / 360).Floor();
        var raHours1 = PAMacros.DecimalDegreesToDegreeHours(raDeg2);

        var raHours    = PAMacros.DecimalHoursHour(raHours1);
        var raMinutes  = PAMacros.DecimalHoursMinute(raHours1);
        var raSeconds  = PAMacros.DecimalHoursSecond(raHours1);
        var decDegrees = PAMacros.DecimalDegreesDegrees(decDeg);
        var decMinutes = PAMacros.DecimalDegreesMinutes(decDeg);
        var decSeconds = PAMacros.DecimalDegreesSeconds(decDeg);

        return(raHours, raMinutes, raSeconds, decDegrees, decMinutes, decSeconds);
    }
예제 #2
0
    /// <summary>
    /// Calculate precise position of the Moon.
    /// </summary>
    /// <returns>
    /// <para>moonRAHour -- Right ascension of Moon (hour part)</para>
    /// <para>moonRAMin -- Right ascension of Moon (minutes part)</para>
    /// <para>moonRASec -- Right ascension of Moon (seconds part)</para>
    /// <para>moonDecDeg -- Declination of Moon (degrees part)</para>
    /// <para>moonDecMin -- Declination of Moon (minutes part)</para>
    /// <para>moonDecSec -- Declination of Moon (seconds part)</para>
    /// <para>earthMoonDistKM -- Distance from Earth to Moon (km)</para>
    /// <para>moonHorParallaxDeg -- Horizontal parallax of Moon (degrees)</para>
    /// </returns>
    public (double moonRAHour, double moonRAMin, double moonRASec, double moonDecDeg, double moonDecMin, double moonDecSec, double earthMoonDistKM, double moonHorParallaxDeg) PrecisePositionOfMoon(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var gdateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var moonResult = PAMacros.MoonLongLatHP(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var nutationInLongitudeDeg = PAMacros.NutatLong(gdateDay, gdateMonth, gdateYear);
        var correctedLongDeg       = moonResult.moonLongDeg + nutationInLongitudeDeg;
        var earthMoonDistanceKM    = 6378.14 / moonResult.moonHorPara.ToRadians().Sine();
        var moonRAHours1           = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(correctedLongDeg, 0, 0, moonResult.moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear));
        var moonDecDeg1            = PAMacros.EcDec(correctedLongDeg, 0, 0, moonResult.moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear);

        var moonRAHour         = PAMacros.DecimalHoursHour(moonRAHours1);
        var moonRAMin          = PAMacros.DecimalHoursMinute(moonRAHours1);
        var moonRASec          = PAMacros.DecimalHoursSecond(moonRAHours1);
        var moonDecDeg         = PAMacros.DecimalDegreesDegrees(moonDecDeg1);
        var moonDecMin         = PAMacros.DecimalDegreesMinutes(moonDecDeg1);
        var moonDecSec         = PAMacros.DecimalDegreesSeconds(moonDecDeg1);
        var earthMoonDistKM    = Math.Round(earthMoonDistanceKM, 0);
        var moonHorParallaxDeg = Math.Round(moonResult.moonHorPara, 6);

        return(moonRAHour, moonRAMin, moonRASec, moonDecDeg, moonDecMin, moonDecSec, earthMoonDistKM, moonHorParallaxDeg);
    }
    /// <summary>
    /// Convert Ecliptic Coordinates to Equatorial Coordinates
    /// </summary>
    /// <returns>Tuple (outRAHours, outRAMinutes, outRASeconds, outDecDegrees, outDecMinutes, outDecSeconds)</returns>
    public (double outRAHours, double outRAMinutes, double outRASeconds, double outDecDegrees, double outDecMinutes, double outDecSeconds) EclipticCoordinateToEquatorialCoordinate(double eclipticLongitudeDegrees, double eclipticLongitudeMinutes, double eclipticLongitudeSeconds, double eclipticLatitudeDegrees, double eclipticLatitudeMinutes, double eclipticLatitudeSeconds, double greenwichDay, int greenwichMonth, int greenwichYear)
    {
        var eclonDeg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(eclipticLongitudeDegrees, eclipticLongitudeMinutes, eclipticLongitudeSeconds);
        var eclatDeg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(eclipticLatitudeDegrees, eclipticLatitudeMinutes, eclipticLatitudeSeconds);
        var eclonRad = eclonDeg.ToRadians();
        var eclatRad = eclatDeg.ToRadians();
        var obliqDeg = PAMacros.Obliq(greenwichDay, greenwichMonth, greenwichYear);
        var obliqRad = obliqDeg.ToRadians();
        var sinDec   = eclatRad.Sine() * obliqRad.Cosine() + eclatRad.Cosine() * obliqRad.Sine() * eclonRad.Sine();
        var decRad   = sinDec.ASine();
        var decDeg   = PAMacros.Degrees(decRad);
        var y        = eclonRad.Sine() * obliqRad.Cosine() - eclatRad.Tangent() * obliqRad.Sine();
        var x        = eclonRad.Cosine();
        var raRad    = y.AngleTangent2(x);
        var raDeg1   = PAMacros.Degrees(raRad);
        var raDeg2   = raDeg1 - 360 * (raDeg1 / 360).Floor();
        var raHours  = PAMacros.DecimalDegreesToDegreeHours(raDeg2);

        var outRAHours    = PAMacros.DecimalHoursHour(raHours);
        var outRAMinutes  = PAMacros.DecimalHoursMinute(raHours);
        var outRASeconds  = PAMacros.DecimalHoursSecond(raHours);
        var outDecDegrees = PAMacros.DecimalDegreesDegrees(decDeg);
        var outDecMinutes = PAMacros.DecimalDegreesMinutes(decDeg);
        var outDecSeconds = PAMacros.DecimalDegreesSeconds(decDeg);

        return(outRAHours, outRAMinutes, outRASeconds, outDecDegrees, outDecMinutes, outDecSeconds);
    }
예제 #4
0
    /// <summary>
    /// Calculate approximate position of the sun for a local date and time.
    /// </summary>
    /// <param name="lctHours">Local civil time, in hours.</param>
    /// <param name="lctMinutes">Local civil time, in minutes.</param>
    /// <param name="lctSeconds">Local civil time, in seconds.</param>
    /// <param name="localDay">Local day, day part.</param>
    /// <param name="localMonth">Local day, month part.</param>
    /// <param name="localYear">Local day, year part.</param>
    /// <param name="isDaylightSaving">Is daylight savings in effect?</param>
    /// <param name="zoneCorrection">Time zone correction, in hours.</param>
    /// <returns>
    /// <para>sunRAHour -- Right Ascension of Sun, hour part</para>
    /// <para>sunRAMin -- Right Ascension of Sun, minutes part</para>
    /// <para>sunRASec -- Right Ascension of Sun, seconds part</para>
    /// <para>sunDecDeg -- Declination of Sun, degrees part</para>
    /// <para>sunDecMin -- Declination of Sun, minutes part</para>
    /// <para>sunDecSec -- Declination of Sun, seconds part</para>
    /// </returns>
    public (double sunRAHour, double sunRAMin, double sunRASec, double sunDecDeg, double sunDecMin, double sunDecSec) ApproximatePositionOfSun(double lctHours, double lctMinutes, double lctSeconds, double localDay, int localMonth, int localYear, bool isDaylightSaving, int zoneCorrection)
    {
        var daylightSaving = (isDaylightSaving == true) ? 1 : 0;

        var greenwichDateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var greenwichDateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var greenwichDateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var utHours            = PAMacros.LocalCivilTimeToUniversalTime(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var utDays             = utHours / 24;
        var jdDays             = PAMacros.CivilDateToJulianDate(greenwichDateDay, greenwichDateMonth, greenwichDateYear) + utDays;
        var dDays   = jdDays - PAMacros.CivilDateToJulianDate(0, 1, 2010);
        var nDeg    = 360 * dDays / 365.242191;
        var mDeg1   = nDeg + PAMacros.SunELong(0, 1, 2010) - PAMacros.SunPeri(0, 1, 2010);
        var mDeg2   = mDeg1 - 360 * (mDeg1 / 360).Floor();
        var eCDeg   = 360 * PAMacros.SunEcc(0, 1, 2010) * mDeg2.ToRadians().Sine() / Math.PI;
        var lSDeg1  = nDeg + eCDeg + PAMacros.SunELong(0, 1, 2010);
        var lSDeg2  = lSDeg1 - 360 * (lSDeg1 / 360).Floor();
        var raDeg   = PAMacros.EcRA(lSDeg2, 0, 0, 0, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);
        var raHours = PAMacros.DecimalDegreesToDegreeHours(raDeg);
        var decDeg  = PAMacros.EcDec(lSDeg2, 0, 0, 0, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);

        var sunRAHour = PAMacros.DecimalHoursHour(raHours);
        var sunRAMin  = PAMacros.DecimalHoursMinute(raHours);
        var sunRASec  = PAMacros.DecimalHoursSecond(raHours);
        var sunDecDeg = PAMacros.DecimalDegreesDegrees(decDeg);
        var sunDecMin = PAMacros.DecimalDegreesMinutes(decDeg);
        var sunDecSec = PAMacros.DecimalDegreesSeconds(decDeg);

        return(sunRAHour, sunRAMin, sunRASec, sunDecDeg, sunDecMin, sunDecSec);
    }
    /// <summary>
    /// Calculate position of a parabolic comet.
    /// </summary>
    /// <returns>
    /// cometRAHour -- Right ascension of comet (hour part)
    /// cometRAMin -- Right ascension of comet (minutes part)
    /// cometRASec -- Right ascension of comet (seconds part)
    /// cometDecDeg -- Declination of comet (degrees part)
    /// cometDecMin -- Declination of comet (minutes part)
    /// cometDecSec -- Declination of comet (seconds part)
    /// cometDistEarth -- Comet's distance from Earth (AU)
    /// </returns>
    /// <returns></returns>
    public (double cometRAHour, double cometRAMin, double cometRASec, double cometDecDeg, double cometDecMin, double cometDecSec, double cometDistEarth) PositionOfParabolicComet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string cometName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var greenwichDateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var greenwichDateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var greenwichDateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var cometInfo = CometInfoParabolic.GetCometParabolicInfo(cometName);

        var perihelionEpochDay   = cometInfo.EpochPeriDay;
        var perihelionEpochMonth = cometInfo.EpochPeriMonth;
        var perihelionEpochYear  = cometInfo.EpochPeriYear;
        var qAU            = cometInfo.PeriDist;
        var inclinationDeg = cometInfo.Incl;
        var perihelionDeg  = cometInfo.ArgPeri;
        var nodeDeg        = cometInfo.Node;

        var cometLongLatDist = PAMacros.PCometLongLatDist(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear, perihelionEpochDay, perihelionEpochMonth, perihelionEpochYear, qAU, inclinationDeg, perihelionDeg, nodeDeg);

        var cometRAHours = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(cometLongLatDist.cometLongDeg, 0, 0, cometLongLatDist.cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear));
        var cometDecDeg1 = PAMacros.EcDec(cometLongLatDist.cometLongDeg, 0, 0, cometLongLatDist.cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);

        var cometRAHour    = PAMacros.DecimalHoursHour(cometRAHours);
        var cometRAMin     = PAMacros.DecimalHoursMinute(cometRAHours);
        var cometRASec     = PAMacros.DecimalHoursSecond(cometRAHours);
        var cometDecDeg    = PAMacros.DecimalDegreesDegrees(cometDecDeg1);
        var cometDecMin    = PAMacros.DecimalDegreesMinutes(cometDecDeg1);
        var cometDecSec    = PAMacros.DecimalDegreesSeconds(cometDecDeg1);
        var cometDistEarth = Math.Round(cometLongLatDist.cometDistAU, 2);

        return(cometRAHour, cometRAMin, cometRASec, cometDecDeg, cometDecMin, cometDecSec, cometDistEarth);
    }
예제 #6
0
    /// <summary>
    /// Calculate solar elongation for a celestial body.
    /// </summary>
    /// <remarks>
    /// Solar elongation is the angle between the lines of sight from the Earth to the Sun and from the Earth to the celestial body.
    /// </remarks>
    /// <returns>solarElongationDeg -- Solar elongation, in degrees</returns>
    public double SolarElongation(double raHour, double raMin, double raSec, double decDeg, double decMin, double decSec, double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var sunLongitudeDeg    = PAMacros.SunLong(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var sunRAHours         = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(sunLongitudeDeg, 0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear));
        var sunDecDeg          = PAMacros.EcDec(sunLongitudeDeg, 0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var solarElongationDeg = PAMacros.Angle(sunRAHours, 0, 0, sunDecDeg, 0, 0, raHour, raMin, raSec, decDeg, decMin, decSec, PAAngleMeasure.Hours);

        return(Math.Round(solarElongationDeg, 2));
    }
예제 #7
0
    /// <summary>
    /// Calculate approximate position of a planet.
    /// </summary>
    public (double planetRAHour, double planetRAMin, double planetRASec, double planetDecDeg, double planetDecMin, double planetDecSec) ApproximatePositionOfPlanet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string planetName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var planetInfo = PlanetInfo.GetPlanetInfo(planetName);

        var gdateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var utHours = PAMacros.LocalCivilTimeToUniversalTime(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var dDays   = PAMacros.CivilDateToJulianDate(gdateDay + (utHours / 24), gdateMonth, gdateYear) - PAMacros.CivilDateToJulianDate(0, 1, 2010);
        var npDeg1  = 360 * dDays / (365.242191 * planetInfo.tp_PeriodOrbit);
        var npDeg2  = npDeg1 - 360 * (npDeg1 / 360).Floor();
        var mpDeg   = npDeg2 + planetInfo.long_LongitudeEpoch - planetInfo.peri_LongitudePerihelion;
        var lpDeg1  = npDeg2 + (360 * planetInfo.ecc_EccentricityOrbit * mpDeg.ToRadians().Sine() / Math.PI) + planetInfo.long_LongitudeEpoch;
        var lpDeg2  = lpDeg1 - 360 * (lpDeg1 / 360).Floor();
        var planetTrueAnomalyDeg = lpDeg2 - planetInfo.peri_LongitudePerihelion;
        var rAU = planetInfo.axis_AxisOrbit * (1 - Math.Pow(planetInfo.ecc_EccentricityOrbit, 2)) / (1 + planetInfo.ecc_EccentricityOrbit * planetTrueAnomalyDeg.ToRadians().Cosine());

        var earthInfo = PlanetInfo.GetPlanetInfo("Earth");

        var neDeg1 = 360 * dDays / (365.242191 * earthInfo.tp_PeriodOrbit);
        var neDeg2 = neDeg1 - 360 * (neDeg1 / 360).Floor();
        var meDeg  = neDeg2 + earthInfo.long_LongitudeEpoch - earthInfo.peri_LongitudePerihelion;
        var leDeg1 = neDeg2 + earthInfo.long_LongitudeEpoch + 360 * earthInfo.ecc_EccentricityOrbit * meDeg.ToRadians().Sine() / Math.PI;
        var leDeg2 = leDeg1 - 360 * (leDeg1 / 360).Floor();
        var earthTrueAnomalyDeg = leDeg2 - earthInfo.peri_LongitudePerihelion;
        var rAU2       = earthInfo.axis_AxisOrbit * (1 - Math.Pow(earthInfo.ecc_EccentricityOrbit, 2)) / (1 + earthInfo.ecc_EccentricityOrbit * earthTrueAnomalyDeg.ToRadians().Cosine());
        var lpNodeRad  = (lpDeg2 - planetInfo.node_LongitudeAscendingNode).ToRadians();
        var psiRad     = ((lpNodeRad).Sine() * planetInfo.incl_OrbitalInclination.ToRadians().Sine()).ASine();
        var y          = lpNodeRad.Sine() * planetInfo.incl_OrbitalInclination.ToRadians().Cosine();
        var x          = lpNodeRad.Cosine();
        var ldDeg      = PAMacros.Degrees(y.AngleTangent2(x)) + planetInfo.node_LongitudeAscendingNode;
        var rdAU       = rAU * psiRad.Cosine();
        var leLdRad    = (leDeg2 - ldDeg).ToRadians();
        var atan2Type1 = (rdAU * leLdRad.Sine()).AngleTangent2(rAU2 - rdAU * leLdRad.Cosine());
        var atan2Type2 = (rAU2 * (-leLdRad).Sine()).AngleTangent2(rdAU - rAU2 * leLdRad.Cosine());
        var aRad       = (rdAU < 1) ? atan2Type1 : atan2Type2;
        var lamdaDeg1  = (rdAU < 1) ? 180 + leDeg2 + PAMacros.Degrees(aRad) : PAMacros.Degrees(aRad) + ldDeg;
        var lamdaDeg2  = lamdaDeg1 - 360 * (lamdaDeg1 / 360).Floor();
        var betaDeg    = PAMacros.Degrees((rdAU * psiRad.Tangent() * ((lamdaDeg2 - ldDeg).ToRadians()).Sine() / (rAU2 * (-leLdRad).Sine())).AngleTangent());
        var raHours    = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(lamdaDeg2, 0, 0, betaDeg, 0, 0, gdateDay, gdateMonth, gdateYear));
        var decDeg     = PAMacros.EcDec(lamdaDeg2, 0, 0, betaDeg, 0, 0, gdateDay, gdateMonth, gdateYear);

        var planetRAHour = PAMacros.DecimalHoursHour(raHours);
        var planetRAMin  = PAMacros.DecimalHoursMinute(raHours);
        var planetRASec  = PAMacros.DecimalHoursSecond(raHours);
        var planetDecDeg = PAMacros.DecimalDegreesDegrees(decDeg);
        var planetDecMin = PAMacros.DecimalDegreesMinutes(decDeg);
        var planetDecSec = PAMacros.DecimalDegreesSeconds(decDeg);

        return(planetRAHour, planetRAMin, planetRASec, planetDecDeg, planetDecMin, planetDecSec);
    }
예제 #8
0
    /// <summary>
    /// Calculate the equation of time. (The difference between the real Sun time and the mean Sun time.)
    /// </summary>
    /// <param name="gwdateDay">Greenwich date (day part)</param>
    /// <param name="gwdateMonth">Greenwich date (month part)</param>
    /// <param name="gwdateYear">Greenwich date (year part)</param>
    /// <returns>
    /// <para>equation_of_time_min -- equation of time (minute part)</para>
    /// <para>equation_of_time_sec -- equation of time (seconds part)</para>
    /// </returns>
    public (double equationOfTimeMin, double equationOfTimeSec) EquationOfTime(double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var sunLongitudeDeg     = PAMacros.SunLong(12, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var sunRAHours          = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(sunLongitudeDeg, 0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear));
        var equivalentUTHours   = PAMacros.GreenwichSiderealTimeToUniversalTime(sunRAHours, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var equationOfTimeHours = equivalentUTHours - 12;

        var equationOfTimeMin = PAMacros.DecimalHoursMinute(equationOfTimeHours);
        var equationOfTimeSec = PAMacros.DecimalHoursSecond(equationOfTimeHours);

        return(equationOfTimeMin, equationOfTimeSec);
    }
예제 #9
0
    /// <summary>
    /// Calculate approximate position of the Moon.
    /// </summary>
    /// <returns>
    /// <para>moon_ra_hour -- Right ascension of Moon (hour part)</para>
    /// <para>moon_ra_min -- Right ascension of Moon (minutes part)</para>
    /// <para>moon_ra_sec -- Right ascension of Moon (seconds part)</para>
    /// <para>moon_dec_deg -- Declination of Moon (degrees part)</para>
    /// <para>moon_dec_min -- Declination of Moon (minutes part)</para>
    /// <para>moon_dec_sec -- Declination of Moon (seconds part)</para>
    /// </returns>
    public (double moonRAHour, double moonRAMin, double moonRASec, double moonDecDeg, double moonDecMin, double moonDecSec) ApproximatePositionOfMoon(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var l0 = 91.9293359879052;
        var p0 = 130.143076320618;
        var n0 = 291.682546643194;
        var i  = 5.145396;

        var gdateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var utHours           = PAMacros.LocalCivilTimeToUniversalTime(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var dDays             = PAMacros.CivilDateToJulianDate(gdateDay, gdateMonth, gdateYear) - PAMacros.CivilDateToJulianDate(0.0, 1, 2010) + utHours / 24;
        var sunLongDeg        = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var sunMeanAnomalyRad = PAMacros.SunMeanAnomaly(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var lmDeg             = PAMacros.UnwindDeg(13.1763966 * dDays + l0);
        var mmDeg             = PAMacros.UnwindDeg(lmDeg - 0.1114041 * dDays - p0);
        var nDeg   = PAMacros.UnwindDeg(n0 - (0.0529539 * dDays));
        var evDeg  = 1.2739 * ((2.0 * (lmDeg - sunLongDeg) - mmDeg).ToRadians()).Sine();
        var aeDeg  = 0.1858 * (sunMeanAnomalyRad).Sine();
        var a3Deg  = 0.37 * (sunMeanAnomalyRad).Sine();
        var mmdDeg = mmDeg + evDeg - aeDeg - a3Deg;
        var ecDeg  = 6.2886 * mmdDeg.ToRadians().Sine();
        var a4Deg  = 0.214 * (2.0 * (mmdDeg).ToRadians()).Sine();
        var ldDeg  = lmDeg + evDeg + ecDeg - aeDeg + a4Deg;
        var vDeg   = 0.6583 * (2.0 * (ldDeg - sunLongDeg).ToRadians()).Sine();
        var lddDeg = ldDeg + vDeg;
        var ndDeg  = nDeg - 0.16 * (sunMeanAnomalyRad).Sine();
        var y      = ((lddDeg - ndDeg).ToRadians()).Sine() * i.ToRadians().Cosine();
        var x      = (lddDeg - ndDeg).ToRadians().Cosine();

        var moonLongDeg  = PAMacros.UnwindDeg(PAMacros.Degrees(y.AngleTangent2(x)) + ndDeg);
        var moonLatDeg   = PAMacros.Degrees(((lddDeg - ndDeg).ToRadians().Sine() * i.ToRadians().Sine()).ASine());
        var moonRAHours1 = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(moonLongDeg, 0, 0, moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear));
        var moonDecDeg1  = PAMacros.EcDec(moonLongDeg, 0, 0, moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear);

        var moonRAHour = PAMacros.DecimalHoursHour(moonRAHours1);
        var moonRAMin  = PAMacros.DecimalHoursMinute(moonRAHours1);
        var moonRASec  = PAMacros.DecimalHoursSecond(moonRAHours1);
        var moonDecDeg = PAMacros.DecimalDegreesDegrees(moonDecDeg1);
        var moonDecMin = PAMacros.DecimalDegreesMinutes(moonDecDeg1);
        var moonDecSec = PAMacros.DecimalDegreesSeconds(moonDecDeg1);

        return(moonRAHour, moonRAMin, moonRASec, moonDecDeg, moonDecMin, moonDecSec);
    }
    /// <summary>
    /// Calculate position of an elliptical comet.
    /// </summary>
    /// <returns>
    /// cometRAHour -- Right ascension of comet (hour part)
    /// cometRAMin -- Right ascension of comet (minutes part)
    /// cometDecDeg -- Declination of comet (degrees part)
    /// cometDecMin -- Declination of comet (minutes part)
    /// cometDistEarth -- Comet's distance from Earth (AU)
    /// </returns>
    public (double cometRAHour, double cometRAMin, double cometDecDeg, double cometDecMin, double cometDistEarth) PositionOfEllipticalComet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string cometName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var greenwichDateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var greenwichDateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var greenwichDateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var cometInfo = CometInfoElliptical.GetCometEllipticalInfo(cometName);

        var timeSinceEpochYears = (PAMacros.CivilDateToJulianDate(greenwichDateDay, greenwichDateMonth, greenwichDateYear) - PAMacros.CivilDateToJulianDate(0.0, 1, greenwichDateYear)) / 365.242191 + greenwichDateYear - cometInfo.epoch_EpochOfPerihelion;
        var mcDeg          = 360 * timeSinceEpochYears / cometInfo.period_PeriodOfOrbit;
        var mcRad          = (mcDeg - 360 * (mcDeg / 360).Floor()).ToRadians();
        var eccentricity   = cometInfo.ecc_EccentricityOfOrbit;
        var trueAnomalyDeg = PAMacros.Degrees(PAMacros.TrueAnomaly(mcRad, eccentricity));
        var lcDeg          = trueAnomalyDeg + cometInfo.peri_LongitudeOfPerihelion;
        var rAU            = cometInfo.axis_SemiMajorAxisOfOrbit * (1 - eccentricity * eccentricity) / (1 + eccentricity * ((trueAnomalyDeg).ToRadians()).Cosine());
        var lcNodeRad      = (lcDeg - cometInfo.node_LongitudeOfAscendingNode).ToRadians();
        var psiRad         = ((lcNodeRad).Sine() * ((cometInfo.incl_InclinationOfOrbit).ToRadians()).Sine()).ASine();

        var y = (lcNodeRad).Sine() * ((cometInfo.incl_InclinationOfOrbit).ToRadians()).Cosine();
        var x = (lcNodeRad).Cosine();

        var ldDeg = PAMacros.Degrees(y.AngleTangent2(x)) + cometInfo.node_LongitudeOfAscendingNode;
        var rdAU  = rAU * (psiRad).Cosine();

        var earthLongitudeLeDeg = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear) + 180.0;
        var earthRadiusVectorAU = PAMacros.SunDist(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var leLdRad = (earthLongitudeLeDeg - ldDeg).ToRadians();
        var aRad    = (rdAU < earthRadiusVectorAU) ? (rdAU * (leLdRad).Sine()).AngleTangent2(earthRadiusVectorAU - rdAU * (leLdRad).Cosine()) : (earthRadiusVectorAU * (-leLdRad).Sine()).AngleTangent2(rdAU - earthRadiusVectorAU * (leLdRad).Cosine());

        var cometLongDeg1   = (rdAU < earthRadiusVectorAU) ? 180.0 + earthLongitudeLeDeg + PAMacros.Degrees(aRad) : PAMacros.Degrees(aRad) + ldDeg;
        var cometLongDeg    = cometLongDeg1 - 360 * (cometLongDeg1 / 360).Floor();
        var cometLatDeg     = PAMacros.Degrees((rdAU * (psiRad).Tangent() * ((cometLongDeg1 - ldDeg).ToRadians()).Sine() / (earthRadiusVectorAU * (-leLdRad).Sine())).AngleTangent());
        var cometRAHours1   = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(cometLongDeg, 0, 0, cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear));
        var cometDecDeg1    = PAMacros.EcDec(cometLongDeg, 0, 0, cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);
        var cometDistanceAU = (Math.Pow(earthRadiusVectorAU, 2) + Math.Pow(rAU, 2) - 2.0 * earthRadiusVectorAU * rAU * ((lcDeg - earthLongitudeLeDeg).ToRadians()).Cosine() * (psiRad).Cosine()).SquareRoot();

        var cometRAHour    = PAMacros.DecimalHoursHour(cometRAHours1 + 0.008333);
        var cometRAMin     = PAMacros.DecimalHoursMinute(cometRAHours1 + 0.008333);
        var cometDecDeg    = PAMacros.DecimalDegreesDegrees(cometDecDeg1 + 0.008333);
        var cometDecMin    = PAMacros.DecimalDegreesMinutes(cometDecDeg1 + 0.008333);
        var cometDistEarth = Math.Round(cometDistanceAU, 2);

        return(cometRAHour, cometRAMin, cometDecDeg, cometDecMin, cometDistEarth);
    }
예제 #11
0
    /// <summary>
    /// Calculate precise position of a planet.
    /// </summary>
    public (double planetRAHour, double planetRAMin, double planetRASec, double planetDecDeg, double planetDecMin, double planetDecSec) PrecisePositionOfPlanet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string planetName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var coordinateResults = PAMacros.PlanetCoordinates(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear, planetName);

        var planetRAHours = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(coordinateResults.planetLongitude, 0, 0, coordinateResults.planetLatitude, 0, 0, localDateDay, localDateMonth, localDateYear));
        var planetDecDeg1 = PAMacros.EcDec(coordinateResults.planetLongitude, 0, 0, coordinateResults.planetLatitude, 0, 0, localDateDay, localDateMonth, localDateYear);

        var planetRAHour = PAMacros.DecimalHoursHour(planetRAHours);
        var planetRAMin  = PAMacros.DecimalHoursMinute(planetRAHours);
        var planetRASec  = PAMacros.DecimalHoursSecond(planetRAHours);
        var planetDecDeg = PAMacros.DecimalDegreesDegrees(planetDecDeg1);
        var planetDecMin = PAMacros.DecimalDegreesMinutes(planetDecDeg1);
        var planetDecSec = PAMacros.DecimalDegreesSeconds(planetDecDeg1);

        return(planetRAHour, planetRAMin, planetRASec, planetDecDeg, planetDecMin, planetDecSec);
    }
예제 #12
0
    /// <summary>
    /// Calculate precise position of the sun for a local date and time.
    /// </summary>
    public (double sunRAHour, double sunRAMin, double sunRASec, double sunDecDeg, double sunDecMin, double sunDecSec) PrecisePositionOfSun(double lctHours, double lctMinutes, double lctSeconds, double localDay, int localMonth, int localYear, bool isDaylightSaving, int zoneCorrection)
    {
        var daylightSaving = (isDaylightSaving == true) ? 1 : 0;

        var gDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var gMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var gYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var sunEclipticLongitudeDeg = PAMacros.SunLong(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var raDeg   = PAMacros.EcRA(sunEclipticLongitudeDeg, 0, 0, 0, 0, 0, gDay, gMonth, gYear);
        var raHours = PAMacros.DecimalDegreesToDegreeHours(raDeg);
        var decDeg  = PAMacros.EcDec(sunEclipticLongitudeDeg, 0, 0, 0, 0, 0, gDay, gMonth, gYear);

        var sunRAHour = PAMacros.DecimalHoursHour(raHours);
        var sunRAMin  = PAMacros.DecimalHoursMinute(raHours);
        var sunRASec  = PAMacros.DecimalHoursSecond(raHours);
        var sunDecDeg = PAMacros.DecimalDegreesDegrees(decDeg);
        var sunDecMin = PAMacros.DecimalDegreesMinutes(decDeg);
        var sunDecSec = PAMacros.DecimalDegreesSeconds(decDeg);

        return(sunRAHour, sunRAMin, sunRASec, sunDecDeg, sunDecMin, sunDecSec);
    }
    /// <summary>
    /// Calculate rising and setting times for an object.
    /// </summary>
    /// <returns>Tuple (riseSetStatus, utRiseHour, utRiseMin, utSetHour, utSetMin, azRise, azSet)</returns>
    public (string riseSetStatus, double utRiseHour, double utRiseMin, double utSetHour, double utSetMin, double azRise, double azSet) RisingAndSetting(double raHours, double raMinutes, double raSeconds, double decDeg, double decMin, double decSec, double gwDateDay, int gwDateMonth, int gwDateYear, double geogLongDeg, double geogLatDeg, double vertShiftDeg)
    {
        var raHours1             = PAMacros.HMStoDH(raHours, raMinutes, raSeconds);
        var decRad               = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDeg, decMin, decSec).ToRadians();
        var verticalDisplRadians = vertShiftDeg.ToRadians();
        var geoLatRadians        = geogLatDeg.ToRadians();
        var cosH                = -(verticalDisplRadians.Sine() + geoLatRadians.Sine() * decRad.Sine()) / (geoLatRadians.Cosine() * decRad.Cosine());
        var hHours              = PAMacros.DecimalDegreesToDegreeHours(PAMacros.Degrees(cosH.ACosine()));
        var lstRiseHours        = (raHours1 - hHours) - 24 * ((raHours1 - hHours) / 24).Floor();
        var lstSetHours         = (raHours1 + hHours) - 24 * ((raHours1 + hHours) / 24).Floor();
        var aDeg                = PAMacros.Degrees((((decRad).Sine() + (verticalDisplRadians).Sine() * (geoLatRadians).Sine()) / ((verticalDisplRadians).Cosine() * (geoLatRadians).Cosine())).ACosine());
        var azRiseDeg           = aDeg - 360 * (aDeg / 360).Floor();
        var azSetDeg            = (360 - aDeg) - 360 * ((360 - aDeg) / 360).Floor();
        var utRiseHours1        = PAMacros.GreenwichSiderealTimeToUniversalTime(PAMacros.LocalSiderealTimeToGreenwichSiderealTime(lstRiseHours, 0, 0, geogLongDeg), 0, 0, gwDateDay, gwDateMonth, gwDateYear);
        var utSetHours1         = PAMacros.GreenwichSiderealTimeToUniversalTime(PAMacros.LocalSiderealTimeToGreenwichSiderealTime(lstSetHours, 0, 0, geogLongDeg), 0, 0, gwDateDay, gwDateMonth, gwDateYear);
        var utRiseAdjustedHours = utRiseHours1 + 0.008333;
        var utSetAdjustedHours  = utSetHours1 + 0.008333;

        var riseSetStatus = "OK";

        if (cosH > 1)
        {
            riseSetStatus = "never rises";
        }
        if (cosH < -1)
        {
            riseSetStatus = "circumpolar";
        }

        var utRiseHour = (riseSetStatus == "OK") ? PAMacros.DecimalHoursHour(utRiseAdjustedHours) : 0;
        var utRiseMin  = (riseSetStatus == "OK") ? PAMacros.DecimalHoursMinute(utRiseAdjustedHours) : 0;
        var utSetHour  = (riseSetStatus == "OK") ? PAMacros.DecimalHoursHour(utSetAdjustedHours) : 0;
        var utSetMin   = (riseSetStatus == "OK") ? PAMacros.DecimalHoursMinute(utSetAdjustedHours) : 0;
        var azRise     = (riseSetStatus == "OK") ? Math.Round(azRiseDeg, 2) : 0;
        var azSet      = (riseSetStatus == "OK") ? Math.Round(azSetDeg, 2) : 0;

        return(riseSetStatus, utRiseHour, utRiseMin, utSetHour, utSetMin, azRise, azSet);
    }