/// <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> /// Calculate Moon phase and position angle of bright limb. /// </summary> /// <returns> /// <para>moonPhase -- Phase of Moon, between 0 and 1, where 0 is New and 1 is Full.</para> /// <para>paBrightLimbDeg -- Position angle of the bright limb (degrees)</para> /// </returns> public (double moonPhase, double paBrightLimbDeg) MoonPhase(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, PAAccuracyLevel accuracyLevel) { 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 sunLongDeg = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear); var moonResult = PAMacros.MoonLongLatHP(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear); var dRad = (moonResult.moonLongDeg - sunLongDeg).ToRadians(); var moonPhase1 = (accuracyLevel == PAAccuracyLevel.Precise) ? PAMacros.MoonPhase(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear) : (1.0 - (dRad).Cosine()) / 2.0; var sunRARad = (PAMacros.EcRA(sunLongDeg, 0, 0, 0, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians(); var moonRARad = (PAMacros.EcRA(moonResult.moonLongDeg, 0, 0, moonResult.moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians(); var sunDecRad = (PAMacros.EcDec(sunLongDeg, 0, 0, 0, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians(); var moonDecRad = (PAMacros.EcDec(moonResult.moonLongDeg, 0, 0, moonResult.moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians(); var y = (sunDecRad).Cosine() * (sunRARad - moonRARad).Sine(); var x = (moonDecRad).Cosine() * (sunDecRad).Sine() - (moonDecRad).Sine() * (sunDecRad).Cosine() * (sunRARad - moonRARad).Cosine(); var chiDeg = PAMacros.Degrees(y.AngleTangent2(x)); var moonPhase = Math.Round(moonPhase1, 2); var paBrightLimbDeg = Math.Round(chiDeg, 2); return(moonPhase, paBrightLimbDeg); }