//static void AltAzToRaDec2(double alt, double az, out double hrAngle, out double dec, double lat) //{ // if (alt == 0) // { // alt = .00000000001; // } // if (az == 0) // { // az = .00000000001; // } // double sin_dec; // double cos_lat = Math.Cos(lat); // if (alt > Math.PI / 2.0) // { // alt = Math.PI - alt; // az += Math.PI; // } // if (alt < -Math.PI / 2.0) // { // alt = -Math.PI - alt; // az -= Math.PI; // } // sin_dec = Math.Sin(lat) * Math.Sin(alt) + cos_lat * Math.Cos(alt) * Math.Cos(az); // dec = Math.Asin(sin_dec); // if (cos_lat < .00001) // { // hrAngle = az + Math.PI; // } // else // { // double cos_lat_cos_dec = (cos_lat * Math.Cos(dec)); // double sin_alt_sinLat_sin_dec = Math.Sin(alt) - Math.Sin(lat) * sin_dec; // double acosTarget = sin_alt_sinLat_sin_dec / cos_lat_cos_dec; // double temp = 0; // if (Math.Abs(acosTarget) < 1.1) // { // if (acosTarget > 1) // { // acosTarget = 1.0; // } // if (acosTarget < -1) // { // acosTarget = -1.0; // } // temp = Math.Acos(acosTarget); // } // else // { // temp = Math.PI; // } // //if (double.IsNaN(temp)) // //{ // // temp = Math.PI; // //} // if (Math.Sin(az) > 0.0) // { // hrAngle = Math.PI - temp; // } // else // { // hrAngle = Math.PI + temp; // } // } //} public static double MstFromUTC2(Date utc, double lng) { int year = utc.GetUTCFullYear(); int month = utc.GetUTCMonth()+1; int day = utc.GetUTCDate(); int hour = utc.GetUTCHours(); int minute = utc.GetUTCMinutes(); double second = utc.GetUTCSeconds() + utc.GetUTCMilliseconds() / 1000.0; if (month == 1 || month == 2) { year -= 1; month += 12; } int a = (int)(year / 100); int b = 2 - a + (int)Math.Floor((double)(a / 4.0)); int c = (int)Math.Floor(365.25 * year); int d = (int)Math.Floor(30.6001 * (month + 1)); double julianDays; double jd2; double julianCenturies; double mst; julianDays = b + c + d - 730550.5 + day + (hour + minute / 60.00 + second / 3600.00) / 24.00; julianCenturies = julianDays / 36525.0d; mst = 280.46061837 + 360.98564736629d * julianDays + 0.000387933d * julianCenturies * julianCenturies - julianCenturies * julianCenturies * julianCenturies / 38710000 + lng; if (mst > 0.0) { while (mst > 360.0) { mst = mst - 360.0; } } else { while (mst < 0.0) { mst = mst + 360.0; } } return mst; }
public static double UtcToJulian(Date utc) { int year = utc.GetUTCFullYear(); int month = utc.GetUTCMonth()+1; double day = utc.GetUTCDate(); double hour = utc.GetUTCHours(); double minute = utc.GetUTCMinutes(); double second = utc.GetUTCSeconds() + utc.GetUTCMilliseconds() / 1000.0; double dblDay = day + (hour / 24.0) + (minute / 1440.0) + (second / 86400.0); return AstroCalc.GetJulianDay(year, month, dblDay); //return DateToJD(year, month, dblDay, true); //return julianDays; }