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.asteroid; 20 21 import std.math; 22 23 import nova.elliptic_motion; 24 import nova.utility; 25 import nova.ln_types; 26 27 extern (C) { 28 29 /*! 30 * \brief Calculate the visual magnitude of an asteroid 31 * \param JD Julian day. 32 * \param orbit Orbital parameters 33 * \param H Mean absolute visual magnitude 34 * \param G Slope parameter 35 * \return The visual magnitude. 36 * 37 * Calculate the visual magnitude of an asteroid. 38 */ 39 @nogc double ln_get_asteroid_mag(double JD, ref ln_ell_orbit orbit, double H, 40 double G) nothrow 41 { 42 double t1,t2; 43 double b,r,d; 44 double E,M; 45 46 /* get phase angle */ 47 b = ln_get_ell_body_phase_angle(JD, orbit); 48 b = ln_deg_to_rad(b); 49 50 /* get mean anomaly */ 51 if (orbit.n == 0) 52 orbit.n = ln_get_ell_mean_motion(orbit.a); 53 M = ln_get_ell_mean_anomaly(orbit.n, JD - orbit.JD); 54 55 /* get eccentric anomaly */ 56 E = ln_solve_kepler(orbit.e, M); 57 58 /* get radius vector */ 59 r = ln_get_ell_radius_vector(orbit.a, orbit.e, E); 60 d = ln_get_ell_body_solar_dist(JD, orbit); 61 62 t1 = exp(-3.33 * pow(tan(b / 2.0), 0.63)); 63 t2 = exp(-0.187 * pow(tan(b / 2.0), 1.22)); 64 65 return H + 5.0 * log10(r * d) - 2.5 * log10((1.0 - G) * t1 + G * t2); 66 } 67 68 /*! \fn double ln_get_asteroid_sdiam_km (double H, double A) 69 * \param H Absolute magnitude of asteroid 70 * \param A Albedo of asteroid 71 * \return Semidiameter in km 72 * 73 * Calculate the semidiameter of an asteroid in km. 74 * 75 * Note: Many asteroids have an irregular shape and therefore this function returns 76 * an approximate value of the diameter. 77 */ 78 @nogc double ln_get_asteroid_sdiam_km (double H, double A) nothrow 79 { 80 return 3.13 - 0.2 * H - (0.5 * log10(A)); 81 } 82 83 /*! \fn double ln_get_asteroid_sdiam_arc(double JD, struct ln_ell_orbit *orbit, double H, double A) 84 * \param JD Julian day 85 * \param orbit Orbital parameters 86 * \param H Absolute magnitude of asteroid 87 * \param A Albedo of asteroid 88 * \return Semidiameter in seconds of arc 89 * 90 * Calculate the semidiameter of an asteroid in arc seconds. 91 * 92 * Note: Many asteroids have an irregular shape and therefore this function returns 93 * an approximate value of the diameter. 94 */ 95 @nogc double ln_get_asteroid_sdiam_arc(double JD, ref ln_ell_orbit orbit, double H, double A) nothrow 96 { 97 double d, dist; 98 99 /* calc distance to Earth in AU */ 100 dist = ln_get_ell_body_earth_dist(JD, orbit); 101 102 d = 3.13 - 0.2 * H - (0.5 * log10(A)); 103 return 0.0013788 * d / dist; 104 } 105 106 /*! \example asteroid.c 107 * 108 * Examples of how to use asteroid functions. 109 */ 110 111 }