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) 2009 Petr Kubanek 17 */ 18 19 module nova.heliocentric_time; 20 21 import std.math; 22 23 import nova.nutation; 24 import nova.earth; 25 import nova.utility; 26 import nova.ln_types; 27 28 extern (C) { 29 30 /*! \fn double ln_get_heliocentric_time_diff(double JD, struct ln_equ_posn *object) 31 * \param JD Julian day 32 * \param object Pointer to object (RA, DEC) for which heliocentric correction will be caculated 33 * 34 * \return Heliocentric correction in fraction of day 35 * 36 * Calculate heliocentric corection for object at given coordinates and on given 37 * date. 38 * 39 * Due to the finite speed of light, events outside of the solar system are seen 40 * at different times within the solar system depending on the observer's position. 41 * This function corrects for that, converting a time at the Earth to the time 42 * at the center of the solar system. 43 * 44 * For example, an event happening overhead at midnight is seen at the Earth 45 * roughly eight minutes before it's seen at the Sun. Given the date, and 46 * the equatorial position of the object, this function returns the difference 47 * expressed in Julian days. 48 * 49 * See [Wikipedia](https://en.wikipedia.org/wiki/Heliocentric_Julian_Day) 50 */ 51 @nogc double ln_get_heliocentric_time_diff(double JD, const ref ln_equ_posn object) nothrow 52 { 53 double theta, ra, dec, c_dec, obliq; 54 ln_nutation nutation; 55 ln_helio_posn earth; 56 57 ln_get_nutation(JD, nutation); 58 ln_get_earth_helio_coords(JD, earth); 59 60 theta = ln_deg_to_rad(ln_range_degrees(earth.L + 180)); 61 ra = ln_deg_to_rad(object.ra); 62 dec = ln_deg_to_rad(object.dec); 63 c_dec = cos(dec); 64 obliq = ln_deg_to_rad(nutation.ecliptic); 65 66 /* L.Binnendijk Properties of Double Stars, 67 * Philadelphia, University of Pennselvania Press, pp. 228-232, 1960 */ 68 return -0.0057755 * earth.R * 69 (cos(theta) * cos(ra) * c_dec 70 + sin(theta) * (sin(obliq) * sin(dec) + cos(obliq) * c_dec * sin(ra))); 71 } 72 73 }