#include <Astronomy.h>
Static Public Member Functions | |
static void | convertEclipticToEquatorialRad (LongReal lon, LongReal lat, LongReal &rasc, LongReal &decl) |
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) |
static void | getHorizontalSunPosition (LongReal jday, LongReal longitude, LongReal latitude, LongReal &azimuth, LongReal &altitude) |
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) |
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) |
static LongReal | getJulianDayFromGregorianDateTime (int year, int month, int day, int hour, int minute, LongReal second) |
static LongReal | getJulianDayFromGregorianDateTime (int year, int month, int day, LongReal secondsFromMidnight) |
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 () |
static void | restoreFloatingPointMode (int oldMode) |
Static Public Attributes | |
static const LongReal | J2000 = 2451545.0 |
January 1, 2000, noon. |
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.
void caelum::Astronomy::convertEclipticToEquatorialRad | ( | LongReal | lon, | |
LongReal | lat, | |||
LongReal & | rasc, | |||
LongReal & | decl | |||
) | [static] |
Convert from ecliptic to ecuatorial spherical coordinates, in radians.
lon | Ecliptic longitude | |
lat | Ecliptic latitude | |
rasc | Right ascension | |
decl | Declination |
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.
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.
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::SolarSystemModel::getSunDirection().
void caelum::Astronomy::getEclipticMoonPositionRad | ( | LongReal | jday, | |
LongReal & | lon, | |||
LongReal & | lat | |||
) | [static] |
Gets the moon position at a specific time in ecliptic coordinates
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
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.
Definition at line 253 of file Astronomy.cpp.
References enterHighPrecissionFloatingPointMode(), getJulianDayFromGregorianDate(), and restoreFloatingPointMode().
LongReal caelum::Astronomy::getJulianDayFromGregorianDateTime | ( | int | year, | |
int | month, | |||
int | day, | |||
LongReal | secondsFromMidnight | |||
) | [static] |
Get astronomical julian day from normal gregorian calendar.
Definition at line 267 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.
Definition at line 326 of file Astronomy.cpp.
Referenced by caelum::UniversalClock::getJulianDay(), getJulianDayFromGregorianDateTime(), caelum::UniversalClock::getJulianSecond(), caelum::SolarSystemModel::getMoonDirection(), and caelum::SolarSystemModel::getSunDirection().
void caelum::Astronomy::restoreFloatingPointMode | ( | int | oldMode | ) | [static] |
Restore old floating point precission.
Definition at line 333 of file Astronomy.cpp.
Referenced by caelum::UniversalClock::getJulianDay(), getJulianDayFromGregorianDateTime(), caelum::UniversalClock::getJulianSecond(), caelum::SolarSystemModel::getMoonDirection(), and caelum::SolarSystemModel::getSunDirection().