00001 /* 00002 * Sol.cpp 00003 * 00004 * Part of Fly! Legacy project 00005 * 00006 * Copyright 2003 Chris Wallace 00007 * 00008 * Fly! Legacy is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * Fly! Legacy is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with Fly! Legacy; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 */ 00023 00032 #include <math.h> 00033 #include "../Include/Ephemeris.h" 00034 00035 // 00036 // Default orbital elements 00037 // 00038 static const SOrbitalElements first = 00039 { 00040 0.0, // N, Longitude of the ascending node 00041 0.0, // i, Inclination to the ecliptic 00042 282.9404, // w, Argument of perihelion 00043 1.000000, // a, Semi-major axis 00044 0.016709, // e, Eccentricity 00045 356.0470 // M, Mean anomaly 00046 }; 00047 00048 static const SOrbitalElements second = 00049 { 00050 0.0000000, // N, Longitude of the ascending node 00051 0.0000000, // i, Inclination to the ecliptic 00052 4.7093500E-5, // w, Argument of perihelion 00053 0.0000000, // a, Semi-major axis 00054 -1.151E-9, // e, Eccentricity 00055 0.98560025850 // M, Mean anomaly 00056 }; 00057 00058 00059 /************************************************************************* 00060 * CSol::CSol(double mjd) 00061 * Public constructor for class Star 00062 * Argument: The current time. 00063 * the hard coded orbital elements our sun are passed to 00064 * CelestialBody::CelestialBody(); 00065 * note that the word sun is avoided, in order to prevent some compilation 00066 * problems on sun systems 00067 ************************************************************************/ 00068 CSol::CSol (double mjd) : 00069 CCelestialBody (first.N, first.i, first.w, first.a, first.e, first.M, 00070 second.N, second.i, second.w, second.a, second.e, second.M, 00071 mjd) 00072 { 00073 distance = 0.0; 00074 } 00075 00076 CSol::CSol () : 00077 CCelestialBody (first.N, first.i, first.w, first.a, first.e, first.M, 00078 second.N, second.i, second.w, second.a, second.e, second.M) 00079 { 00080 distance = 0.0; 00081 } 00082 00083 CSol::~CSol() 00084 { 00085 } 00086 00087 00088 /************************************************************************* 00089 * void CSol::updatePosition (double mjd) 00090 * 00091 * calculates the current position of our sun. 00092 *************************************************************************/ 00093 void CSol::UpdatePosition(double mjd) 00094 { 00095 // Determine number of days since the epoch for this algorithm: 1 Jan 2000 00096 double d = CalcActTime(mjd); 00097 00098 // Update orbital elements for the current date/time 00099 UpdateOrbElements(mjd); 00100 00101 // Calculate obliquity of the ecliptic in radians 00102 double ecl = SGD_DEGREES_TO_RADIANS * (23.4393 - 3.563E-7 * d); 00103 00104 // Calculate eccentric anomaly (aka solving Kepler's equation) 00105 // Result is in radians 00106 double eccAnom = CalcEccAnom(M, e); 00107 00108 // Calculate distance (r) and true anomaly (v) 00109 double xv = cos(eccAnom) - e; 00110 double yv = sqrt (1.0 - e*e) * sin(eccAnom); 00111 double v = atan2 (yv, xv); 00112 double r = sqrt (xv*xv + yv*yv); // and its distance 00113 distance = r; 00114 00115 // Calculate true longitude and latitude 00116 lonEcl = v + w; 00117 latEcl = 0; 00118 00119 // Convert true longitude to ecliptic rectangular geocentric 00120 // coordinates (xs, ys) 00121 xs = r * cos (lonEcl); 00122 ys = r * sin (lonEcl); 00123 00124 // Convert ecliptic coordinates to equatorial rectangular 00125 // geocentric coordinates 00126 double xe = xs; 00127 double ye = ys * cos (ecl); 00128 double ze = ys * sin (ecl); 00129 00130 // And finally, calculate right ascension and declination 00131 rightAscension = atan2 (ye, xe); 00132 declination = atan2 (ze, sqrt (xe*xe + ye*ye)); 00133 } 00134 00135 00136 /************************************************************************** 00137 * star.cxx 00138 * Written by Durk Talsma. Originally started October 1997, for distribution 00139 * with the FlightGear project. Version 2 was written in August and 00140 * September 1998. This code is based upon algorithms and data kindly 00141 * provided by Mr. Paul Schlyter. (pausch@saaf.se). 00142 * 00143 * This library is free software; you can redistribute it and/or 00144 * modify it under the terms of the GNU Library General Public 00145 * License as published by the Free Software Foundation; either 00146 * version 2 of the License, or (at your option) any later version. 00147 * 00148 * This library is distributed in the hope that it will be useful, 00149 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00150 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00151 * Library General Public License for more details. 00152 * 00153 * You should have received a copy of the GNU Library General Public 00154 * License along with this library; if not, write to the 00155 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00156 * Boston, MA 02111-1307, USA. 00157 * 00158 **************************************************************************/ 00159
|
|
Documentation generated by
|