/// <summary> /// Convert Equatorial Coordinates to Ecliptic Coordinates /// </summary> /// <returns>Tuple (outEclLongDeg, outEclLongMin, outEclLongSec, outEclLatDeg, outEclLatMin, outEclLatSec)</returns> public (double outEclLongDeg, double outEclLongMin, double outEclLongSec, double outEclLatDeg, double outEclLatMin, double outEclLatSec) EquatorialCoordinateToEclipticCoordinate(double raHours, double raMinutes, double raSeconds, double decDegrees, double decMinutes, double decSeconds, double gwDay, int gwMonth, int gwYear) { var raDeg = PAMacros.DegreeHoursToDecimalDegrees(PAMacros.HMStoDH(raHours, raMinutes, raSeconds)); var decDeg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDegrees, decMinutes, decSeconds); var raRad = raDeg.ToRadians(); var decRad = decDeg.ToRadians(); var obliqDeg = PAMacros.Obliq(gwDay, gwMonth, gwYear); var obliqRad = obliqDeg.ToRadians(); var sinEclLat = decRad.Sine() * obliqRad.Cosine() - decRad.Cosine() * obliqRad.Sine() * raRad.Sine(); var eclLatRad = sinEclLat.ASine(); var eclLatDeg = PAMacros.Degrees(eclLatRad); var y = raRad.Sine() * obliqRad.Cosine() + decRad.Tangent() * obliqRad.Sine(); var x = raRad.Cosine(); var eclLongRad = y.AngleTangent2(x); var eclLongDeg1 = PAMacros.Degrees(eclLongRad); var eclLongDeg2 = eclLongDeg1 - 360 * (eclLongDeg1 / 360).Floor(); var outEclLongDeg = PAMacros.DecimalDegreesDegrees(eclLongDeg2); var outEclLongMin = PAMacros.DecimalDegreesMinutes(eclLongDeg2); var outEclLongSec = PAMacros.DecimalDegreesSeconds(eclLongDeg2); var outEclLatDeg = PAMacros.DecimalDegreesDegrees(eclLatDeg); var outEclLatMin = PAMacros.DecimalDegreesMinutes(eclLatDeg); var outEclLatSec = PAMacros.DecimalDegreesSeconds(eclLatDeg); return(outEclLongDeg, outEclLongMin, outEclLongSec, outEclLatDeg, outEclLatMin, outEclLatSec); }
/// <summary> /// Calculate the angle between two celestial objects /// </summary> /// <returns>Tuple (angleDeg, angleMin, angleSec)</returns> public (double angleDeg, double angleMin, double angleSec) AngleBetweenTwoObjects(double raLong1HourDeg, double raLong1Min, double raLong1Sec, double decLat1Deg, double decLat1Min, double decLat1Sec, double raLong2HourDeg, double raLong2Min, double raLong2Sec, double decLat2Deg, double decLat2Min, double decLat2Sec, PAAngleMeasure hourOrDegree) { var raLong1Decimal = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.HMStoDH(raLong1HourDeg, raLong1Min, raLong1Sec) : PAMacros.DegreesMinutesSecondsToDecimalDegrees(raLong1HourDeg, raLong1Min, raLong1Sec); var raLong1Deg = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.DegreeHoursToDecimalDegrees(raLong1Decimal) : raLong1Decimal; var raLong1Rad = raLong1Deg.ToRadians(); var decLat1Deg1 = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decLat1Deg, decLat1Min, decLat1Sec); var decLat1Rad = decLat1Deg1.ToRadians(); var raLong2Decimal = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.HMStoDH(raLong2HourDeg, raLong2Min, raLong2Sec) : PAMacros.DegreesMinutesSecondsToDecimalDegrees(raLong2HourDeg, raLong2Min, raLong2Sec); var raLong2Deg = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.DegreeHoursToDecimalDegrees(raLong2Decimal) : raLong2Decimal; var raLong2Rad = raLong2Deg.ToRadians(); var decLat2Deg1 = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decLat2Deg, decLat2Min, decLat2Sec); var decLat2Rad = decLat2Deg1.ToRadians(); var cosD = decLat1Rad.Sine() * decLat2Rad.Sine() + decLat1Rad.Cosine() * decLat2Rad.Cosine() * (raLong1Rad - raLong2Rad).Cosine(); var dRad = cosD.ACosine(); var dDeg = PAMacros.Degrees(dRad); var angleDeg = PAMacros.DecimalDegreesDegrees(dDeg); var angleMin = PAMacros.DecimalDegreesMinutes(dDeg); var angleSec = PAMacros.DecimalDegreesSeconds(dDeg); return(angleDeg, angleMin, angleSec); }
/// <summary> /// Convert Local Sidereal Time to Greenwich Sidereal Time /// </summary> /// <returns>Tuple (int gstHours, int gstMinutes, double gstSeconds)</returns> public (int gstHours, int gstMinutes, double gstSeconds) LocalSiderealTimeToGreenwichSiderealTime(double lstHours, double lstMinutes, double lstSeconds, double geographicalLongitude) { var gst = PAMacros.HMStoDH(lstHours, lstMinutes, lstSeconds); var longHours = geographicalLongitude / 15; var gst1 = gst - longHours; var gst2 = gst1 - (24 * (gst1 / 24).Floor()); var gstHours = PAMacros.DecimalHoursHour(gst2); var gstMinutes = PAMacros.DecimalHoursMinute(gst2); var gstSeconds = PAMacros.DecimalHoursSecond(gst2); return(gstHours, gstMinutes, gstSeconds); }
/// <summary> /// Convert Greenwich Sidereal Time to Local Sidereal Time /// </summary> /// <returns>Tuple (int lstHours, int lstMinutes, double lstSeconds)</returns> public (int lstHours, int lstMinutes, double lstSeconds) GreenwichSiderealTimeToLocalSiderealTime(double gstHours, double gstMinutes, double gstSeconds, double geographicalLongitude) { var gst = PAMacros.HMStoDH(gstHours, gstMinutes, gstSeconds); var offset = geographicalLongitude / 15; var lstHours1 = gst + offset; var lstHours2 = lstHours1 - (24 * (lstHours1 / 24).Floor()); var lstHours = PAMacros.DecimalHoursHour(lstHours2); var lstMinutes = PAMacros.DecimalHoursMinute(lstHours2); var lstSeconds = PAMacros.DecimalHoursSecond(lstHours2); return(lstHours, lstMinutes, lstSeconds); }
/// <summary> /// Convert Universal Time to Greenwich Sidereal Time /// </summary> /// <returns>Tuple (int gstHours, int gstMinutes, double gstSeconds)</returns> public (int gstHours, int gstMinutes, double gstSeconds) UniversalTimeToGreenwichSiderealTime(double utHours, double utMinutes, double utSeconds, double gwDay, int gwMonth, int gwYear) { var jd = PAMacros.CivilDateToJulianDate(gwDay, gwMonth, gwYear); var s = jd - 2451545; var t = s / 36525; var t01 = 6.697374558 + (2400.051336 * t) + (0.000025862 * t * t); var t02 = t01 - (24.0 * (t01 / 24).Floor()); var ut = PAMacros.HMStoDH(utHours, utMinutes, utSeconds); var a = ut * 1.002737909; var gst1 = t02 + a; var gst2 = gst1 - (24.0 * (gst1 / 24).Floor()); var gstHours = PAMacros.DecimalHoursHour(gst2); var gstMinutes = PAMacros.DecimalHoursMinute(gst2); var gstSeconds = PAMacros.DecimalHoursSecond(gst2); return(gstHours, gstMinutes, gstSeconds); }
/// <summary> /// Convert Greenwich Sidereal Time to Universal Time /// </summary> /// <returns>Tuple (int utHours, int utMinutes, double utSeconds, PAWarningFlag warningFlag)</returns> public (int utHours, int utMinutes, double utSeconds, PAWarningFlag warningFlag) GreenwichSiderealTimeToUniversalTime(double gstHours, double gstMinutes, double gstSeconds, double gwDay, int gwMonth, int gwYear) { var jd = PAMacros.CivilDateToJulianDate(gwDay, gwMonth, gwYear); var s = jd - 2451545; var t = s / 36525; var t01 = 6.697374558 + (2400.051336 * t) + (0.000025862 * t * t); var t02 = t01 - (24 * (t01 / 24).Floor()); var gstHours1 = PAMacros.HMStoDH(gstHours, gstMinutes, gstSeconds); var a = gstHours1 - t02; var b = a - (24 * (a / 24).Floor()); var ut = b * 0.9972695663; var utHours = PAMacros.DecimalHoursHour(ut); var utMinutes = PAMacros.DecimalHoursMinute(ut); var utSeconds = PAMacros.DecimalHoursSecond(ut); var warningFlag = (ut < 0.065574) ? PAWarningFlag.Warning : PAWarningFlag.OK; return(utHours, utMinutes, utSeconds, warningFlag); }
/// <summary> /// Calculate precession (corrected coordinates between two epochs) /// </summary> /// <returns>Tuple (correctedRAHour, correctedRAMinutes, correctedRASeconds, correctedDecDeg, correctedDecMinutes, correctedDecSeconds)</returns> public (double correctedRAHour, double correctedRAMinutes, double correctedRASeconds, double correctedDecDeg, double correctedDecMinutes, double correctedDecSeconds) CorrectForPrecession(double raHour, double raMinutes, double raSeconds, double decDeg, double decMinutes, double decSeconds, double epoch1Day, int epoch1Month, int epoch1Year, double epoch2Day, int epoch2Month, int epoch2Year) { var ra1Rad = (PAMacros.DegreeHoursToDecimalDegrees(PAMacros.HMStoDH(raHour, raMinutes, raSeconds))).ToRadians(); var dec1Rad = (PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDeg, decMinutes, decSeconds)).ToRadians(); var tCenturies = (PAMacros.CivilDateToJulianDate(epoch1Day, epoch1Month, epoch1Year) - 2415020) / 36525; var mSec = 3.07234 + (0.00186 * tCenturies); var nArcsec = 20.0468 - (0.0085 * tCenturies); var nYears = (PAMacros.CivilDateToJulianDate(epoch2Day, epoch2Month, epoch2Year) - PAMacros.CivilDateToJulianDate(epoch1Day, epoch1Month, epoch1Year)) / 365.25; var s1Hours = ((mSec + (nArcsec * (ra1Rad).Sine() * (dec1Rad).Tangent() / 15)) * nYears) / 3600; var ra2Hours = PAMacros.HMStoDH(raHour, raMinutes, raSeconds) + s1Hours; var s2Deg = (nArcsec * (ra1Rad).Cosine() * nYears) / 3600; var dec2Deg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDeg, decMinutes, decSeconds) + s2Deg; var correctedRAHour = PAMacros.DecimalHoursHour(ra2Hours); var correctedRAMinutes = PAMacros.DecimalHoursMinute(ra2Hours); var correctedRASeconds = PAMacros.DecimalHoursSecond(ra2Hours); var correctedDecDeg = PAMacros.DecimalDegreesDegrees(dec2Deg); var correctedDecMinutes = PAMacros.DecimalDegreesMinutes(dec2Deg); var correctedDecSeconds = PAMacros.DecimalDegreesSeconds(dec2Deg); return(correctedRAHour, correctedRAMinutes, correctedRASeconds, correctedDecDeg, correctedDecMinutes, correctedDecSeconds); }
/// <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); }
/// <summary> /// Convert Equatorial Coordinates to Galactic Coordinates /// </summary> /// <returns>Tuple (galLongDeg, galLongMin, galLongSec, galLatDeg, galLatMin, galLatSec)</returns> public (double galLongDeg, double galLongMin, double galLongSec, double galLatDeg, double galLatMin, double galLatSec) EquatorialCoordinateToGalacticCoordinate(double raHours, double raMinutes, double raSeconds, double decDegrees, double decMinutes, double decSeconds) { var raDeg = PAMacros.DegreeHoursToDecimalDegrees(PAMacros.HMStoDH(raHours, raMinutes, raSeconds)); var decDeg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDegrees, decMinutes, decSeconds); var raRad = raDeg.ToRadians(); var decRad = decDeg.ToRadians(); var sinB = decRad.Cosine() * (27.4).ToRadians().Cosine() * (raRad - (192.25).ToRadians()).Cosine() + decRad.Sine() * (27.4).ToRadians().Sine(); var bRadians = sinB.ASine(); var bDeg = PAMacros.Degrees(bRadians); var y = decRad.Sine() - sinB * (27.4).ToRadians().Sine(); var x = decRad.Cosine() * (raRad - (192.25).ToRadians()).Sine() * (27.4).ToRadians().Cosine(); var longDeg1 = PAMacros.Degrees(y.AngleTangent2(x)) + 33; var longDeg2 = longDeg1 - 360 * (longDeg1 / 360).Floor(); var galLongDeg = PAMacros.DecimalDegreesDegrees(longDeg2); var galLongMin = PAMacros.DecimalDegreesMinutes(longDeg2); var galLongSec = PAMacros.DecimalDegreesSeconds(longDeg2); var galLatDeg = PAMacros.DecimalDegreesDegrees(bDeg); var galLatMin = PAMacros.DecimalDegreesMinutes(bDeg); var galLatSec = PAMacros.DecimalDegreesSeconds(bDeg); return(galLongDeg, galLongMin, galLongSec, galLatDeg, galLatMin, galLatSec); }
/// <summary> /// Convert Universal Time to local Civil Time /// </summary> /// <returns>Tuple (int lctHours, int lctMinutes, int lctSeconds, int localDay, int localMonth, int localYear)</returns> public (int lctHours, int lctMinutes, int lctSeconds, int localDay, int localMonth, int localYear) UniversalTimeToLocalCivilTime(double utHours, double utMinutes, double utSeconds, bool isDaylightSavings, int zoneCorrection, int gwDay, int gwMonth, int gwYear) { var dstValue = (isDaylightSavings) ? 1 : 0; var ut = PAMacros.HMStoDH(utHours, utMinutes, utSeconds); var zoneTime = ut + zoneCorrection; var localTime = zoneTime + dstValue; var localJDPlusLocalTime = PAMacros.CivilDateToJulianDate(gwDay, gwMonth, gwYear) + (localTime / 24); var localDay = PAMacros.JulianDateDay(localJDPlusLocalTime); var integerDay = localDay.Floor(); var localMonth = PAMacros.JulianDateMonth(localJDPlusLocalTime); var localYear = PAMacros.JulianDateYear(localJDPlusLocalTime); var lct = 24 * (localDay - integerDay); return( PAMacros.DecimalHoursHour(lct), PAMacros.DecimalHoursMinute(lct), (int)PAMacros.DecimalHoursSecond(lct), (int)integerDay, localMonth, localYear ); }
/// <summary> /// Convert a Civil Time (hours,minutes,seconds) to Decimal Hours /// </summary> public double CivilTimeToDecimalHours(double hours, double minutes, double seconds) { return(PAMacros.HMStoDH(hours, minutes, seconds)); }