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.refraction; 20 21 import std.math; 22 import nova.utility; 23 24 extern (C) { 25 26 /*! \fn double ln_get_refraction_adj (double altitude, double atm_pres, double temp) 27 * \param altitude The altitude of the object above the horizon in degrees 28 * \param atm_pres Atmospheric pressure in milibars 29 * \param temp Temperature in degrees C. 30 * \return Adjustment in objects altitude in degrees. 31 * 32 * Calculate the adjustment in altitude of a body due to atmosphric 33 * refraction. This value varies over altitude, pressure and temperature. 34 * 35 * Note: Default values for pressure and teperature are 1010 mBar and 10C 36 * respectively. 37 */ 38 @nogc double ln_get_refraction_adj(double altitude, double atm_pres, double temp) nothrow 39 { 40 real R; 41 42 /* equ 16.3 */ 43 R = 1.0 / tan(ln_deg_to_rad(altitude + (7.31 / (altitude + 4.4)))); 44 R -= 0.06 * sin(ln_deg_to_rad(14.7 * (R / 60.0) + 13.0)); 45 46 /* take into account of atm press and temp */ 47 R *= ((atm_pres / 1010.0) * (283.0 / (273.0 + temp))); 48 49 /* convert from arcminutes to degrees */ 50 R /= 60.0; 51 52 return R; 53 } 54 55 }