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 Petr Kubanek 17 */ 18 19 module nova.parallax; 20 21 import std.math; 22 23 import nova.earth; 24 import nova.utility; 25 import nova.sidereal_time; 26 import nova.ln_types; 27 28 extern (C) { 29 30 /*! \fn void ln_get_parallax(struct ln_equ_posn *object, double au_distance, struct ln_lnlat_posn *observer, double height, double JD, struct ln_equ_posn *parallax); 31 * \param object Object geocentric coordinates 32 * \param au_distance Distance of object from Earth in AU 33 * \param observer Geographics observer positions 34 * \param height Observer height in m 35 * \param JD Julian day of observation 36 * \param parallax RA and DEC parallax 37 * 38 * Calculate body parallax, which is need to calculate topocentric position of the body. 39 */ 40 /* Equ 39.1, 39.2, 39.3 Pg 263 and 264 41 */ 42 @nogc void ln_get_parallax(const ref ln_equ_posn object, double au_distance, 43 const ref ln_lnlat_posn observer, double height, double JD, 44 ref ln_equ_posn parallax) nothrow 45 { 46 double H; 47 48 H = ln_get_apparent_sidereal_time(JD) + 49 (observer.lng - object.ra) / 15.0; 50 ln_get_parallax_ha(object, au_distance, observer, height, H, parallax); 51 } 52 53 54 /*! \fn void ln_get_parallax_ha(struct ln_equ_posn *object, double au_distance, struct ln_lnlat_posn *observer, double height, double H, struct ln_equ_posn *parallax); 55 * \param object Object geocentric coordinates 56 * \param au_distance Distance of object from Earth in AU 57 * \param observer Geographics observer positions 58 * \param height Observer height in m 59 * \param H Hour angle of object in hours 60 * \param parallax RA and DEC parallax 61 * 62 * Calculate body parallax, which is need to calculate topocentric position of the body. 63 * Uses hour angle as time reference (handy in case we already compute it). 64 */ 65 /* Equ 39.1, 39.2, 39.3 Pg 263 and 264 66 */ 67 @nogc void ln_get_parallax_ha(const ref ln_equ_posn object, double au_distance, 68 const ref ln_lnlat_posn observer, double height, double H, 69 ref ln_equ_posn parallax) nothrow 70 { 71 double sin_pi, ro_sin, ro_cos, sin_H, cos_H, dec_rad, cos_dec; 72 73 ln_get_earth_centre_dist (height, observer.lat, ro_sin, ro_cos); 74 sin_pi = sin(ln_deg_to_rad((8.794 / au_distance) / 3600.0)); // (39.1) 75 76 /* change hour angle from hours to radians*/ 77 H *= PI / 12.0; 78 79 sin_H = sin(H); 80 cos_H = cos(H); 81 82 dec_rad = ln_deg_to_rad(object.dec); 83 cos_dec = cos(dec_rad); 84 85 parallax.ra = atan2(-ro_cos * sin_pi * sin_H, cos_dec - ro_cos * 86 sin_pi * cos_H); // (39.2) 87 parallax.dec = atan2((sin(dec_rad) - ro_sin * sin_pi) * 88 cos(parallax.ra), cos_dec - ro_cos * sin_pi * cos_H); // (39.3) 89 90 parallax.ra = ln_rad_to_deg(parallax.ra); 91 parallax.dec = ln_rad_to_deg(parallax.dec) - object.dec; 92 } 93 94 }