1 /* 2 * This library is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU Lesser General Public 4 * License as published by the Free Software Foundation; either 5 * version 2 of the License, or (at your option) any later version. 6 * 7 * This library is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 * Lesser General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 * 16 * Copyright (C) 2000 - 2005 Liam Girdwood <lgirdwood@gmail.com> 17 */ 18 19 module nova.sidereal_time; 20 21 import std.math; 22 23 import nova.nutation; 24 import nova.utility; 25 import nova.ln_types; 26 27 extern (C) { 28 29 /*! \fn double ln_get_mean_sidereal_time(double JD) 30 * \param JD Julian Day 31 * \return Mean sidereal time (hours). 32 * 33 * Calculate the mean sidereal time at the meridian of Greenwich of a given date. 34 */ 35 /* Formula 11.1, 11.4 pg 83 36 */ 37 38 @nogc double ln_get_mean_sidereal_time(double JD) nothrow 39 { 40 real sidereal; 41 real T; 42 43 T =(JD - 2451545.0) / 36525.0; 44 45 /* calc mean angle */ 46 sidereal = 280.46061837 + (360.98564736629 *(JD - 2451545.0)) + 47 (0.000387933 * T * T) - (T * T * T / 38710000.0); 48 49 /* add a convenient multiple of 360 degrees */ 50 sidereal = ln_range_degrees(sidereal); 51 52 /* change to hours */ 53 sidereal *= 24.0 / 360.0; 54 55 return sidereal; 56 } 57 58 /*! \fn double ln_get_apparent_sidereal_time(double JD) 59 * \param JD Julian Day 60 * /return Apparent sidereal time (hours). 61 * 62 * Calculate the apparent sidereal time at the meridian of Greenwich of a given date, 63 * corrected for nutation. 64 */ 65 /* Formula 11.1, 11.4 pg 83 66 */ 67 68 @nogc double ln_get_apparent_sidereal_time(double JD) nothrow 69 { 70 double correction, sidereal; 71 ln_nutation nutation; 72 73 /* get the mean sidereal time */ 74 sidereal = ln_get_mean_sidereal_time(JD); 75 76 /* add corrections for nutation in longitude and for the true obliquity of 77 the ecliptic */ 78 ln_get_nutation(JD, nutation); 79 80 correction = (nutation.longitude / 15.0 * 81 cos(ln_deg_to_rad(nutation.obliquity))); 82 83 sidereal += correction; 84 85 return sidereal; 86 } 87 88 }