head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.40; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.58; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.04; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.01; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# star.cxx

    00001 /**************************************************************************
    00002  * star.cxx
    00003  * Written by Durk Talsma. Originally started October 1997, for distribution
    00004  * with the FlightGear project. Version 2 was written in August and
    00005  * September 1998. This code is based upon algorithms and data kindly
    00006  * provided by Mr. Paul Schlyter. (pausch@@saaf.se).
    00007  *
    00008  * This library is free software; you can redistribute it and/or
    00009  * modify it under the terms of the GNU Library General Public
    00010  * License as published by the Free Software Foundation; either
    00011  * version 2 of the License, or (at your option) any later version.
    00012  *
    00013  * This library 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 GNU
    00016  * Library General Public License for more details.
    00017  *
    00018  * You should have received a copy of the GNU Library General Public
    00019  * License along with this library; if not, write to the
    00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00021  * Boston, MA  02111-1307, USA.
    00022  *
    00023  * $Id: star.cxx,v 1.15 2001/03/24 03:20:47 curt Exp $
    00024  **************************************************************************/
    00025
    00026
    00027 #ifdef __BORLANDC__
    00028 #  define exception c_exception
    00029 #endif
    00030 #include <math.h>
    00031
    00032 #include <simgear/debug/logstream.hxx>
    00033
    00034 #include "star.hxx"
    00035
    00036
    00037 /*************************************************************************
    00038  * Star::Star(double mjd)
    00039  * Public constructor for class Star
    00040  * Argument: The current time.
    00041  * the hard coded orbital elements our sun are passed to
    00042  * CelestialBody::CelestialBody();
    00043  * note that the word sun is avoided, in order to prevent some compilation
    00044  * problems on sun systems
    00045  ************************************************************************/
    00046 Star::Star(double mjd) :
    00047     CelestialBody (0.000000,  0.0000000000,
    00048                    0.0000,    0.00000,
    00049                    282.9404,  4.7093500E-5,
    00050                    1.0000000, 0.000000,
    00051                    0.016709,  -1.151E-9,
    00052                    356.0470,  0.98560025850, mjd)
    00053 {
    00054     distance = 0.0;
    00055 }
    00056
    00057 Star::Star() :
    00058     CelestialBody (0.000000,  0.0000000000,
    00059                    0.0000,    0.00000,
    00060                    282.9404,  4.7093500E-5,
    00061                    1.0000000, 0.000000,
    00062                    0.016709,  -1.151E-9,
    00063                    356.0470,  0.98560025850)
    00064 {
    00065     distance = 0.0;
    00066 }
    00067
    00068 Star::~Star()
    00069 {
    00070 }
    00071
    00072
    00073 /*************************************************************************
    00074  * void Star::updatePosition(double mjd, Star *ourSun)
    00075  *
    00076  * calculates the current position of our sun.
    00077  *************************************************************************/
    00078 void Star::updatePosition(double mjd)
    00079 {
    00080   double
    00081     actTime, eccAnom,
    00082     xv, yv, v, r,
    00083     xe, ye, ze, ecl;
    00084
    00085   updateOrbElements(mjd);
    00086
    00087   actTime = sgCalcActTime(mjd);
    00088   ecl = SGD_DEGREES_TO_RADIANS * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
    00089   eccAnom = sgCalcEccAnom(M, e);  // Calculate the eccentric Anomaly (also known as solving Kepler's equation)
    00090
    00091   xv = cos(eccAnom) - e;
    00092   yv = sqrt (1.0 - e*e) * sin(eccAnom);
    00093   v = atan2 (yv, xv);                   // the sun's true anomaly
    00094   distance = r = sqrt (xv*xv + yv*yv);  // and its distance
    00095
    00096   lonEcl = v + w; // the sun's true longitude
    00097   latEcl = 0;
    00098
    00099   // convert the sun's true longitude to ecliptic rectangular
    00100   // geocentric coordinates (xs, ys)
    00101   xs = r * cos (lonEcl);
    00102   ys = r * sin (lonEcl);
    00103
    00104   // convert ecliptic coordinates to equatorial rectangular
    00105   // geocentric coordinates
    00106
    00107   xe = xs;
    00108   ye = ys * cos (ecl);
    00109   ze = ys * sin (ecl);
    00110
    00111   // And finally, calculate right ascension and declination
    00112   rightAscension = atan2 (ye, xe);
    00113   declination = atan2 (ze, sqrt (xe*xe + ye*ye));
    00114 }

@ 1.3 log @Oops, try again. @ text @d123 1 a123 1