X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fephemeris%2FcelestialBody.cxx;h=4e8873925b65ef7290aba629afcf390648d4ac29;hb=f19e83dcf10d5fced3d799c884a4654d7ada6548;hp=ae6a792982890b5aa3f22198c109371870adf7b9;hpb=557fade4a7df3f030b943ba6114c3c566c57b73c;p=simgear.git diff --git a/simgear/ephemeris/celestialBody.cxx b/simgear/ephemeris/celestialBody.cxx index ae6a7929..4e887392 100644 --- a/simgear/ephemeris/celestialBody.cxx +++ b/simgear/ephemeris/celestialBody.cxx @@ -15,19 +15,15 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $Id$ **************************************************************************/ #include -#ifdef SG_MATH_EXCEPTION_CLASH -# define exception c_exception -#endif #include #include "celestialBody.hxx" @@ -158,22 +154,112 @@ double CelestialBody::sgCalcEccAnom(double M, double e) return eccAnom; } +/***************************************************************************** + * inline CelestialBody::CelestialBody + * public constructor for a generic celestialBody object. + * initializes the 6 primary orbital elements. The elements are: + * N: longitude of the ascending node + * i: inclination to the ecliptic + * w: argument of perihelion + * a: semi-major axis, or mean distance from the sun + * e: eccenticity + * M: mean anomaly + * Each orbital element consists of a constant part and a variable part that + * gradually changes over time. + * + * Argumetns: + * the 13 arguments to the constructor constitute the first, constant + * ([NiwaeM]f) and the second variable ([NiwaeM]s) part of the orbital + * elements. The 13th argument is the current time. Note that the inclination + * is written with a capital (If, Is), because 'if' is a reserved word in the + * C/C++ programming language. + ***************************************************************************/ +CelestialBody::CelestialBody(double Nf, double Ns, + double If, double Is, + double wf, double ws, + double af, double as, + double ef, double es, + double Mf, double Ms, double mjd) +{ + NFirst = Nf; NSec = Ns; + iFirst = If; iSec = Is; + wFirst = wf; wSec = ws; + aFirst = af; aSec = as; + eFirst = ef; eSec = es; + MFirst = Mf; MSec = Ms; + updateOrbElements(mjd); +} +CelestialBody::CelestialBody(double Nf, double Ns, + double If, double Is, + double wf, double ws, + double af, double as, + double ef, double es, + double Mf, double Ms) +{ + NFirst = Nf; NSec = Ns; + iFirst = If; iSec = Is; + wFirst = wf; wSec = ws; + aFirst = af; aSec = as; + eFirst = ef; eSec = es; + MFirst = Mf; MSec = Ms; +} +/**************************************************************************** + * inline void CelestialBody::updateOrbElements(double mjd) + * given the current time, this private member calculates the actual + * orbital elements + * + * Arguments: double mjd: the current modified julian date: + * + * return value: none + ***************************************************************************/ +void CelestialBody::updateOrbElements(double mjd) +{ + double actTime = sgCalcActTime(mjd); + M = SGD_DEGREES_TO_RADIANS * (MFirst + (MSec * actTime)); + w = SGD_DEGREES_TO_RADIANS * (wFirst + (wSec * actTime)); + N = SGD_DEGREES_TO_RADIANS * (NFirst + (NSec * actTime)); + i = SGD_DEGREES_TO_RADIANS * (iFirst + (iSec * actTime)); + e = eFirst + (eSec * actTime); + a = aFirst + (aSec * actTime); +} +/***************************************************************************** + * inline double CelestialBody::sgCalcActTime(double mjd) + * this private member function returns the offset in days from the epoch for + * wich the orbital elements are calculated (Jan, 1st, 2000). + * + * Argument: the current time + * + * return value: the (fractional) number of days until Jan 1, 2000. + ****************************************************************************/ +double CelestialBody::sgCalcActTime(double mjd) +{ + return (mjd - 36523.5); +} +/***************************************************************************** + * inline void CelestialBody::getPos(double* ra, double* dec) + * gives public access to Right Ascension and declination + * + ****************************************************************************/ +void CelestialBody::getPos(double* ra, double* dec) +{ + *ra = rightAscension; + *dec = declination; +} - - - - - - - - - - - - +/***************************************************************************** + * inline void CelestialBody::getPos(double* ra, double* dec, double* magnitude + * gives public acces to the current Right ascension, declination, and + * magnitude + ****************************************************************************/ +void CelestialBody::getPos(double* ra, double* dec, double* magn) +{ + *ra = rightAscension; + *dec = declination; + *magn = magnitude; +}