/// <summary> /// Based on Chapter 39, Meeus and Chapter 10 /// </summary> /// <param name="obs"></param> public void makeTopocentric(GPObserver obs) { double u, h, delta_alpha; double rho_sin, rho_cos; const double b_a = 0.99664719; // geocentric position of observer on the earth surface // 10.1 - 10.3 u = GPMath.arctanDeg(b_a * b_a * GPMath.tanDeg(obs.GetLatitudeNorthPositive())); rho_sin = b_a * GPMath.sinDeg(u) + obs.GetAltitude() / 6378140.0 * GPMath.sinDeg(obs.GetLatitudeNorthPositive()); rho_cos = GPMath.cosDeg(u) + obs.GetAltitude() / 6378140.0 * GPMath.cosDeg(obs.GetLatitudeNorthPositive()); // equatorial horizontal paralax // 39.1 this.parallax = GPMath.arcsinDeg(GPMath.sinDeg(8.794 / 3600) / (this.distanceFromEarth / GPAstroEngine.AU)); // geocentric hour angle of the body h = apparent_sidereal_time - obs.GetLongitudeWestPositive() - right_ascession; // 39.2 delta_alpha = GPMath.arctanDeg( (-rho_cos * GPMath.sinDeg(this.parallax) * GPMath.sinDeg(h)) / (GPMath.cosDeg(this.declination) - rho_cos * GPMath.sinDeg(this.parallax) * GPMath.cosDeg(h))); this.right_ascession += delta_alpha; this.declination = GPMath.arctanDeg( ((GPMath.sinDeg(this.declination) - rho_sin * GPMath.sinDeg(this.parallax)) * GPMath.cosDeg(delta_alpha)) / (GPMath.cosDeg(this.declination) - rho_cos * GPMath.sinDeg(this.parallax) * GPMath.cosDeg(h))); }
public static void calc_geocentric(ref double longitude, ref double latitude, ref double rektaszension, ref double declination, double date) { //var double epsilon; //: extended; double delta_phi; //: extended; double alpha, delta; //: extended; calc_epsilon_phi(date, out delta_phi, out epsilon); longitude = GPMath.putIn360(longitude + delta_phi); alpha = GPMath.arctan2Deg(GPMath.sinDeg(longitude) * GPMath.cosDeg(epsilon) - GPMath.tanDeg(latitude) * GPMath.sinDeg(epsilon), GPMath.cosDeg(longitude)); delta = GPMath.arcsinDeg(GPMath.sinDeg(latitude) * GPMath.cosDeg(epsilon) + GPMath.cosDeg(latitude) * GPMath.sinDeg(epsilon) * GPMath.sinDeg(longitude)); rektaszension = alpha; declination = delta; double xg, yg, zg; xg = GPMath.cosDeg(longitude) * GPMath.cosDeg(latitude); yg = GPMath.sinDeg(longitude) * GPMath.cosDeg(latitude); zg = GPMath.sinDeg(latitude); alpha = GPMath.arctan2Deg(yg * GPMath.cosDeg(epsilon) - zg * GPMath.sinDeg(epsilon), GPMath.cosDeg(longitude) * GPMath.cosDeg(latitude)); }
public void calculateCoordinatesMethodM(double julian) { double DG = GPMath.rads; double RAD = 180 / GPMath.pi; double t = (julian - 2451545.0) / 36525; double t2 = t * t; double t3 = t2 * t; double t4 = t2 * t2; // mean ecliptic longitude of the sun double L0 = 280.4664567 + 36000.76982779 * t + 0.0003032028 * t2 + t3 / 49931000; // mean anomaly of the sun double M = 357.5291 + 35999.05030 * t - 0.0001559 * t2 - 0.00000048 * t3; L0 = GPMath.putIn360(L0); M = GPMath.putIn360(M); sunMeanAnomaly = M; double C = (1.9146 - 0.004817 * t - 0.000014 * t2) * GPMath.sinDeg(M) + (0.019993 - 0.000101 * t) * GPMath.sinDeg(2 * M) + 0.00029 * GPMath.sinDeg(3 * M); sunEquationCenter = C; // ecliptic longitude of the sun //double els = 0; eclipticalLongitude = GPMath.putIn360(L0 + C); double e = 0.016708617 - 0.000042037 * t - 0.0000001236 * t2; double trueAnomaly = M + C; // double epsilon; // double deltaPhi; // GPAstroEngine.calc_epsilon_phi(julianDay, out deltaPhi, out epsilon); // = 23.4391 - 0.013 * t - t2/6101694; double omega = 125.04 - 1934.136 * t; double lambda = eclipticalLongitude - 0.00569 - 0.00478 * GPMath.sinDeg(omega); double epsilon0 = 23.4392911 - 0.01300416 * t - 1.638e-7 * t2; double epsilon1 = epsilon0 + 0.00256 * GPMath.cosDeg(omega); // right ascension of the sun this.rightAscession = RAD * Math.Atan2(GPMath.cosDeg(epsilon1) * GPMath.sinDeg(lambda), GPMath.cosDeg(lambda)); this.rightAscession = GPMath.putIn360(rightAscession); // declination of the sun this.declination = GPMath.arcsinDeg(GPMath.sinDeg(epsilon1) * GPMath.sinDeg(lambda)); // equation of time equationOfTime = GPAstroEngine.getEquationOfTime(julian, this.rightAscession); }
private void calculateRiseSetMethodM(double D, GPLocationProvider ed) { GPLocation obs = ed.getLocation(D); double a1, a2, a3; double d1, d2, d3; double siderealTime = GPAstroEngine.GetSiderealTime(D); double h0 = -0.833333; calculateCoordinatesMethodM(D - 1); a1 = rightAscession; d1 = declination; calculateCoordinatesMethodM(D); a2 = rightAscession; d2 = declination; calculateCoordinatesMethodM(D + 1); a3 = rightAscession; d3 = declination; double longitude = -ed.GetLongitudeEastPositive(); double latitude = ed.GetLatitudeNorthPositive(); double cosH0 = (GPMath.sinDeg(h0) - GPMath.sinDeg(latitude) * GPMath.sinDeg(d2)) / (GPMath.cosDeg(latitude) * GPMath.cosDeg(d2)); double H0 = GPMath.arccosDeg(cosH0); H0 = GPMath.putIn180(H0); double m0 = (a2 + longitude - siderealTime) / 360; double m1 = m0 - H0 / 360; double m2 = m0 + H0 / 360; double deltaM = 0; deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m0, true); m0 += deltaM; deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m1, false); m1 += deltaM; deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m2, false); m2 += deltaM; julianDayRise = julianDay + m1; julianDayNoon = julianDay + m0; julianDaySet = julianDay + m2; sunrise_deg = GPMath.putIn360(m1 * 360); noon_deg = GPMath.putIn360(m0 * 360); sunset_deg = GPMath.putIn360(m2 * 360); }
private static double getCorrection(double D, double a1, double a2, double a3, double d1, double d2, double d3, double siderealTime, double h0, double longitude, double latitude, double m0, bool transit) { double deltaM = 0; double PHI = siderealTime + 360.985647 * m0; double n = m0 + GPDynamicTime.GetDeltaT(D) / 86400; double alpha = GPAstroEngine.interpolation(a1, a2, a3, n); double delta = GPAstroEngine.interpolation(d1, d2, d3, n); double H = GPMath.putIn180(PHI - longitude - alpha); double h = 0; if (transit) { deltaM = -H / 360; } else { double sinH = GPMath.sinDeg(latitude) * GPMath.sinDeg(delta) + GPMath.cosDeg(latitude) * GPMath.cosDeg(delta) * GPMath.cosDeg(H); h = GPMath.arcsinDeg(sinH); deltaM = (h - h0) / (360 * GPMath.cosDeg(delta) * GPMath.cosDeg(latitude) * GPMath.sinDeg(H)); } return(deltaM); }
private void calculateRiseSetMethodA(GPGregorianTime vct, GPLocationProvider ed, double DayHours, GPSun sun, double DG, double RAD) { double time = vct.getJulianLocalNoon() - 0.5 + DayHours / 360 - vct.getTimeZoneOffsetHours() / 24.0; double dLatitude = ed.getLocation(time).GetLatitudeNorthPositive(); double dLongitude = ed.getLocation(time).GetLongitudeEastPositive(); //Debugger.Log(0,"",String.Format("{0} {1} {2}\n", vct.getLongDateString(), dLatitude, dLongitude)); // definition of event // eventdef = 0.0; // civil twilight eventdef = 0.10453; // nautical twilight eventdef = 0.20791; // astronomical twilight eventdef = 0.30902; // center of the sun on the horizont eventdef = 0.01454; double eventdef = 0.01454; double x = GPMath.tanDeg(dLatitude) * GPMath.tanDeg(sun.declination) + eventdef / (GPMath.cosDeg(dLatitude) * GPMath.cosDeg(sun.declination)); if (x < -1.0 || x > 1.0) { // initial values for the case // that no rise no set for that day sun.sunrise_deg = -360; sun.noon_deg = -360; sun.sunset_deg = -360; return; } double hourAngle = GPMath.arcsinDeg(x); // time of sunrise sun.sunrise_deg = 90.0 - dLongitude - hourAngle + equationOfTime; // time of noon sun.noon_deg = 180.0 - dLongitude + equationOfTime; // time of sunset sun.sunset_deg = 270.0 - dLongitude + hourAngle + equationOfTime; }
/// <summary> /// Calculates sidereal time at Greenwich. /// Based on Chapter 11 of Astronomical Algorithms. /// </summary> /// <param name="date">Julian Ephemeris Day</param> /// <returns>Sidereal time in degrees.</returns> public void SetSiderealTime(double date) { double t; //date = 2446896.30625; //jd = date; t = (date - GPAstroEngine.J2000) / 36525.0; GPAstroEngine.calc_epsilon_phi(date, out delta_phi, out epsilon); // 11.2 mean_sidereal_time = GPMath.putIn360(280.46061837 + 360.98564736629 * (date - GPAstroEngine.J2000) + t * t * (0.000387933 - t / 38710000)); apparent_sidereal_time = GPMath.putIn360(mean_sidereal_time + delta_phi * GPMath.cosDeg(epsilon)); }