00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CAELUM__ASTRONOMY_H
00022 #define CAELUM__ASTRONOMY_H
00023
00024 #include "CaelumPrerequisites.h"
00025
00026 namespace Caelum
00027 {
00044 class CAELUM_EXPORT Astronomy
00045 {
00046 private:
00047 Astronomy() {}
00048
00049 static const LongReal PI;
00050
00054 static LongReal normalizeDegrees (LongReal x);
00055
00057 static LongReal radToDeg (LongReal x);
00058
00060 static LongReal degToRad (LongReal x);
00061
00062 static LongReal sinDeg (LongReal x);
00063 static LongReal cosDeg (LongReal x);
00064 static LongReal atan2Deg (LongReal y, LongReal x);
00065
00066 public:
00068 static const LongReal J2000;
00069
00077 static void convertEclipticToEquatorialRad (
00078 LongReal lon, LongReal lat,
00079 LongReal& rasc, LongReal& decl);
00080
00081 static void convertRectangularToSpherical (
00082 LongReal x, LongReal y, LongReal z,
00083 LongReal &rasc, LongReal &decl, LongReal &dist);
00084
00085 static void convertSphericalToRectangular (
00086 LongReal rasc, LongReal decl, LongReal dist,
00087 LongReal &x, LongReal &y, LongReal &z);
00088
00100 static void convertEquatorialToHorizontal (
00101 LongReal jday,
00102 LongReal longitude, LongReal latitude,
00103 LongReal rasc, LongReal decl,
00104 LongReal &azimuth, LongReal &altitude);
00105
00113 static void getHorizontalSunPosition (
00114 LongReal jday,
00115 LongReal longitude, LongReal latitude,
00116 LongReal &azimuth, LongReal &altitude);
00117
00118 static void getHorizontalSunPosition (
00119 LongReal jday,
00120 Ogre::Degree longitude, Ogre::Degree latitude,
00121 Ogre::Degree &azimuth, Ogre::Degree &altitude);
00122
00126 static void getEclipticMoonPositionRad (
00127 LongReal jday,
00128 LongReal &lon,
00129 LongReal &lat);
00130
00131 static void getHorizontalMoonPosition (
00132 LongReal jday,
00133 LongReal longitude, LongReal latitude,
00134 LongReal &azimuth, LongReal &altitude);
00135 static void getHorizontalMoonPosition (
00136 LongReal jday,
00137 Ogre::Degree longitude, Ogre::Degree latitude,
00138 Ogre::Degree &azimuth, Ogre::Degree &altitude);
00139
00146 static int getJulianDayFromGregorianDate (
00147 int year, int month, int day);
00148
00154 static LongReal getJulianDayFromGregorianDateTime (
00155 int year, int month, int day,
00156 int hour, int minute, LongReal second);
00157
00161 static LongReal getJulianDayFromGregorianDateTime (
00162 int year, int month, int day,
00163 LongReal secondsFromMidnight);
00164
00166 static void getGregorianDateFromJulianDay (
00167 int julianDay, int &year, int &month, int &day);
00168
00170 static void getGregorianDateTimeFromJulianDay (
00171 LongReal julianDay, int &year, int &month, int &day,
00172 int &hour, int &minute, LongReal &second);
00173
00175 static void getGregorianDateFromJulianDay (
00176 LongReal julianDay, int &year, int &month, int &day);
00177
00195 static int enterHighPrecissionFloatingPointMode ();
00196
00200 static void restoreFloatingPointMode (int oldMode);
00201 };
00202
00212 class CAELUM_EXPORT ScopedHighPrecissionFloatSwitch
00213 {
00214 private:
00215 int mOldFpMode;
00216
00217 public:
00218 inline ScopedHighPrecissionFloatSwitch() {
00219 mOldFpMode = Astronomy::enterHighPrecissionFloatingPointMode ();
00220 }
00221
00222 inline ~ScopedHighPrecissionFloatSwitch() {
00223 Astronomy::restoreFloatingPointMode (mOldFpMode);
00224 }
00225 };
00226 }
00227
00228 #endif // CAELUM__ASTRONOMY_H