Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

astro Namespace Reference


Classes

class  Date

Enumerations

enum  CoordinateSystem {
  Universal = 0, Ecliptical = 1, Equatorial = 2, Geographic = 3,
  ObserverLocal = 4, PhaseLock = 5, Chase = 6
}
enum  ReferencePlane { BodyEquator, Ecliptic_J2000, Equator_J2000 }

Functions

float absMagToLum (float mag)
float absToAppMag (float absMag, float lyrs)
void anomaly (double meanAnomaly, double eccentricity, double &trueAnomaly, double &eccentricAnomaly)
float appMagToLum (float mag, float lyrs)
float appToAbsMag (float appMag, float lyrs)
double AUtoKilometers (double)
float AUtoKilometers (float)
float AUtoLightYears (float)
double AUtoMicroLightYears (double)
float AUtoMicroLightYears (float)
void decimalToDegMinSec (double angle, int &hours, int &minutes, double &seconds)
double degMinSecToDecimal (int hours, int minutes, double seconds)
Point3d equatorialToCelestialCart (double ra, double dec, double distance)
Point3f equatorialToCelestialCart (float ra, float dec, float distance)
Point3d heliocentricPosition (const UniversalCoord &universal, const Point3f &starPosition)
double julianDateToSeconds (double)
double kilometersToAU (double)
float kilometersToAU (float)
double kilometersToLightYears (double)
float kilometersToLightYears (float)
double kilometersToMicroLightYears (double)
float kilometersToMicroLightYears (float)
double lightYearsToAU (double)
float lightYearsToAU (float)
double lightYearsToKilometers (double)
float lightYearsToKilometers (float)
double lightYearsToParsecs (double)
float lightYearsToParsecs (float)
float lumToAbsMag (float lum)
float lumToAppMag (float lum, float lyrs)
double meanEclipticObliquity (double jd)
double microLightYearsToAU (double)
float microLightYearsToAU (float)
double microLightYearsToKilometers (double)
float microLightYearsToKilometers (float)
double parsecsToLightYears (double)
float parsecsToLightYears (float)
bool parseDate (const std::string &, Date &)
double secondsToJulianDate (double)
float sphereIlluminationFraction (Point3d spherePos, Point3d viewerPos)
UniversalCoord universalPosition (const Point3d &heliocentric, const UniversalCoord &starPosition)
UniversalCoord universalPosition (const Point3d &heliocentric, const Point3f &starPosition)

Variables

const double EarthMass = 5.976e24
const double G = 6.672e-11
const double J2000 = 2451545.0
const double LunarMass = 7.354e22
const double SolarMass = 1.989e30
const double speedOfLight = 299792.458


Enumeration Type Documentation

enum astro::CoordinateSystem
 

Enumeration values:
Universal 
Ecliptical 
Equatorial 
Geographic 
ObserverLocal 
PhaseLock 
Chase 

Definition at line 47 of file astro.h.

00048     {
00049         Universal       = 0,
00050         Ecliptical      = 1,
00051         Equatorial      = 2,
00052         Geographic      = 3,
00053         ObserverLocal   = 4,
00054         PhaseLock       = 5,
00055         Chase           = 6,
00056     };

enum astro::ReferencePlane
 

Enumeration values:
BodyEquator 
Ecliptic_J2000 
Equator_J2000 

Definition at line 58 of file astro.h.

00059     {
00060         BodyEquator,        // planet equator if moon, ecliptic if planet
00061         Ecliptic_J2000,
00062         Equator_J2000,
00063     };


Function Documentation

float astro::absMagToLum float  mag  ) 
 

Definition at line 49 of file astro.cpp.

References exp(), LN_MAG, and SOLAR_ABSMAG.

Referenced by appMagToLum(), and Star::getLuminosity().

00050 {
00051     return (float) exp((SOLAR_ABSMAG - mag) / LN_MAG);
00052 }

float astro::absToAppMag float  absMag,
float  lyrs
 

Definition at line 59 of file astro.cpp.

References LY_PER_PARSEC.

Referenced by displayApparentMagnitude(), displayStarInfo(), Star::getApparentMagnitude(), SelectionPopup::init(), Renderer::labelStars(), lumToAppMag(), DSORenderer::process(), StarRenderer::process(), CelestialBrowser::slotRefresh(), StarBrowserCompareFunc(), and StarBrowserDisplayItem().

00060 {
00061     return (float) (absMag - 5 + 5 * log10(lyrs / LY_PER_PARSEC));
00062 }

void astro::anomaly double  meanAnomaly,
double  eccentricity,
double &  trueAnomaly,
double &  eccentricAnomaly
 

Definition at line 292 of file astro.cpp.

References abs(), cos(), PI, sin(), and sqrt().

Referenced by computePlanetCoords(), and EarthOrbit::computePosition().

00294 {
00295     double e, delta, err;
00296     double tol = 0.00000001745;
00297     int iterations = 20;        // limit while() to maximum of 20 iterations.
00298 
00299     e = meanAnomaly - 2*PI * (int) (meanAnomaly / (2*PI));
00300     err = 1;
00301     while(abs(err) > tol && iterations > 0)
00302     {
00303         err = e - eccentricity*sin(e) - meanAnomaly;
00304         delta = err / (1 - eccentricity * cos(e));
00305         e -= delta;
00306         iterations--;
00307     }
00308 
00309     trueAnomaly = 2*atan(sqrt((1+eccentricity)/(1-eccentricity))*tan(e/2));
00310     eccentricAnomaly = e;
00311 }

float astro::appMagToLum float  mag,
float  lyrs
 

Definition at line 54 of file astro.cpp.

References absMagToLum(), and appToAbsMag().

00055 {
00056     return absMagToLum(appToAbsMag(mag, lyrs));
00057 }

float astro::appToAbsMag float  appMag,
float  lyrs
 

Definition at line 64 of file astro.cpp.

References LY_PER_PARSEC.

Referenced by appMagToLum(), StarDatabase::buildOctree(), DSODatabase::buildOctree(), and StarDatabase::createStar().

00065 {
00066     return (float) (appMag + 5 - 5 * log10(lyrs / LY_PER_PARSEC));
00067 }

double astro::AUtoKilometers double   ) 
 

Definition at line 129 of file astro.cpp.

References KM_PER_AU.

00130 {
00131     return au * (double) KM_PER_AU;
00132 }

float astro::AUtoKilometers float   ) 
 

Definition at line 124 of file astro.cpp.

References KM_PER_AU.

Referenced by PhoebeOrbit::computePosition(), CreateEllipticalOrbit(), getPreferredDistance(), GotoObject(), and GotoObjectProc().

00125 {
00126     return au * (float) KM_PER_AU;
00127 }

float astro::AUtoLightYears float   ) 
 

Definition at line 119 of file astro.cpp.

References AU_PER_LY.

Referenced by ReadDestinationList().

00120 {
00121     return au / (float) AU_PER_LY;
00122 }

double astro::AUtoMicroLightYears double   ) 
 

Definition at line 216 of file astro.cpp.

References AU_PER_LY.

00217 {
00218     return au / (AU_PER_LY * 1e-6);
00219 }

float astro::AUtoMicroLightYears float   ) 
 

Definition at line 211 of file astro.cpp.

References AU_PER_LY.

00212 {
00213     return au / ((float) AU_PER_LY * 1e-6f);
00214 }

void astro::decimalToDegMinSec double  angle,
int &  hours,
int &  minutes,
double &  seconds
 

Definition at line 154 of file astro.cpp.

References B.

Referenced by displayAngle().

00155 {
00156     double A, B, C;
00157 
00158     hours = (int) angle;
00159 
00160     A = angle - (double) hours;
00161     B = A * 60.0;
00162     minutes = (int) B;
00163     C = B - (double) minutes;
00164     seconds = C * 60.0;
00165 }

double astro::degMinSecToDecimal int  hours,
int  minutes,
double  seconds
 

Definition at line 167 of file astro.cpp.

00168 {
00169     return (double)hours + (seconds/60.0 + (double)minutes)/60.0;
00170 }

Point3d astro::equatorialToCelestialCart double  ra,
double  dec,
double  distance
 

Definition at line 280 of file astro.cpp.

References cos(), distance(), equatorialToCelestiald, PI, and sin().

00281 {
00282     double theta = ra / 24.0 * PI * 2 + PI;
00283     double phi = (dec / 90.0 - 1.0) * PI / 2;
00284     double x = cos(theta) * sin(phi) * distance;
00285     double y = cos(phi) * distance;
00286     double z = -sin(theta) * sin(phi) * distance;
00287 
00288     return (Point3d(x, y, z) * equatorialToCelestiald);
00289 }

Point3f astro::equatorialToCelestialCart float  ra,
float  dec,
float  distance
 

Definition at line 266 of file astro.cpp.

References cos(), distance(), equatorialToCelestial, PI, and sin().

Referenced by StarDatabase::createStar(), DumpOldStarDatabase(), ConstellationBoundaries::lineto(), DeepSkyObject::load(), StarDatabase::loadOldFormatBinary(), ConstellationBoundaries::moveto(), Renderer::renderCelestialSphere(), and WriteStarDatabase().

00267 {
00268     double theta = ra / 24.0 * PI * 2 + PI;
00269     double phi = (dec / 90.0 - 1.0) * PI / 2;
00270     double x = cos(theta) * sin(phi) * distance;
00271     double y = cos(phi) * distance;
00272     double z = -sin(theta) * sin(phi) * distance;
00273 
00274     return (Point3f((float) x, (float) y, (float) z) * equatorialToCelestial);
00275 }

Point3d astro::heliocentricPosition const UniversalCoord universal,
const Point3f starPosition
 

Definition at line 227 of file astro.cpp.

References microLightYearsToKilometers(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::labelStars().

00229 {
00230     // Get the offset vector
00231     Vec3d v = universal - Point3d(starPosition.x * 1e6,
00232                                   starPosition.y * 1e6,
00233                                   starPosition.z * 1e6);
00234 
00235     // . . . and convert it to kilometers
00236     return Point3d(microLightYearsToKilometers(v.x),
00237                    microLightYearsToKilometers(v.y),
00238                    microLightYearsToKilometers(v.z));
00239 }

double astro::julianDateToSeconds double   ) 
 

Definition at line 149 of file astro.cpp.

Referenced by CelestiaCore::renderOverlay(), KdePreferencesDialog::setTime(), and tzOffsetAtDate().

00150 {
00151     return jd * 86400.0;
00152 }

double astro::kilometersToAU double   ) 
 

Definition at line 139 of file astro.cpp.

References KM_PER_AU.

00140 {
00141     return km / KM_PER_AU;
00142 }

float astro::kilometersToAU float   ) 
 

Definition at line 134 of file astro.cpp.

References KM_PER_AU.

Referenced by Renderer::renderForegroundOrbits(), Renderer::renderOrbits(), setupObjectLighting(), and StateVectorToOrbit().

00135 {
00136     return km / (float) KM_PER_AU;
00137 }

double astro::kilometersToLightYears double   ) 
 

Definition at line 104 of file astro.cpp.

References KM_PER_LY.

00105 {
00106     return km / KM_PER_LY;
00107 }

float astro::kilometersToLightYears float   ) 
 

Definition at line 99 of file astro.cpp.

References KM_PER_LY.

Referenced by StarDetails::computeOrbitalRadius(), displayPlanetInfo(), GotoObject(), GotoObjectProc(), StarRenderer::process(), ReadDestinationList(), and LongLatDialog::slotApply().

00100 {
00101     return km / (float) KM_PER_LY;
00102 }

double astro::kilometersToMicroLightYears double   ) 
 

Definition at line 196 of file astro.cpp.

References KM_PER_LY.

00197 {
00198     return km / (KM_PER_LY * 1e-6);
00199 }

float astro::kilometersToMicroLightYears float   ) 
 

Definition at line 191 of file astro.cpp.

References KM_PER_LY.

Referenced by Observer::changeOrbitDistance(), CelestiaCore::charEntered(), EclipseFinderProc(), eclipseGoto(), getOrbitDistance(), Star::getPosition(), EclipseFinderDlg::gotoEclipse(), Observer::gotoSelectionGC(), Observer::gotoSurface(), KdePreferencesDialog::ltSubstract(), CommandParser::parseCommand(), CelestiaCore::renderOverlay(), universalPosition(), and Observer::update().

00192 {
00193     return km / ((float) KM_PER_LY * 1e-6f);
00194 }

double astro::lightYearsToAU double   ) 
 

Definition at line 114 of file astro.cpp.

References AU_PER_LY.

00115 {
00116     return ly * AU_PER_LY;
00117 }

float astro::lightYearsToAU float   ) 
 

Definition at line 109 of file astro.cpp.

References AU_PER_LY.

Referenced by displayDistance().

00110 {
00111     return ly * (float) AU_PER_LY;
00112 }

double astro::lightYearsToKilometers double   ) 
 

Definition at line 94 of file astro.cpp.

References KM_PER_LY.

00095 {
00096     return ly * KM_PER_LY;
00097 }

float astro::lightYearsToKilometers float   ) 
 

Definition at line 89 of file astro.cpp.

References KM_PER_LY.

Referenced by displayDistance(), displayPlanetInfo(), displayStarInfo(), KdePreferencesDialog::KdePreferencesDialog(), KdePreferencesDialog::ltSubstract(), StarRenderer::process(), and Selection::radius().

00090 {
00091     return ly * (float) KM_PER_LY;
00092 }

double astro::lightYearsToParsecs double   ) 
 

Definition at line 74 of file astro.cpp.

References LY_PER_PARSEC.

00075 {
00076     return ly / (double) LY_PER_PARSEC;
00077 }

float astro::lightYearsToParsecs float   ) 
 

Definition at line 69 of file astro.cpp.

References LY_PER_PARSEC.

Referenced by displayDistance().

00070 {
00071     return ly / (float) LY_PER_PARSEC;
00072 }

float astro::lumToAbsMag float  lum  ) 
 

Definition at line 37 of file astro.cpp.

References LN_MAG, log(), and SOLAR_ABSMAG.

Referenced by lumToAppMag(), Star::setLuminosity(), and starAbsoluteMagnitudeDecayFunction().

00038 {
00039     return (float) (SOLAR_ABSMAG - log(lum) * LN_MAG);
00040 }

float astro::lumToAppMag float  lum,
float  lyrs
 

Definition at line 44 of file astro.cpp.

References absToAppMag(), and lumToAbsMag().

Referenced by Body::getApparentMagnitude().

00045 {
00046     return absToAppMag(lumToAbsMag(lum), lyrs);
00047 }

double astro::meanEclipticObliquity double  jd  ) 
 

Definition at line 314 of file astro.cpp.

00315 {
00316     double t, de;
00317 
00318     jd -= 2451545.0;
00319     t = jd / 36525;
00320     de = (46.815 * t + 0.0006 * t * t - 0.00181 * t * t * t) / 3600;
00321 
00322     return 23.439292 - de;
00323 }

double astro::microLightYearsToAU double   ) 
 

Definition at line 206 of file astro.cpp.

References AU_PER_LY.

00207 {
00208     return ly * AU_PER_LY * 1e-6;
00209 }

float astro::microLightYearsToAU float   ) 
 

Definition at line 201 of file astro.cpp.

References AU_PER_LY.

Referenced by CelestiaCore::renderOverlay().

00202 {
00203     return ly * (float) AU_PER_LY * 1e-6f;
00204 }

double astro::microLightYearsToKilometers double   ) 
 

Definition at line 186 of file astro.cpp.

References KM_PER_LY.

00187 {
00188     return ly * (KM_PER_LY * 1e-6);
00189 }

float astro::microLightYearsToKilometers float   ) 
 

Definition at line 181 of file astro.cpp.

References KM_PER_LY.

Referenced by Observer::computeGotoParameters(), Observer::computeGotoParametersGC(), ComputeRotationCoarseness(), CelestiaCore::getLightTravelDelay(), Observer::getSelectionLongLat(), Observer::gotoJourney(), Observer::gotoLocation(), heliocentricPosition(), CloseStarPicker::process(), CelestiaCore::renderOverlay(), CelestiaCore::setLightTravelDelay(), and setupLightSources().

00182 {
00183     return ly * ((float) KM_PER_LY * 1e-6f);
00184 }

double astro::parsecsToLightYears double   ) 
 

Definition at line 84 of file astro.cpp.

References LY_PER_PARSEC.

00085 {
00086     return pc * (double) LY_PER_PARSEC;
00087 }

float astro::parsecsToLightYears float   ) 
 

Definition at line 79 of file astro.cpp.

References LY_PER_PARSEC.

00080 {
00081     return pc * (float) LY_PER_PARSEC;
00082 }

bool astro::parseDate const std::string ,
Date & 
 

Definition at line 406 of file astro.cpp.

00407 {
00408     int year = 0;
00409     unsigned int month = 1;
00410     unsigned int day = 1;
00411     unsigned int hour = 0;
00412     unsigned int minute = 0;
00413     unsigned int second = 0;
00414 
00415     if (sscanf(s.c_str(), " %d %u %u %u:%u:%u ",
00416                &year, &month, &day, &hour, &minute, &second) == 6 ||
00417         sscanf(s.c_str(), " %d %u %u %u:%u ",
00418                &year, &month, &day, &hour, &minute) == 5 ||
00419         sscanf(s.c_str(), " %d %u %u ", &year, &month, &day) == 3)
00420     {
00421         if (month < 1 || month > 12)
00422             return false;
00423         if (hour > 23 || minute > 59 || second > 59)
00424             return false;
00425 
00426         // Cheesy days/month calculation . . .
00427         int maxDay = 31 - ((0xa50 >> month) & 0x1);
00428         if (month == 2)
00429         {
00430             // Check for a leap year
00431             if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
00432                 maxDay = 29;
00433             else
00434                 maxDay = 28;
00435         }
00436         if (day > (unsigned int)maxDay || day < 1)
00437             return false;
00438 
00439         date.year = year;
00440         date.month = month;
00441         date.day = day;
00442         date.hour = hour;
00443         date.minute = minute;
00444         date.seconds = second;
00445 
00446         return true;
00447     }
00448 
00449     return false;
00450 }

double astro::secondsToJulianDate double   ) 
 

Definition at line 144 of file astro.cpp.

Referenced by dialogSetTime(), and KdePreferencesDialog::getTime().

00145 {
00146     return sec / 86400.0;
00147 }

float astro::sphereIlluminationFraction Point3d  spherePos,
Point3d  viewerPos
 

Definition at line 175 of file astro.cpp.

00177 {
00178     return 1.0f;
00179 }

UniversalCoord astro::universalPosition const Point3d heliocentric,
const UniversalCoord starPosition
 

Definition at line 254 of file astro.cpp.

References kilometersToMicroLightYears().

00256 {
00257     return starPosition +
00258         Vec3d(kilometersToMicroLightYears(heliocentric.x),
00259               kilometersToMicroLightYears(heliocentric.y),
00260               kilometersToMicroLightYears(heliocentric.z));
00261 }

UniversalCoord astro::universalPosition const Point3d heliocentric,
const Point3f starPosition
 

Definition at line 242 of file astro.cpp.

References kilometersToMicroLightYears().

Referenced by Selection::getPosition().

00244 {
00245     return UniversalCoord(Point3d(starPosition.x * 1e6,
00246                                   starPosition.y * 1e6,
00247                                   starPosition.z * 1e6)) +
00248         Vec3d(kilometersToMicroLightYears(heliocentric.x),
00249               kilometersToMicroLightYears(heliocentric.y),
00250               kilometersToMicroLightYears(heliocentric.z));
00251 }


Variable Documentation

const double astro::EarthMass = 5.976e24
 

Definition at line 27 of file astro.cpp.

const double astro::G = 6.672e-11
 

Definition at line 24 of file astro.cpp.

const double astro::J2000 = 2451545.0
 

Definition at line 22 of file astro.cpp.

const double astro::LunarMass = 7.354e22
 

Definition at line 28 of file astro.cpp.

const double astro::SolarMass = 1.989e30
 

Definition at line 26 of file astro.cpp.

const double astro::speedOfLight = 299792.458
 

Definition at line 19 of file astro.cpp.


Generated on Sat Jan 14 22:33:44 2006 for Celestia by  doxygen 1.4.1