Project

General

Profile

SO3Engine

#include <SO3Astronomy.h>

Static Public Member Functions

static double NormalizeDegrees (const double &x)
 
static double RadToDeg (const double &x)
 
static double DegToRad (const double &x)
 
static double SinDeg (const double &x)
 
static double CosDeg (const double &x)
 
static double Atan2Deg (const double &y, const double &x)
 
static void ConvertEclipticToEquatorialRad (const double &lon, const double &lat, double &rasc, double &decl)
 
static void ConvertRectangularToSpherical (const double &x, const double &y, const double &z, double &rasc, double &decl, double &dist)
 
static void ConvertSphericalToRectangular (const double &rasc, const double &decl, const double &dist, double &x, double &y, double &z)
 
static void ConvertEquatorialToHorizontal (const double &jday, const double &longitude, const double &latitude, const double &rasc, const double &decl, double &azimuth, double &altitude)
 
static void GetEclipticSunPosition (const double &jday, double &lambda, double &beta)
 
static void GetEquatorialSunPosition (const double &jday, double &sunRightAscension, double &sunDeclinaison)
 
static void GetHorizontalSunPosition (const double &jday, const double &longitude, const double &latitude, double &azimuth, double &altitude)
 
static void GetHorizontalSunPosition (const double &jday, const Ogre::Degree &longitude, const Ogre::Degree &latitude, Ogre::Degree &azimuth, Ogre::Degree &altitude)
 
static void GetEclipticMoonPositionRad (const double &jday, double &lon, double &lat)
 
static void GetHorizontalMoonPosition (const double &jday, const double &longitude, const double &latitude, double &azimuth, double &altitude)
 
static void GetHorizontalMoonPosition (const double &jday, const Ogre::Degree &longitude, const Ogre::Degree &latitude, Ogre::Degree &azimuth, Ogre::Degree &altitude)
 
static void GetMoonPhase (const double &jday, float &moonPhase)
 
static int GetJulianDayFromGregorianDate (const int &year, const int &month, const int &day)
 
static double GetJulianDayFromGregorianDateTime (const int &year, const int &month, const int &day, const int &hour, const int &minute, const double &second)
 
static double GetJulianDayFromGregorianDateTime (const int &year, const int &month, const int &day, const double &secondsFromMidnight)
 
static void GetGregorianDateFromJulianDay (const int &julianDay, int &year, int &month, int &day)
 
static void GetGregorianDateTimeFromJulianDay (const double &julianDay, int &year, int &month, int &day, int &hour, int &minute, double &second)
 
static void GetGregorianDateFromJulianDay (const double &julianDay, int &year, int &month, int &day)
 
static int EnterHighPrecissionFloatingPointMode ()
 
static void RestoreFloatingPointMode (const int &oldMode)
 
static void GetEclipticSunMeanLongitude (const double &jday, double &sunlon)
 

Static Public Attributes

static const double 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 double instead of float for precission. All angles are in degrees unless otherwise mentioned.

Definition at line 48 of file SO3Astronomy.h.

Member Function Documentation

◆ Atan2Deg()

double SO3::SAstronomy::Atan2Deg ( const double &  y,
const double &  x 
)
static

Definition at line 60 of file SO3Astronomy.cpp.

◆ ConvertEclipticToEquatorialRad()

void SO3::SAstronomy::ConvertEclipticToEquatorialRad ( const double &  lon,
const double &  lat,
double &  rasc,
double &  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.

Definition at line 74 of file SO3Astronomy.cpp.

◆ ConvertEquatorialToHorizontal()

void SO3::SAstronomy::ConvertEquatorialToHorizontal ( const double &  jday,
const double &  longitude,
const double &  latitude,
const double &  rasc,
const double &  decl,
double &  azimuth,
double &  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).

Definition at line 101 of file SO3Astronomy.cpp.

◆ ConvertRectangularToSpherical()

void SO3::SAstronomy::ConvertRectangularToSpherical ( const double &  x,
const double &  y,
const double &  z,
double &  rasc,
double &  decl,
double &  dist 
)
static

Definition at line 87 of file SO3Astronomy.cpp.

◆ ConvertSphericalToRectangular()

void SO3::SAstronomy::ConvertSphericalToRectangular ( const double &  rasc,
const double &  decl,
const double &  dist,
double &  x,
double &  y,
double &  z 
)
static

Definition at line 94 of file SO3Astronomy.cpp.

◆ CosDeg()

double SO3::SAstronomy::CosDeg ( const double &  x)
static

Definition at line 55 of file SO3Astronomy.cpp.

◆ DegToRad()

double SO3::SAstronomy::DegToRad ( const double &  x)
static

Convert degrees to radians.

Definition at line 45 of file SO3Astronomy.cpp.

◆ EnterHighPrecissionFloatingPointMode()

int SO3::SAstronomy::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 328 of file SO3Astronomy.cpp.

◆ GetEclipticMoonPositionRad()

void SO3::SAstronomy::GetEclipticMoonPositionRad ( const double &  jday,
double &  lon,
double &  lat 
)
static

Gets the moon position at a specific time in ecliptic coordinates

Parameters
lonEcliptic longitude, in radians.
latEcliptic latitude, in radians.

Definition at line 185 of file SO3Astronomy.cpp.

◆ GetEclipticSunMeanLongitude()

void SO3::SAstronomy::GetEclipticSunMeanLongitude ( const double &  jday,
double &  sunlon 
)
static

Definition at line 126 of file SO3Astronomy.cpp.

◆ GetEclipticSunPosition()

void SO3::SAstronomy::GetEclipticSunPosition ( const double &  jday,
double &  lambda,
double &  beta 
)
static

Definition at line 151 of file SO3Astronomy.cpp.

◆ GetEquatorialSunPosition()

void SO3::SAstronomy::GetEquatorialSunPosition ( const double &  jday,
double &  sunRightAscension,
double &  sunDeclinaison 
)
static

Definition at line 160 of file SO3Astronomy.cpp.

◆ GetGregorianDateFromJulianDay() [1/2]

void SO3::SAstronomy::GetGregorianDateFromJulianDay ( const double &  julianDay,
int &  year,
int &  month,
int &  day 
)
static

Get gregorian date from floating point julian day.

Definition at line 319 of file SO3Astronomy.cpp.

◆ GetGregorianDateFromJulianDay() [2/2]

void SO3::SAstronomy::GetGregorianDateFromJulianDay ( const int &  julianDay,
int &  year,
int &  month,
int &  day 
)
static

Get gregorian date from integer julian day.

Definition at line 282 of file SO3Astronomy.cpp.

◆ GetGregorianDateTimeFromJulianDay()

void SO3::SAstronomy::GetGregorianDateTimeFromJulianDay ( const double &  julianDay,
int &  year,
int &  month,
int &  day,
int &  hour,
int &  minute,
double &  second 
)
static

Get gregorian date time from floating point julian day.

Definition at line 303 of file SO3Astronomy.cpp.

◆ GetHorizontalMoonPosition() [1/2]

void SO3::SAstronomy::GetHorizontalMoonPosition ( const double &  jday,
const double &  longitude,
const double &  latitude,
double &  azimuth,
double &  altitude 
)
static

Definition at line 218 of file SO3Astronomy.cpp.

◆ GetHorizontalMoonPosition() [2/2]

void SO3::SAstronomy::GetHorizontalMoonPosition ( const double &  jday,
const Ogre::Degree &  longitude,
const Ogre::Degree &  latitude,
Ogre::Degree &  azimuth,
Ogre::Degree &  altitude 
)
static

Definition at line 236 of file SO3Astronomy.cpp.

◆ GetHorizontalSunPosition() [1/2]

void SO3::SAstronomy::GetHorizontalSunPosition ( const double &  jday,
const double &  longitude,
const double &  latitude,
double &  azimuth,
double &  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.

Definition at line 169 of file SO3Astronomy.cpp.

◆ GetHorizontalSunPosition() [2/2]

void SO3::SAstronomy::GetHorizontalSunPosition ( const double &  jday,
const Ogre::Degree &  longitude,
const Ogre::Degree &  latitude,
Ogre::Degree &  azimuth,
Ogre::Degree &  altitude 
)
static

Definition at line 177 of file SO3Astronomy.cpp.

◆ GetJulianDayFromGregorianDate()

int SO3::SAstronomy::GetJulianDayFromGregorianDate ( const int &  year,
const int &  month,
const 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 254 of file SO3Astronomy.cpp.

◆ GetJulianDayFromGregorianDateTime() [1/2]

double SO3::SAstronomy::GetJulianDayFromGregorianDateTime ( const int &  year,
const int &  month,
const int &  day,
const double &  secondsFromMidnight 
)
static

Get astronomical julian day from normal gregorian calendar.

Definition at line 275 of file SO3Astronomy.cpp.

◆ GetJulianDayFromGregorianDateTime() [2/2]

double SO3::SAstronomy::GetJulianDayFromGregorianDateTime ( const int &  year,
const int &  month,
const int &  day,
const int &  hour,
const int &  minute,
const double &  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 265 of file SO3Astronomy.cpp.

◆ GetMoonPhase()

void SO3::SAstronomy::GetMoonPhase ( const double &  jday,
float &  moonPhase 
)
static

Compute the moon phase at a given date.

Definition at line 244 of file SO3Astronomy.cpp.

◆ NormalizeDegrees()

double SO3::SAstronomy::NormalizeDegrees ( const double &  x)
static

Normalize an angle to the 0, 360 range.

Parameters
xThe angle to normalize

Definition at line 65 of file SO3Astronomy.cpp.

◆ RadToDeg()

double SO3::SAstronomy::RadToDeg ( const double &  x)
static

Convert radians to degrees.

Definition at line 40 of file SO3Astronomy.cpp.

◆ RestoreFloatingPointMode()

void SO3::SAstronomy::RestoreFloatingPointMode ( const int &  oldMode)
static

Definition at line 335 of file SO3Astronomy.cpp.

◆ SinDeg()

double SO3::SAstronomy::SinDeg ( const double &  x)
static

Definition at line 50 of file SO3Astronomy.cpp.

Member Data Documentation

◆ J2000

const double SO3::SAstronomy::J2000 = 2451545.0
static

January 1, 2000, noon.

Definition at line 51 of file SO3Astronomy.h.


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