X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fephemeris%2FcelestialBody.hxx;h=e555deef54078e7e1483a1d88bd20ba84bcc83cd;hb=598b64fa9569c16878c904e344e2e2775e210c42;hp=c9cda8b9e9ff93cfdc4c5dcf98e340fa44820681;hpb=a46163bcd7fe4daa2bcfc95d6d609870797bad70;p=simgear.git diff --git a/simgear/ephemeris/celestialBody.hxx b/simgear/ephemeris/celestialBody.hxx index c9cda8b9..e555deef 100644 --- a/simgear/ephemeris/celestialBody.hxx +++ b/simgear/ephemeris/celestialBody.hxx @@ -5,19 +5,19 @@ * September 1998. This code is based upon algorithms and data kindly * provided by Mr. Paul Schlyter. (pausch@saaf.se). * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Library General Public License for more details. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $Id$ **************************************************************************/ @@ -26,13 +26,12 @@ #ifndef _CELESTIALBODY_H_ #define _CELESTIALBODY_H_ -#ifndef __cplusplus +#ifndef __cplusplus # error This library requires C++ -#endif +#endif #include -#include class Star; @@ -60,9 +59,9 @@ protected: // make the data protected, in order to give the double magnitude; double lonEcl, latEcl; - double fgCalcEccAnom(double M, double e); - double fgCalcActTime(FGTime *t); - void updateOrbElements(FGTime *t); + double sgCalcEccAnom(double M, double e); + double sgCalcActTime(double mjd); + void updateOrbElements(double mjd); public: CelestialBody(double Nf, double Ns, @@ -70,7 +69,7 @@ public: double wf, double ws, double af, double as, double ef, double es, - double Mf, double Ms, FGTime *t); + double Mf, double Ms, double mjd); CelestialBody(double Nf, double Ns, double If, double Is, double wf, double ws, @@ -82,142 +81,24 @@ public: double getRightAscension(); double getDeclination(); double getMagnitude(); - double getLon(); - double getLat(); - void updatePosition(FGTime *t, Star *ourSun); + double getLon() const; + double getLat() const; + void updatePosition(double mjd, Star *ourSun); }; -/***************************************************************************** - * 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. - ***************************************************************************/ -inline 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, FGTime *t) -{ - 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(t); -}; - -inline 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(FGTime *t) - * given the current time, this private member calculates the actual - * orbital elements - * - * Arguments: FGTime *t: the current time: - * - * return value: none - ***************************************************************************/ -inline void CelestialBody::updateOrbElements(FGTime *t) -{ - double actTime = fgCalcActTime(t); - M = DEG_TO_RAD * (MFirst + (MSec * actTime)); - w = DEG_TO_RAD * (wFirst + (wSec * actTime)); - N = DEG_TO_RAD * (NFirst + (NSec * actTime)); - i = DEG_TO_RAD * (iFirst + (iSec * actTime)); - e = eFirst + (eSec * actTime); - a = aFirst + (aSec * actTime); -} -/***************************************************************************** - * inline double CelestialBody::fgCalcActTime(FGTime *t) - * 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. - ****************************************************************************/ -inline double CelestialBody::fgCalcActTime(FGTime *t) -{ - return (t->getMjd() - 36523.5); -} - -/***************************************************************************** - * inline void CelestialBody::getPos(double* ra, double* dec) - * gives public access to Right Ascension and declination - * - ****************************************************************************/ -inline 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 - ****************************************************************************/ -inline void CelestialBody::getPos(double* ra, double* dec, double* magn) -{ - *ra = rightAscension; - *dec = declination; - *magn = magnitude; -} - inline double CelestialBody::getRightAscension() { return rightAscension; } inline double CelestialBody::getDeclination() { return declination; } inline double CelestialBody::getMagnitude() { return magnitude; } -inline double CelestialBody::getLon() +inline double CelestialBody::getLon() const { return lonEcl; } -inline double CelestialBody::getLat() +inline double CelestialBody::getLat() const { return latEcl; } #endif // _CELESTIALBODY_H_ - - - - - - - - - - -