Caelum::Astronomy Class Reference

Static class with astronomy routines. More...

#include <Astronomy.h>

List of all members.

Static Public Member Functions

static void convertEclipticToEquatorialRad (LongReal lon, LongReal lat, LongReal &rasc, LongReal &decl)
 Convert from ecliptic to ecuatorial spherical coordinates, in radians.
static void convertRectangularToSpherical (LongReal x, LongReal y, LongReal z, LongReal &rasc, LongReal &decl, LongReal &dist)
static void convertSphericalToRectangular (LongReal rasc, LongReal decl, LongReal dist, LongReal &x, LongReal &y, LongReal &z)
static void convertEquatorialToHorizontal (LongReal jday, LongReal longitude, LongReal latitude, LongReal rasc, LongReal decl, LongReal &azimuth, LongReal &altitude)
 Convert from equatorial to horizontal coordinates.
static void getHorizontalSunPosition (LongReal jday, LongReal longitude, LongReal latitude, LongReal &azimuth, LongReal &altitude)
 Get the sun's position in the sky in, relative to the horizon.
static void getHorizontalSunPosition (LongReal jday, Ogre::Degree longitude, Ogre::Degree latitude, Ogre::Degree &azimuth, Ogre::Degree &altitude)
static void getEclipticMoonPositionRad (LongReal jday, LongReal &lon, LongReal &lat)
 Gets the moon position at a specific time in ecliptic coordinates.
static void getHorizontalMoonPosition (LongReal jday, LongReal longitude, LongReal latitude, LongReal &azimuth, LongReal &altitude)
static void getHorizontalMoonPosition (LongReal jday, Ogre::Degree longitude, Ogre::Degree latitude, Ogre::Degree &azimuth, Ogre::Degree &altitude)
static int getJulianDayFromGregorianDate (int year, int month, int day)
 Get astronomical julian day from normal gregorian calendar.
static LongReal getJulianDayFromGregorianDateTime (int year, int month, int day, int hour, int minute, LongReal second)
 Get astronomical julian day from normal gregorian calendar.
static LongReal getJulianDayFromGregorianDateTime (int year, int month, int day, LongReal secondsFromMidnight)
 Get astronomical julian day from normal gregorian calendar.
static void getGregorianDateFromJulianDay (int julianDay, int &year, int &month, int &day)
 Get gregorian date from integer julian day.
static void getGregorianDateTimeFromJulianDay (LongReal julianDay, int &year, int &month, int &day, int &hour, int &minute, LongReal &second)
 Get gregorian date time from floating point julian day.
static void getGregorianDateFromJulianDay (LongReal julianDay, int &year, int &month, int &day)
 Get gregorian date from floating point julian day.
static int enterHighPrecissionFloatingPointMode ()
 Enter high-precission floating-point mode.
static void restoreFloatingPointMode (int oldMode)
 Restore old floating point precission.

Static Public Attributes

static const LongReal J2000 = 2451545.0
 January 1, 2000, noon.


Detailed Description

Static class with astronomy routines.

This class contains various astronomical routines useful in Caelum.

Most of the formulas are from http://stjarnhimlen.se/comp/ppcomp.html That site contains much more than was implemented here; it has code for determining the positions of all the planets. Only the sun and moon are actually useful for caelum.

The formulas are isolated here in pure procedural code for easier testing (Tests are done as assertions in the demo).

Precision is vital here, so this class uses Caelum::LongReal(double) instead of Ogre::Real(float) for precission. All angles are in degrees unless otherwise mentioned. Ogre::Degree and Ogre::Radian use Ogre::Real and should be avoided here.

Definition at line 44 of file Astronomy.h.


Member Function Documentation

void Caelum::Astronomy::convertEclipticToEquatorialRad ( LongReal  lon,
LongReal  lat,
LongReal &  rasc,
LongReal &  decl 
) [static]

Convert from ecliptic to ecuatorial spherical coordinates, in radians.

Parameters:
lon Ecliptic longitude
lat Ecliptic latitude
rasc Right ascension
decl Declination
Warning:
: This function works in radians.

Definition at line 61 of file Astronomy.cpp.

Referenced by getHorizontalSunPosition().

void Caelum::Astronomy::convertEquatorialToHorizontal ( LongReal  jday,
LongReal  longitude,
LongReal  latitude,
LongReal  rasc,
LongReal  decl,
LongReal &  azimuth,
LongReal &  altitude 
) [static]

Convert from equatorial to horizontal coordinates.

This function converts from angles relative to the earth's equator to angle relative to the horizon at a given point.

Parameters:
jday Astronomical time as julian day.
longitude Observer's longitude in degrees east.
latitude Observer's latitude in degrees north.
rasc Object's right ascension.
decl Object's declination.
azimuth Object's azimuth (clockwise degrees from true north).
altitude Object's altitude (degrees above the horizon).

Definition at line 94 of file Astronomy.cpp.

Referenced by getHorizontalSunPosition().

void Caelum::Astronomy::getHorizontalSunPosition ( LongReal  jday,
LongReal  longitude,
LongReal  latitude,
LongReal &  azimuth,
LongReal &  altitude 
) [static]

Get the sun's position in the sky in, relative to the horizon.

Parameters:
jday Astronomical time as julian day.
longitude Observer longitude
latitude Observer latitude
azimuth Astronomical azimuth, measured clockwise from North = 0.
altitude Astronomical altitude, elevation above the horizon.

Definition at line 121 of file Astronomy.cpp.

References convertEclipticToEquatorialRad(), and convertEquatorialToHorizontal().

Referenced by Caelum::CaelumSystem::getSunDirection().

void Caelum::Astronomy::getEclipticMoonPositionRad ( LongReal  jday,
LongReal &  lon,
LongReal &  lat 
) [static]

Gets the moon position at a specific time in ecliptic coordinates.

Parameters:
lon,: Ecliptic longitude, in radians.
lat,: Ecliptic latitude, in radians.

Definition at line 173 of file Astronomy.cpp.

int Caelum::Astronomy::getJulianDayFromGregorianDate ( int  year,
int  month,
int  day 
) [static]

Get astronomical julian day from normal gregorian calendar.

From wikipedia: the integer number of days that have elapsed since the initial epoch defined as noon Universal Time (UT) Monday, January 1, 4713 BC

Note:
this is the time at noon, not midnight.

Definition at line 241 of file Astronomy.cpp.

Referenced by getJulianDayFromGregorianDateTime().

LongReal Caelum::Astronomy::getJulianDayFromGregorianDateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
LongReal  second 
) [static]

Get astronomical julian day from normal gregorian calendar.

Calculate julian day from a day in the normal gregorian calendar. Time should be given as UTC.

See also:
http://en.wikipedia.org/wiki/Julian_day

Definition at line 253 of file Astronomy.cpp.

References getJulianDayFromGregorianDate().

Referenced by Caelum::UniversalClock::setGregorianDateTime().

LongReal Caelum::Astronomy::getJulianDayFromGregorianDateTime ( int  year,
int  month,
int  day,
LongReal  secondsFromMidnight 
) [static]

Get astronomical julian day from normal gregorian calendar.

See also:
above (I don't know the proper doxygen syntax).

Definition at line 266 of file Astronomy.cpp.

References getJulianDayFromGregorianDate().

int Caelum::Astronomy::enterHighPrecissionFloatingPointMode (  )  [static]

Enter high-precission floating-point mode.

By default Direct3D decreases the precission of ALL floating point calculations, enough to stop Caelum's astronomy routines from working correctly.

To trigger this behaviour in a standard ogre demo select the Direct3D render system and set "Floating-point mode" to "Fastest". Otherwise it's not a problem.

It can be fixed by changing the precission only inside caelum's astronomy routines using the _controlfp function. This only works for MSVC on WIN32; This is a no-op on other compilers.

Note:
: Must be paired with restoreFloatingPointMode.
Returns:
Value to pass to restoreFloatingModeMode.

Definition at line 325 of file Astronomy.cpp.

void Caelum::Astronomy::restoreFloatingPointMode ( int  oldMode  )  [static]

Restore old floating point precission.

See also:
enterHighPrecissionFloatingPointMode.

Definition at line 332 of file Astronomy.cpp.


The documentation for this class was generated from the following files:

Generated on Sun Aug 9 10:24:21 2009 for Caelum by  doxygen 1.5.9