Caelum  0.6.3
Static Public Member Functions | Static Public Attributes | List of all members
Caelum::Astronomy Class Reference

Static class with astronomy routines. More...

#include <Astronomy.h>

Static Public Member Functions

static void convertEclipticToEquatorialRad (LongReal lon, LongReal lat, LongReal &rasc, LongReal &decl)
 Convert from ecliptic to ecuatorial spherical coordinates, in radians. More...
 
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. More...
 
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. More...
 
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. More...
 
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 void getHorizontalNorthEclipticPolePosition (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. More...
 
static LongReal getJulianDayFromGregorianDateTime (int year, int month, int day, int hour, int minute, LongReal second)
 Get astronomical julian day from normal gregorian calendar. More...
 
static LongReal getJulianDayFromGregorianDateTime (int year, int month, int day, LongReal secondsFromMidnight)
 Get astronomical julian day from normal gregorian calendar. More...
 
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. More...
 
static void restoreFloatingPointMode (int oldMode)
 Restore old floating point precission. More...
 

Static Public Attributes

static const LongReal J2000
 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.

Member Function Documentation

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

Convert from ecliptic to ecuatorial spherical coordinates, in radians.

Parameters
lonEcliptic longitude
latEcliptic latitude
rascRight ascension
declDeclination
Warning
: This function works in radians.
static 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
jdayAstronomical time as julian day.
longitudeObserver's longitude in degrees east.
latitudeObserver's latitude in degrees north.
rascObject's right ascension.
declObject's declination.
azimuthObject's azimuth (clockwise degrees from true north).
altitudeObject's altitude (degrees above the horizon).
static 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
jdayAstronomical time as julian day.
longitudeObserver longitude
latitudeObserver latitude
azimuthAstronomical azimuth, measured clockwise from North = 0.
altitudeAstronomical altitude, elevation above the horizon.
static void Caelum::Astronomy::getEclipticMoonPositionRad ( LongReal  jday,
LongReal &  lon,
LongReal &  lat 
)
static

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

Parameters
lonEcliptic longitude, in radians.
latEcliptic latitude, in radians.
static 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.
static 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
static 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).
static 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.
static void Caelum::Astronomy::restoreFloatingPointMode ( int  oldMode)
static

Restore old floating point precission.

See also
enterHighPrecissionFloatingPointMode.

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