/// <summary> /// Compute sun declination for given julian date. /// </summary> /// <param name="julianDate"> /// Julian date of sun declination to be computed. /// </param> /// <returns> /// Sun declination for given julian date. /// </returns> internal static double ComputeSunDeclination(double julianDate) { var epochDaysFraction = ComputeEpochDaysFraction(julianDate); var sunMeanAnomaly = ComputeSunMeanAnomaly(epochDaysFraction); var sunMeanLongitude = ComputeSunMeanLongitude(epochDaysFraction); var sunEclipticLongitude = ComputeSunEclipticLongitude(sunMeanLongitude, sunMeanAnomaly); var eclipticMeanObliquity = ComputeEclipticMeanObliquity(epochDaysFraction); return(AngleMath.InverseSineInDegree(AngleMath.SineOfDegree(eclipticMeanObliquity) * AngleMath.SineOfDegree(sunEclipticLongitude))); }
/// <summary> /// Compute solar time for given julian date, time fraction, angle, latitude and direction. /// </summary> /// <param name="julianDate"> /// Julian date of solar time to be computed. /// </param> /// <param name="timeFraction"> /// Time fraction of the day of solar time to be computed. /// </param> /// <param name="angle"> /// Sun's angle of solar time to be computed. /// </param> /// <param name="latitude"> /// Location's latitude. /// </param> /// <param name="direction"> /// <see cref="Direction" /> value which determine whether sun is before or after mid day. /// </param> /// <returns> /// Solar time for given julian date, time fraction, angle, latitude and direction. /// </returns> internal static double ComputeSolarTime(double julianDate, double timeFraction, double angle, double latitude, Direction direction) { var sunDeclination = ComputeSunDeclination(julianDate + timeFraction); var midDay = ComputeMidDay(julianDate, timeFraction); var solarTime = 0.0666666666666667 * AngleMath.InverseCosineInDegree((-AngleMath.SineOfDegree(angle) - (AngleMath.SineOfDegree(sunDeclination) * AngleMath.SineOfDegree(latitude))) / (AngleMath.CosineOfDegree(sunDeclination) * AngleMath.CosineOfDegree(latitude))); return(midDay + (direction == Direction.CounterClockwise ? -solarTime : solarTime)); }
/// <summary> /// Compute sun's right ascension for given mean obliquity and ecliptic longitude. /// </summary> private static double ComputeSunRightAscension(double eclipticMeanObliquity, double sunEclipticLongitude) { return(AngleMath.InverseTangent2InDegree(AngleMath.CosineOfDegree(eclipticMeanObliquity) * AngleMath.SineOfDegree(sunEclipticLongitude), AngleMath.CosineOfDegree(sunEclipticLongitude)) / 15.0); }
/// <summary> /// Compute sun's ecliptic longitude for given mean longitude and mean anomaly. /// </summary> private static double ComputeSunEclipticLongitude(double sunMeanLongitude, double sunMeanAnomaly) { return(AngleMath.FixDegreesAngle(sunMeanLongitude + (1.915 * AngleMath.SineOfDegree(sunMeanAnomaly)) + (0.02 * AngleMath.SineOfDegree(2.0 * sunMeanAnomaly)))); }